![]() ![]() |
Moderator Alumni![]() Group: Hall Of Fame
Joined: 31-August 02
Posts: 15,634
|
Jun 14 2005, 08:24 PM |
|
|
Hi Barry,
It's not the number one rule mainly because there are a lot of things that you need to understand before you get to the Visual Model of CSS2, and how containing blocks work. It helps to first understand how a selector works, how values are assigned, and how inheritance and cascading work. Once you have those down, you need to be able to understand the box model. After you have that, the visual model, and things like containing blocks are the next step. A lot of tutorials don't get that far. Your sidebar div acts as a containing block for your sidebarbox. It helps give it context, when it comes to positioning. This is about the simplest illustration I could find of how a containing block works: http://members.aol.com/jbjtutor/css/pagec_27.html I'll throw a more complicated example at you, too: http://www.stopdesign.com/articles/absolute/ |
||
| Offline | ![]() |
Moderator/Blog Editor![]() ![]() Group: Site Admin
Joined: 18-January 05
Posts: 5,375
From: Olympia WA, USA
|
Jun 15 2005, 03:14 AM |
|
|
NICE list of examples. You've covered quite the gamut, between w3c's verbal documentation, Stopdesign's lovely look so thoughtful and full of resources, and the little straightforward diagram at http://members.aol.com/jbjtutor/css/pagec_27.html.
If I were to choose a preferred site I'd go for Stopdesign. On the other hand, the AOL page made sense the fastest. Their CSS tutorial is easy as pie, one step at a time. http://members.aol.com/jbjtutor/css/ Thanks for the links, yet again. Elizabeth |
||
| Offline | ![]() |
Moderator Alumni![]() Group: Hall Of Fame
Joined: 27-January 03
Posts: 3,438
From: Brighton, UK
|
Jun 15 2005, 03:49 AM |
|
|
Yup, Barry, that's a useful thing to know. Personally I've started using it more and more, because IE doesn't treat the Box Model properly. Even the latest versions of IE still get parts of it wrong (for example, the position of a background is calculated before the border is drawn, putting it in the wrong place). It's a nice, relatively safe (though not "clean") way of working part this problem.
|
||
| Offline | ![]() |
Star Member![]() Group: Members
Joined: 11-December 03
Posts: 800
From: Back in Sunny California
|
Jun 17 2005, 01:19 AM |
|
|
you know I've never tried working with opera outside of viewing it on browsercam... but from my understanding, the FF / Mozilla browser is closer to abiding by the W3Cs standards than is IE.
Tantek's famous hack tackles that issue: http://tantek.com/CSS/Examples/boxmodelhack.html However, I could be wrong.... I'm not exactly clear on the facts. I just wish the all the browsers would render code the same way. |
||
| Offline | ![]() |
Moderator![]() Group: Moderators
Joined: 6-March 03
Posts: 7,962
From: Langley, British Columbia, Canada
|
Jun 17 2005, 06:45 AM |
|
|
I hesitate to cross swords with you, Dave, but Opera and Firefox treat width differently. That is part of the dilemma in getting hacks that will cover both Opera and IE since Opera is 'standards compliant' and IE isn't.
I only ran into this when I assumed that Opera was the same as Firefox. I've put together a small example to illustrate the problem. You can check it out in all three browsers at the following link: operatest050617.htm You will see that apart from the vertical spacing Opera and IE look similar with the upper Div being narrower. This is because both have assumed that the padding in the upper box is within the width. Firefox looks different because it adds the padding to the width in the upper box. So both boxes look the same width. The code for operatest050617.htm is as follows: QUOTE <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html> <head> <title>Opera Test</title> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> <style type=\"text/css\"> body { background:#123; margin:0; padding:0px; width:600px; } div#main { width:400px; padding:0 50px; background:#678; margin-left:100px; } div#main2 { width:500px; padding: 0; background:#abc; margin-left:100px; } </style> </head> <body> <div id=\"main\"> <p>&</p><p>&</p><p>&</p> <p align=\"center\">This is the Main Div</p> <p>&</p><p>&</p><p>&</p> </div> <div id=\"main2\"> <p>&</p><p>&</p><p>&</p> <p align=\"center\">This is the Main2 Div</p> <p>&</p><p>&</p><p>&</p> </div> </body> </html> This is why I couldn't figure out how to hack Opera to handle width right and thankfully found the container within a container approach. I don't claim to be an expert, I just try to make things work. So if I've gone astray somewhere in the above, please let me know. |
||
| Offline | ![]() |
Moderator![]() ![]() Group: Moderators
Joined: 29-August 02
Posts: 5,751
From: Bristol, UK
|
Jun 17 2005, 01:01 PM |
|
|
Opera doesn't have a quirks mode per se, it's more the others that do.
Quirks mode come into effect when you don't have a proper DTD at the top of the HTML. When they find a page with either a missing, or incomplete DTD, they go into quirks mode, and try and sort some stuff out, because they can't be as sure how to interpret things. An old A List Apart article called Fix Your Site With the Right DOCTYPE! may help clarify things. Remember that articles over 3 yrs old, so some references will be out of date, the general message should be accurate though. Says something about using standards to future proof your coding as well |
||
| Offline | ![]() |
Moderator![]() ![]() Group: Moderators
Joined: 29-August 02
Posts: 5,751
From: Bristol, UK
|
Jun 17 2005, 01:34 PM |
|
|
Hmmm, I thought it used to error when shown a doctype like that.
The list of valid HTML4.01 Doctypes from the standards A lot of sites, particularly CMS type web software like many forums, won't validate. There are generaly few web apps that do, Wordpress does mostly, though depends if you put invalid HTML in a post yourself. |
||
| Offline | ![]() |
Moderator Alumni![]() Group: Hall Of Fame
Joined: 27-January 03
Posts: 3,438
From: Brighton, UK
|
Jun 18 2005, 04:45 AM |
|
|
Barry, don't pay too much attention to that validator when it comes to DTDs. The original DTD you were using was - technically - valid (I think). According to the standards, IIRC, you are allowed to add a DTD without the reference URL in it. However, browsers will not always interpret that correctly and some will slip into quirks mode if you leave out the URL. A better, and still valid, DTD includes the URL.
When it (the DTD) is complete, browsers behave in standards compliant mode. QUOTE Opera doesn't have a quirks mode per se, it's more the others that do. IE and Opera both have quirks modes (added to Opera in version 7) - that's why it looked like they were behaving the same way originally. Quirks mode is a sort of backwards-compatibility more for older sites. The forum doesn't validate, no. We're using a slightly modified version of the default template, and it would be a lot of work to make that validate. Finally, here is a list of all HTML DTDs. |
||
| Offline | ![]() |
|
|
2 Pages 1 2 >
|
|
| Lo-Fi Version | Time is now: 9th February 2010 - 04:10 PM |
| Meet our Moderators: | cre8pc : projectphp : sanity : Black Phoenix : bwelford : EGOL : Ruud : rustybrick : AbleReach : swainzy : joedolson: eKstreme: dazzlindonna : SEOigloo: iamlost : RisaBB |