Forum Moderators: not2easy

Message Too Old, No Replies

Headers in CSS, text shifting difference IE

         

kenbo64

9:33 pm on May 7, 2008 (gmt 0)

10+ Year Member



Set up H1 style sheet in head section.
Set up body text style sheet in head.
Wrote text - made first line H1 then full paragraph and remainder of text as bodytext style.
OK in IE6 but all text (header & bodytext) shift down.
Without H1 text does not shift.
Hope this makes sense

Marshall

9:39 pm on May 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi kenbo64, welcome to WebmasterWorld.

Each browser has its own default margins and padding for tags. The easiest thing to do, IMHO, is set the desired margins and padding in your CSS to make them uniform across browser platforms.

Marshall

kenbo64

9:43 pm on May 7, 2008 (gmt 0)

10+ Year Member



Thanks Marshall - you are talking to a complete novice can you explain further

Marshall

10:04 pm on May 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In your CSS, simply assign the margins to the <h>, and if you want, the <p> tags (or any other tags for that matter) to achieve a uniform look across browser platforms.

h1, h2, h3, h4, h5, h6, p {
margin: 10px auto 10px auto; /* reads top, right, bottom, left; */
}

You can also shortcut this to

h1, h2, h3, h4, h5, h6, p {
margin: 10px auto; /* reads top/bottom, right/left; */
}

You can do the same with the padding if necessary:

h1, h2, h3, h4, h5, h6, p {
padding: 10px auto; /* reads top/bottom, right/left; */
}

But try the margins first before changing the padding.

The number I pick, 10px, is arbitrary. Use what you need to achieve the look you want. The fact different browser assign different margins and padding to elements is a pain, but not always crucial unless you have a fixed design layout they you do not want to shift.

Marshall

kenbo64

10:10 pm on May 7, 2008 (gmt 0)

10+ Year Member



Thanks again will try tomorrow

kenbo64

8:54 am on May 8, 2008 (gmt 0)

10+ Year Member



Brilliant - it worked - Thanks