Jump to content

Recommended Posts

Posted

Is there any way to prevent the line breaks after a set of <h1></h1> tags?

 

I'd like to use the tag but it makes the page look, well, kinda crappy.

Posted

Actually, even CSS masters recommend you use <h1> tags, Jim :lol:

Among other things, it allows your webpage to be correctly displayed even on browsers that have different stylesheets set up to override the ones you specify on your webpage. Or even browsers that don't make use of stylesheets at all but know how to interpret XHTML tags. Or vocal-browsers, for blind people. Or... OK, you get the point :(

 

As for your question, boxturt, you can prevent the line break after the <h1> tag if you use CSS to set it's display style to inline.

 

Something like this should do the trick:

><h1 style="display: inline;" >Inside H1</h1>Outside H1

The "Outside H1" text should appear right next to the "Inside H1" text.

 

If you take out the "style=....." stuff, leaving only

><h1>Inside H1</h1>Outside H1

you will indeed have a line break. That's because the H1 element is a block level element instead of an inline element, which means that it has an implicit line break right after it.

If it was an inline element, it would not have a line break after it, like the <a href=.....> tags.

 

So what you do is use CSS to make it an inline element, effectively turning off the line break :lol:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...