如何使用 &lt;h2&gt;标签</h2>在&lt;p&gt;&lt;/p&gt;里面在文本中间? [英] How to use an &lt;h2&gt; tag &lt;/h2&gt; inside a &lt;p&gt;&lt;/p&gt; in the middle of a text?

查看:40
本文介绍了如何使用 &lt;h2&gt;标签</h2>在&lt;p&gt;&lt;/p&gt;里面在文本中间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做这样的事情:

<p>This is a <h2>text</h2> paragraph.</p>

我禁用了 h2 的边距和填充,但它仍然在 h2 标记之前和之后断线.如何在文本中间使用 h2 标签并使其看起来像一个普通单词,就像 <b > 是吗?

I disabled margin and padding for the h2 but it still breaks the line before and after the h2 tag. How can I use the h2 tag in the middle of a text and make it look like if it was a normal word, just like < b > does?

我的 html 文档的 doctype 是XHTML 1.0 Transitional"

The doctype of my html document is "XHTML 1.0 Transitional"

推荐答案

在正文中使用表示标题"的标签是不合适的. 标签是逻辑标签;它们的使用赋予所附文本意义——即,该文本是一个节标题.

It's not appropriate to use a tag that means "heading" within body text. The <h..> tags are logical tags; their use imparts meaning to the enclosed text -- namely, that the text is a section heading.

虽然您可以使用 display: inline 属性,但请考虑使用更合适的标签,甚至是 <span> 标签.

Although you could use the display: inline attribute, consider using a more appropriate tag, or even a <span> tag.

这篇关于如何使用 &lt;h2&gt;标签</h2>在&lt;p&gt;&lt;/p&gt;里面在文本中间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆