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"
It is not valid to have a
h2
inside of ap
.Aside from that, and to answer your question, a
h2
is ablock
level element. Making it aninline
level element will cause it to behave similarly to how you describe theb
tag acting.As I said above though, the HTML you've given is invalid.