<br> inside an H tag

OK, I know his is going to really sound basic, but is the H tag suppose to ignore a <br> when it is inside an H tag? So if I use this code:

<h2> This is header text but I want the rest<br />of this line to be on the second line. </h2>

I want it to look like this:
This is header text but I want the rest
of this line to be on the second line.

Not this:
This is header text but I want the rest of this line to be on the second line.

That should work fine. Why do you say it gets ignored? How are you testing it? Works for me in Firefox.

I am using on the header “What types of results might you expect? You will learn how to:” on this page and it is not wrapping.

Hm, something weird going on there. If you just grab your raw HTML, the break displays fine, but something is overriding it, though can’t see what. Might be some JavaScript pulling it out. :sick:

Try putting a “p” tag between and see if that works, it might give you a clearer picture as to whats stopping it.

but something is overriding it, though can’t see what. Might be some JavaScript pulling it out. :sick:
Yes it is javascript pulling the <br> out and it is also placing a span in there.

When I disable js the heading breaks as it is intended to and I am able to see the <br> in firebug.

Actually, you don’t need a <br>.

Use this:


HTML
<h2>What types of results might you expect? You will learn how to:</h2>


CSS
h2 {
    font-size: 200%;
    width: 18em;
}

For different font sizes, you may need to also set different em width to accommodate.

If he want to always break the line at the same point it’s easier to use a br though.

Could you also use noonope’s properties and write a class for it…?

<br> would be my last choice.

First off, I would use em width. Then I would use <span>.

<br> is for when author CSS is not possible. If author CSS is possbile, there is no reason to use <br>. In this case, if author CSS is not applied, it makes little sense to use a multiple lines h2.

I think write a class then, otherwise writing a tag selector will apply those properties to all your h2’s.

Avoiding the use of presentational HTML elements is always better, but sometimes makes things easier (like in this case). Now it’s the author of the topic that has to choose :slight_smile:

PS: I don’t want to be mistaken, I would use only CSS :wink:

You can’t have a <p> tag within an <h1> :frowning:

I didn’t mean for validation, I just thought that it was worth seeing if it would split the line and help identify the problem.

I could be totally wrong with this next point but doesn’t HMTL5 allow block level tags within block level tags or something along those lines…?

On a purely semantic point, the second half of the tag seems like it shouldn’t be in the header at all. I’d actually say it’s worth of being in a <h2> tag alone, with the <h1> around the question part:

<h1>What types of results might you expect?</h1>
<h2>You will learn how to:</h2>

Good point. Perhaps even this:

<h2>What types of results might you expect?</h2>
<p>You will learn how to:</p>

Replacing valid code with invalid and incorrect code is likely to introduce more problems, and unlikely to help you identify what the original problem was at all!

Good point.

You know I’m sure I heard that HMTL5 now allows this sort of thing but Ill have to check it.