Wednesday, September 19, 2012

CSS (Cascading Style Sheets)

CSS is a programming language which allows us to decide how a document will be shown on the web.As in HTML, in CSS you can also use any regular text editor, like notepad or others in order to create a stylesheet.Just remember saving the document as a .css file.
How does it work?
Very simple, with the CSS stylesheet you will modify HTML elements.You will do this by opening a new document and typing the following:
#text{color:#FF0000}

 
  1. Element name.

    Here we will introduce the name of the HTML element/s that we want to modify.
  2. Declaration

    The declaration, situated in between {} is the information that will change our HTML element.In case there is more than one delaration you use ; to seperate them.
  3. Atribute and value

    Inside the declaration, the atribute defines how the element will be changed and after that gives it a value.                                                                                                                          

Style in code


The style in code is directly putting the styles on the HTML document we want to modify.This is not the recommended type of style, we will always try to seperate the content from the presentation.


Example:<p style="color:#ff0000">This car is red</p>

 

Intern style


This style is defined in the HTML document , in between .To do so, inside of the head tag we will introduce our styles in between tags. 

Example:<head>
                <style type="text/css">p{color:#ff0000}</style>
               </head> 

External style


This is the most used.To modify any HTML element you will generate a stylesheet with your notepad or any text editor.Once finished save it as a .css file.Now all we have to do is introduce it into our HTML document between . 

Example:

Content of style.css:
p{color:#ff0000 ;}

Content of<head></head> in HTML file:
<link href="style.css" rel="stylesheet" type="text/css" />

You can generate and introduce all the archives you wish.

No comments:

Post a Comment