CSS Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
CSS Topics
css tutorials Introduction
Types Types
Background Properties Background Properties
Text Properties Text Properties
Font Properties Font Properties
Box Properties BOX Properties
Border Properties Border Properties
Margin Properties Margin Properties
Padding Properties Padding Properties
Special Topics Special Topics
Forums Ask Your Doubts
Scraps More about CSS
Feedback Feedback
 




Types - External Style Sheet


Tutorials Css

Topic

How can I have a external style sheet?
I want to have a separate file containing all my styles, how to do it.




Explanation

This will be very useful when we have so many styles defined. We will want to take all the styles in to a different file. That's what we do in External CSS. We take all the styles in a external file and map it with the html page.

Example:
We will put the following style in a text file say mystyle.css
<style>
.mystyle1
{
color: green;
background-color: orange;
}
</style>


In our head we will link to the external style sheet using the tag link in header portion
Tag:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>

The names used for user defined styles should not belong to any html tag. We set the style for the tag using the attribute "class".
Example1:

<font class=mystyle1> MY STYLE </font>
Result1:
MY STYLE

Example2:
<a href="index.php" class=mystyle1> MY STYLE </a>
Result2:
MY STYLE



A Note
CSS - Cascading Style Sheets can be used along with html tags as explained in this site. This simple CSS will help you to create much elegant and neat html web pages. This does not need any additional softwares or codings. All web browser are capable of handing CSS codes.

Note 2: If required you can using <span> instead of <div> tags. div tag will start and end on new lines. span will not exceed the tag area.
Other Links

web hosting