There are three ways of inserting style information:
[Top]
External style sheets are the best method when you want the style to be applied to many pages. With an external style sheet, you can change the look of an entire web site by changing one external style sheet file. Each HTML document that you want to apply these styles to must contain a link to the style sheet using the <link> tag inside the <head></head> section:
<head>
...
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
The browser will read the style definitions from the file mystyle.css, and format the HTML document accordingly.
An external style sheet can be written in any text editor and saved with a .css extension.
[Top]
An internal style sheet should be used when a single document has a unique style. You define internal styles in the <head></head> section by using the <style> tag, like this:
<head>
...
<style type="text/css">
body {background-image: url(images/back40.gif);}
hr {background: #ffffff;color: 0000ff;}
p {margin-left: 20px;}
</style>
</head>
The browser will now read the style definitions, and format the document according to it. If the document also contains a link to an external style sheet, the internal style declarations will over-ride any similar declarations within the external sheet.
This can be helful when you wish to re-adjust the style of a single page - for example, alter the padding on the body tag.
[Top]
An inline style loses many of the advantages of style sheets by mixing content with presentation.
Therefore, you should use this method sparingly, such as when a style is to be applied to a single occurrence of an element.
To use inline styles, you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example below shows how to change the font-style and the left margin of a paragraph:
<p style="font-style: italic; margin-left: 20px;">
This is a paragraph
</p>
Inline style will overide both internal and external style declarations.
[Top]
If some properties have been set for the same selector in different style sheets, the final value will be inherited according to the rules of Cascading Style
For example, an external style sheet has these properties for the h3 selector:
h3 {text-align: left; font-style: italic; font-size: 200%;}
And an internal style sheet has these properties for the h3 selector:
h3 {text-align: right; font-size: 100%;}
And an inline style declaration reads:
<h3 style="font-size: 80%;">...</h3>
The final values will be:
[Top]
Tags: Css, Miscellaneous, Usage, Use, Webpage
Related Items:
This website follows the ideas of the No Nofollow, I Follow, DoFollow, No-NoFollow movement. Leave a helpful comment and you will get a link without NoFollow (U Comment, I Follow).
If you are looking for web hosting then I would recommend my current web host. They have been good to me, suiting both beginners and advanced users.
Using a transparent and trusted advertising network always helps to generate more revenue on a website. One of the networks I use achieves this more than the others.
If you would like to help pay the web hosting bill for this site, you can donate through my host
If you are looking for web hosting then I would recommend my current web host. They have been good to me, suiting both beginners and advanced users.
Using a transparent and trusted advertising network always helps to generate more revenue on a website. One of the networks I use achieves this more than the others.
If you would like to help pay the web hosting bill for this site, you can donate through my host