Thursday, October 13, 2011

Cascading Style sheet - CSS

INTRODUCTION:
Everybody wanted a high degree of control over web page layout. So CSS has emerged a better solution .
Cascading Style Sheet defines how elements are displayed and where they are positioned on the page.
How to use CSS in web page ?
It is used with HTML to enhance page formatting.
It depends upon the use of element whether you are going to use it with inline element
Or by writing the code in head section only or by through linking a special file placed in separate folder.
The ease of use of CSS allow a well define management of content .
Types of CSS
There are different thinking about of CSS but generally we have three types of Cascading Style Sheet.
a)External CSS
b)Document or internal CSS
c)Inline CSS
1. External CSS:
An external style sheet is a plain text file with a .css file name extension that contains all style sheet rule which are required to your attribute written in simply a HTML.
You can link a style sheet to a web page by passing a tag in the head section.
This link element applies the style rules in the external sheet to the page .
N.B.
Helps to apply style specification to multiple documents because style information is cached by browser.
A external CSS file requires extra download time which may delay for page rendering.
How to use Cascading Style Sheet ?
First use a link tag for linking your external style sheet.

But a external file is like this
You have to create blocks in a CSS and have to write either by using .(dot) operator or by  #symbol or you can directly called a style.
Article on CSS
For automatically calling a style just write the style for that block.
BODY
{
TEXT-ALIGN: center;
MARGIN: 0px;
BACKGROUND: url(images/1.gif) white repeat-y ;
FONT-FAMILY: Arial, Helvetica, sans-serif;
COLOR: #686868;
FONT-SIZE: 12px
}
So if you have a link of any external CSS on your head section you can use the style on body section directly there is no need to use any class or id .
By using .operator you have to called the style block by appropriate class name.
.textholdarea
{
position: absolute;
width: 358px;
background: url(images/sl.png) no-repeat left top;
height: 257px;
top: 5px;
right: 0px;
}

For example for a particular division you can write like this to use above style

So for using above style you have to use a class attribute by calling the above class name in that element .
 By using # operator you have to called the style block by id .
Then that id can be used in any attribute you want to use your style.
#content
{
position: relative;
width: 957px;
background: #FFFFFF url(images/contentrepeat.jpg) no-repeat;
top: -2px;
left: -2px;
height: 165px;
}

So for using above style block u have to call it by using id attribute .
Like

2.Document level CSS / Internal CSS:
It is one and another way to embed a style .
In it you have write the style within the head section under a style block .
You can write either style either by . and # operator or by direct as the appropriate HTML tag.
How to use this Cascading Style Sheet ?
The writing is much more similar to external style sheet except a separation of file it is write with in head section by using style block.
CLICK HERE TO READ FULL ARTICLE

No comments:

Post a Comment