Article five of a series by Jim Stiles.
NOTE: Readers should already be familiar with basic style sheet properties and functions.Cross-Browser Compatability Issues
You will most likely encounter problems when applying your CSS, if not in one browser, then in another. Before trying to fix the cross-browser CSS compatibility issues, you should first validate your style sheet. If it passes validation, you can then sure the problem isn't caused by incorrect code but by incorrect browser implementations. Nonetheless, there are some well-known issues related to Windows Explorer in particular (you shouldn't find these with other browsers):
body {
max-width: 600px;
}
This gives the page body a maximum width, so your text will remain within the readable area of the page, even on larger screen resolutions. Although Windows Explorer does not support max-width, users can opt to resize the window the text is too wide for the viewing screen.Basic Page setup using tables:
This is a basic table setup is most commonly used for the block-type page. It contains header, left navigation, right content and footer cells.<table> <tr> <td colspan="2"> <div class="header">Header</div> </td> </tr> <tr> <td> <div class="navigation">Navigation</div> </td> <td> <div class="content">Content</div> </td> </tr> <tr> <td colspan="2" style="vertical-align: bottom"> <div class="footer">Footer</div> </td> </tr> </table>
Replacing the use of certain tags
1. FONT tag
You no longer need to use the <FONT> tag. Instead, use:
body {
font: 0.8em verdana,sans-serif;
}
NOTE: There are some conflicting problems when using font sizes in table cells.
body,td,li,p {
font: 0.8em verdana,sans-serif;
}
2. CENTER tag
You should also refrain from using the <CENTER> tag. CSS should now be used for centering text and blocks of content. To center the text in div.text you do the following:
div.text {
text-align: center;
}
Centering entire blocks is a bit more complicated. If you want to center the entire div.text, use the following:
div.text {
margin-left: auto;
margin-right: auto;
}
NOTE: (auto means: “as much as you need.” The <div> takes as much margin as it needs and equally divides it between left and right. As a result it is centered).
div.container {
text-align: center;
}
div.text {
margin-left: auto;
margin-right: auto;
text-align: left; /* overrule inheritance */
}
Accessibility
When you've created and validated the entire file, you should perform an accessibility check. To do this, remove all style sheets and JavaScript from the file look at the page unstyled. The content should still be in a logical order and all navigation should display properly.Next, I will show you some examples of how this stuff actually looks.
<<< Previous | HOME | Next >>>