I have multiple paragraphs of text in an HTML document. Also, at various points, some of the text is wrapped in <h6></h6> tags, which is meant to apply certain font effects. In my CSS, the h6 tag is set to display:inline; so the paragraph keeps going continuously without a line break. This works except for the first instance of h6 on each page it is used: there is always a line break before the first element. Does anyone know why/how to prevent this?
CSS:
h6 {
font-family:'Courier New',Courier,'Nimbus Mono L',monospace;
font-size:125%;
display:inline;
}
HTML:
As expected, not a lot was accomplished (in this plane) over a
five-day weekend when much of it was devoted tot he college
process. However, I'm down to only a handful of HTML-validation
errors. A couple of which are going to be particularly problematic,
dealing with my new <h6>Lytebox JavaScript</h6> I talked about
earlier: to enable Lytebox on an image, you give it a CSS tag
<h6>data-lyte-options</h6>...
The second essence of h6 works fine, but there is a line break before the first.
Heading elements can’t be contained inside paragraphs, because inherently they’re treated as block-level elements hence browsers break paragraphs when they get to a block-level element like heading.
Your particular HTML gets changed to this by browsers:
I found a reference to this fact in HTML specification:
And another reference that talks about block-level elements:
Solution?
The problem is that you’re using headings as usual paragraph text (with its own style). You should be using
SPANelements instead to make your HTML valid.If all you’d like to do is to format your text to be displayed as code then you can also use
CODEelement which should be used exactly for this purpose.