On this page:
CSS stands for Cascading Style Sheets, it tells the browser how to display the XHTML page. CSS is very powerful, with one line you can change a whole site. This means also that one error can damage a whole site. You can hide complete sections of the page, which is very useful for printing. It is possible to have CSS file for different "media types", like for print.
To demonstrate the power of CSS, a copy of this page was saved and the css links were removed. So, please look at nostylep12.html. If you compare the source code then only a few lines are missing, the rest is exactly the same. Firefox and Opera users can also disable the stlyesheet of the page. Everything is functional, all the text is there, only the layout is missing.
There are three ways to include CSS inside the html:
1. Inline example:
It is shown here in example3. Open this page and click on the right mouse button to use "view source"
2. In head example:
It is shown here in example4 Open this page and click on the right mouse button to use "view source"3. In a separate CSS file
This looks more complicated but it is very useful for large sites where the layout from many pages can be controlled with one single CSS file.
This goes in the head section of the page, or in all pages on the site:
and this has to be saved in a separate file:
When now the CSS file is changed in for example
then on the whole site, every page that links to this CSS file changes its background color to white. Look here for example 5 which looks the same as the previous examples 3 and 4. The source code is different.
More about CSS also on the w3schools.com.
A classic way to make a page layout is with tables. This is depreciated in the XHTML standard. Tables should be used only for displaying tabular data. The whole layout should be done with CSS. A well known example is the site "Look Ma, No Tables". There are several examples, and they say: "Feel free to steal all the code you find on this site".
The page has to be separated in divisions (DIV's) For each DIV the properties has to be specified with CSS. Look on w3.org for an introduction.