CSS Tutorials

Cascading Style Sheet

CSS is a Cascading Style Sheet which is used to style a Document.

This helps in styling every html elements using their attributes.

There are three ways of embeding a style sheet into a document

1.External Style sheet
2.Embedded style
3.Inline style

External Style sheet

Here the external style sheet is used to style the document
It is performed using the following tag inside "head" tag of document using "link" tag.

Example


Here rel is the relationship of the external file which is linking to the document and type indicates the type of external file linking to it and the href is the target url of the file.


Embedded Style


Here the style is written in the same document rather linking to other external file.
The style can be written either in the "head" section or "body" section of the document.

It uses the style tag to specify the style which has the closing and opening style tag.

Example



Inline Style

Inline styles are always taken the most precedence over the other two way of styling the document.This is achieved by specifying the style in the same tag of the element of the document.

Example




Which results as follows

Hello from Inline style for document


CSS uses elements class and id to style the particular element

Id selector is indicated using the "#" symbol while defining the style and class selector is defined as dot "." to describe the style for particular style for that element.

Example



Using Id selector

Using class selector



CSS can be used to style any of the document elements like
font,heading,paragraph,table,textbox,buttons,labels,textarea etc.

Styling the font

The following code



results in this format

styled font

Styling the label

The following code



results in this format



Styling the paragraph

The following code



results in this format

styled paragraph