Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with <h1>

Status
Not open for further replies.

meeble

Programmer
Sep 24, 2002
137
GB
Hello,

When I use <h1> it also adds a line break after it. How do I get rid of this break? Can you use stylesheets?

Cheers

James
 
can you show the code for this
more then likely you have a return after the <H1> causing the line break.

if you wanted to use style for it you would do somethin glike a span or div
span is only for short phrases though
<style>
.txt {
font-size:46pt;
}
</style>
<span class=&quot;txt&quot;>Hello!</span>
or if it is for a large block of text
<div class=&quot;txt&quot;>paragraph</div> ---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

 
If you just use the <h1> tage it puts a blank line after whatever's in the tag.
 
Does anyone know how to get rid of this line? It happens in all <h> tags
 
Stylesheets can be used.

To take away the white space above and below the heading use margin:0px;

To make the heading flow &quot;inline&quot; (line breaks aren't forced before and after the element) use display:inline;

Examples:

<h1 style=&quot;margin:0em;&quot;>This is a Heading</h1>
<h1 style=&quot;display:inline;&quot;>This is a Heading</h1>

petey
 
Hello,

display:inline gets rid of some of the space, margin:0em doesn't do anything and nothing works in Netscape 4.x

Cheers

James
 
If your requirement is for your designs to look the same on Netscape 4, you're unfortunately out of luck.

Look at the Wired News page in Netscape 4 and then in IE 5/6 or Mozilla and notices the differences, then read their reasoning:

Also check out this:

I hope this helps!

petey
 
first
If you just use the <h1> tage it puts a blank line after whatever's in the tag
why are you putting anything in the tag?
what is the code in question?
if you do
<h1>heading</h1>
you result in one thing
BUT if you do things as
<h1>
heading</h1>
<h1> heading</h1>
etc..
browsers can interpret this differently.

you need to be more detailed and or give the code in question in asking why is this happening?

another note: drop the V4 issues. Most have and you should also. It's not worth it! ---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

 
Wait. It's a header. So it is going to have a line break at the </h1>.

If it is margin issues that you are trying to fix, or padding above and below, see above.
 
nice catch BDNFLNC and if that is the case in what you are trying to do then as BDNFLNC said you can't so do a span instead

<span style=&quot;font-size:46pt;&quot;>heading</span>more text


---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

 
Don't do this:

Code:
<span style=&quot;font-size:46pt;&quot;>heading</span>more text

This replaces a meaningful structural element, <h1>, for a less meaningful element, <span>, which is detrimental to accessibility and web standards.

petey
 
so should we as well throw the other less meaningful elements out the door and stick to the first release of HTML?

That sounds like it should be in the same category of we should keep up with the V4 browsers. Maybe that's a good ethical question in the ethic's forum.

as for the <span> tag I find hundreds of very good uses for it and hope others know it is a great means to include formatting aspects of their text.

besides the fact how can you come up with a argumentful conversation on the <span> tag not being a good idea over a preformatted tag when it is viewable in most browsers
like
Netscape 4, 6, 7
Mozilla 1
Internet Explorer 4, 5, 6
Opera 6
from my last check (thirty seconds ago)


---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

 
The purpose of HTML is to structure a document into something meaningful, regardless of how it might look. (This is a paraphrase of the w3c) This way you ensure the content is meaningful to everybody, because all user-agents and devices agree upon what the HTML tags mean, but few agree on how they should be presented.

<span> is great to set off pieces of text with some special meaning HTML can't convey, but if there's already an HTML tag with that meaning built-in then by all means use it! CSS can be used to make the tag look different, but if a browser doesn't support CSS at least the content structure is there.

There's tons of good articles about all this at these sites:

petey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top