CSS Tricks - H tags styled for inline use
There are times when you may want to use a heading within a sentence and not
have the line break after the heading code and have the heading look like
regular bold text.
Here is the usual way this would look:
This is a heading running
into a sentence.
Here is the way the inline CSS styled sentence looks:
This a styled heading running
into a sentence.
HTML Code:
<div><h1>This a styled heading
running</h1> into a sentence.</div>
CSS Code:
body {
font-family: arial, helvetica, sans-serif;
font-size: .8em;
color: black;
}
h1 {
display:inline;
font-size: 100%;
font-weight: bold;
}
Notes:
- You have to insert the after the <h1> tag to insert the space.
- This can be used to style any H tag 1-6.
- Do not use all <h1> tags as your site might appear spammy to the search
engines. Use the tags the way they were intended, as headings for the
various sections and sub-sections of your page.
- The actual page code of this example is slightly modified, so the
example style tags do not overwrite the site's existing style rules.
- While this code will validate at the W3C, it might be considered, by some,
as a bad design pratice, since it does not follow the true
representation of the various sections.