28-11-2012, 02:21 PM
css basics.com
13544_CSS.pdf (Size: 277.65 KB / Downloads: 16)
Introduction to CSS
A CSS (cascading style sheet) file allows you to separate your web sites
(X)HTML content from it's style. As always you use your (X)HTML file to
arrange the content, but all of the presentation (fonts, colors,
background, borders, text formatting, link effects & so on...) are
accomplished within a CSS.
At this point you have some choices of how to use the CSS, either
internally or externally.
Internal Stylesheet
First we will explore the internal method. This way you are simply placing
the CSS code within the <head></head> tags of each (X)HTML file you
want to style with the CSS. The format for this is shown in the example
below.
External Stylesheet
Next we will explore the external method. An external CSS file can be
created with any text or HTML editor such as "Notepad" or
"Dreamweaver". A CSS file contains no (X)HTML, only CSS. You simply
save it with the .css file extension. You can link to the file externally by
placing one of the following links in the head section of every (X)HTML
file you want to style with the CSS file.
Cascading Order
In the previous paragraphs, I have explained how to link to a css file
either internally or externally. If you understood, than I am doing a good
job. If not don't fret, there is a long way to go before we are finished.
Assuming you have caught on already, you are probably asking, well can
I do both? The answer is yes. You can have both internal, external, and
now wait a minute a third way? Yes inline styles also.
So, which is better?
So with all these various ways of inserting CSS into your (X)HTML files,
you may now be asking well which is better, and if I use more than one
method, in what order do these different ways load into my browser?
All the various methods will cascade into a new "pseudo" stylesheet in
the following order:
1. Inline Style (inside (X)HTML element)
2. Internal Style Sheet (inside the <head> tag)
3. External Style Sheet
As far as which way is better, it depends on what you want to do. If you
have only one file to style then placing it within the <head></head>
tags (internal) will work fine. Though if you are planning on styling
multiple files then the external file method is the way to go.