How to use an

tag

inside a

in t

2019-01-12 05:59发布

This question already has an answer here:

I want to do something like this:

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

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?

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

7条回答
迷人小祖宗
2楼-- · 2019-01-12 06:36

It is not valid to have a h2 inside of a p.

Aside from that, and to answer your question, a h2 is a block level element. Making it an inline level element will cause it to behave similarly to how you describe the b tag acting.

p h2{display:inline}

As I said above though, the HTML you've given is invalid.

查看更多
登录 后发表回答