Home arrow Style Sheets arrow Page 2 - The Advantages of Style Sheets
STYLE SHEETS

The Advantages of Style Sheets


Style sheets have become ever more popular each year as designers realize that whole web sites can be customized without too much fine editing. They allow properties for the whole site to be set, such as page color, link color, margins, text size, and much more. All of these can be keyed into a single file or in the main body of the code.

Author Info:
By: Stephen Davies
Rating: 3 stars3 stars3 stars3 stars3 stars / 6
August 07, 2007
TABLE OF CONTENTS:
  1. · The Advantages of Style Sheets
  2. · Inline and External Styles
  3. · The CLASS and ID tags
  4. · Final Working Examples

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
The Advantages of Style Sheets - Inline and External Styles
(Page 2 of 4 )

Style sheets prevent repetitive actions that are repeated through each page of the web site. Consistency is the key when designing web pages. If edits need to be done to ensure every <P> tag is an Arial font for example, without style sheets, this soon becomes repetitive. It is also very time consuming, a very important point firmly in mind particularly if you are a freelance designer working to a contract deadline. There are three ways a style sheet can change this.

Internal Style

<HEAD>
 
<TITLE>Change the paragraph colour and size</TITLE>
 
<STYLE TYPE="text/css">
   
P { font-size: 3; color: blue; font-family: Arial; }
   
A { font-size: 3; color: red; font-family: Arial; }
 
</STYLE>
</HEAD>

This is okay but can be a little repetitive. It is best used to make alterations outside of the CSS file attached as shown below. Embrace the properties inside the <STYLE></STYLE> tags. Since we are applying text, we specify that the TYPE is "text/css". Here the P and A tags are being styled by font size, color and face.

Inline Styles

These can be typed into the line where the style is required and will override any style properties set by the internal or external style sheet.

<p style="color: green; font-family: Arial">
 
This text will be green and of the Arial family.
</p>

This is useful if small modifications are needed quickly.

External CSS file

This will link the properties to the web page via a linked .CSS file. This line is placed in between the <HEAD> tags just like the <STYLE> tags:

<LINK HREF="stylesheet.css" REL="STYLESHEET" TYPE="text/css">

HREF specifies that the link to the filename storing the properties is called stylesheet.css. REL specifies the relationship of the file to the HTML page as a stylesheet.

Here is an example of what the stylesheet.css could contain:

.sizefamilyP {
 
font-size: 3;
 
color: blue;
 
font-family: Arial;
}

.sizefamilyP is called a class name and is used in the main HTML code to apply the properties specified in the CSS file. In the main HTML body of the page, any line that includes the class name of .sizefamilyP will adopt the properties defined in the above CSS file.

e.g. <p class="sizefamilyP">This text will follow the properties above in the CSS file</p>

The class name applied here tells the P tag to adopt the properties specified in the CSS file. The class can be applied to any tag in the HTML code in the same way by simply changing the tag above.

Now I'll go into more depth on the subject by explaining the use of the class name and the ID tag in more detail.


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials