Treehouse: Grow your CSS skills. Land your dream job.

Line breaking H tags

  • # October 18, 2012 at 12:35 am

    What is the preferred method for splitting an H tag into two lines? I kind of like the following method, but I don’t really like adding tags just for styling.

    [CodePen Example]( “”)

    # October 18, 2012 at 1:09 am

    You would be better off using the <br> tag.

    # October 18, 2012 at 2:31 am

    True, but I was thinking about being able to style the second line separately also.

    # October 18, 2012 at 2:50 am

    Then might it not make more sense to do:

    <h1>Main Title</h1>
    <h2>Differently styled sub title</h2>
    # October 18, 2012 at 2:59 am

    I thought about that too, but I wanted the h1 to be a single sentence when styles are turned off, or if the document gets printed. I wish there was a way to target the text after the br tag, but I can’t think of a way.

    # October 18, 2012 at 3:25 am

    Use a span and set it to display: block.

    # October 18, 2012 at 3:33 am

    That’s what I was doing originally, but was trying to accomplish a similar thing without adding the extra span markup. I’m thinking that’s probably the best solution though.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.