/    Sign up×
Community /Pin to ProfileBookmark

CSS consistency on browsers

Hi,

I’m using style sheets for the layout of my website, but am really struggling with the consistency of the sheets across different browsers. This is mainly to do with the positioning of elements, my page looks so different when using IE, IE on laptop, Mozilla etc. So what I was wondering is what method of placement is best to achieve consistent results. Do people tend to use absolute positioning or relative, padding and margins, or setting the size of elements to avoid the auto option etc.

Any ideas or reference material on the subject would be great.

Thanks,

Tom

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@drhowarddrfineAug 27.2008 — All of the above. Consistency is maintained by following web standards and testing in standards compliant browsers. Currently, those are everything but Internet Explorer. Therefore, initially design and test using Firefox/Opera/Safari, etc., then see if IE managed to follow along. If not, the hacks to fix IE are well known.
Copy linkTweet thisAlerts:
@WebJoelAug 27.2008 — ...Do people tend to use absolute positioning or relative, padding and margins, or setting the size of elements to avoid the auto option etc.[/QUOTE] "Position:absolute;" should be used sparingly, for objects that will be expected to move about the page, or for 'exactly' positioning something that will 'overlap' something else. "absolute" lifts the element (IMG, DIV, TABLE, etc) out of the document flow and base it's position upon position 0,0 (left-top, top-left) of the user's monitor... and since IE adds proprietary margins & padding to elements, this gets [I]all messed up[/I] when viewed in IE... Other browsers do not add this 'padding'/'margin' to everything...

Make your first CSS rule always be:

  • * {margin:0; padding:0;}

    and 90% of the X-browser issues are solved right there. "universal selector" removes ALL margin/padding, from ALL elements, using just this one line.

    However, if you add this line to an *[U]existing[/U] webpage* that otherwise looks okay in IE, it WILL most likely mess-up the page BECAUSE you previously positioned every element based upon IE inept proprietary settings (-still with me?)

    *I* like, prefer & use the "auto" option for widths/height and use (internal) padding on same, to make the content 'fit' into the container against multiple-size viewscreens/resolutions. This is also called "fluid design".

    The 'default position' of elements is "static", by the way. It is only when explicitly stating "position:relative;" does any element become "relative" to the element preceding it... Mostly, the only time you would need to state "position:relative;" on an element is if that element will contain a "position:ABSOLUTE;" in it, so that [I]it[/I] (the 'child element') can be positioned based off of position "0,0" of the "relative-positioned" parent...

    -I know it's all probably very confusing, -but once you stretch your head around these terms and concepts and see IRL what they can do, -creating web pages that -from a content viewability- are 99.9% identical on multiple browser platforms, becomes easier. ? I have built probably 200+ websites and I think only have ever had to use 'IE-conditionals' on maybe two sites because I couldn't figure any other way quickly enough for client demands, so, I opted for [I]the big-easy[/I] quick fix.
  • Copy linkTweet thisAlerts:
    @Tom3CauthorAug 28.2008 — That was a seriously useful reply thanks for that. My issue was initally designing the sign in IE. They have to be difficult don't they!!!

    As you say once understanding all the you can acheive what you what quickly, the problem is trying to learn whats going on, and unless you have someone to tell you it's hard to work out.

    Thanks, that's really helped.

    Tom
    ×

    Success!

    Help @Tom3C spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.16,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...