Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS h1 and h2 tags on same line

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #23504
    daydreemer
    Member

    How can you write a line of text with the first 2 words bold and the rest of the words in the line normal.

    I tried wrapping the first 2 words in a h1 tag and the rest in h2, but the h2 part gets pushed down to another line when previewed.
    e.g.
    <h1>First words</h1><h2>the rest of the sentence</h2>

    Thanks, Steve

    #50822
    jim
    Member

    <body>
    <strong>hey</strong> hey
    </body>

    Maybe?

    #50878
    daydreemer
    Member

    The strong tags didn’t work. No idea why. This is what ended up working OK:

    <h1 style="display:inline;">Bold text goes here</h1> <h2 style="display:inline;">normal text goes here</h2>

    Steve

    #191960
    criewel
    Participant

    same problem, but cybershot`s worked 100%
    thanx

    <h1>first words</h1> <h2>Second words</h2>

    then in the stylesheet do

    #heading h1, h2 { display: inline; }

    #191963
    GSutherland
    Participant

    I mean, this accomplishes getting the text on the same line with different weights, but it’s not semantic. If this is a header, use one tag and use a span with a class that styles the text within that span or use strong. If it’s just regular text, use a paragraph tag and do the same. In the examples given, you’re splitting up one piece of text amongst two separate tags to achieve a side effect of them being in separate tags, and that is a bad idea for a number of reasons.

    Edit: Of course, if what you REALLY want is an h1 tag and an h2 tag on the same line, this is the way to go. But I’m just not thinking that’s the actual need here from the examples provided.

    #191973
    GSutherland
    Participant

    wow, i didn’t even look at when this topic was from.

    hah.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.