Forum Moderators: not2easy
thanks
I used to be a table guy in the days before CSS, but once all browsers mostly supported CSS (e.g. Netscape 4 ceased to be used) I switch fully to CSS. What I have learned is that CSS is immensely more controllable than tables.
For instance using CSS and DIV tags I have created a page layout that changes depending upon the situation. There are there are three basic sections. Section 1 is the main content, section 2 is the primary navigation menu, and section 3 is my primary ad section.
In my HTML source code these sections are in the 1,2,3 order. When the web page is rendered to the screen in a normal web browser they are displayed in a three column format with section 3 being the first column, section 1 being the second column and section 2 being the third column. This gives the page a traditional three column layout. For example:
Section 3 | Section 1 | Section 2 When a user goes to print a page both sections 2 & 3 are turned off and section 1 is reformatted to fill the printed page.
This is accomplished calling different CSS files based on the media type. for example:
<LINK rel="stylesheet" type="text/css" href="/css/main.css" media="all">
<LINK rel="stylesheet" type="text/css" href="/css/screen.css" media="screen">
<LINK rel="stylesheet" type="text/css" href="/css/printer.css" media="print">
What is even more beautiful about using CSS is that when the structure of a site is well thought out, totally reformatting the layout of the page is simply a matter of changing one or two CSS files. No recoding of the the HTML is necessary. The final beauty of CSS is that you can offload all the formatting instructions from the HTML source code to a separate CSS file that can be cached by the browser. What this means is that the HTML becomes much cleaner and more compact and thus as a user surfs around your site your pages load faster because the formatting instructions don't have to be downloaded for every page.
The key to maximizing the potential of CSS is to:
1) make sure you allow CSS to handle ALL of the formatting chores;
2) only use HTML to provide semantic structure;
3) build and test primarily using Firefox, Safari & Opera, once it looks the same in those three browsers tweak for IE (IE is where most issues lay); AND
4)(this is important) make sure all of your code validates to W3C HTML and CSS specifications (I use HTML4.01 Strict and CSS2).
Do those four things and with a little practice you will be able to code web pages that render correctly across all current browsers with very minimal accommodations for Internet Explorer.