Search This Blog

Thursday, 31 December 2009

Cascading Style Sheets for beginners

CSS or Cascading Style Sheets is a stylesheet language used to set the display of a document written in markup language. CSS used to format web pages written in HTML or XHTML format. Even so, the language can be used for all types of XML document, including SVG and XUL. CSS specifications set by the World Wide Web Consortium (W3C).

CSS is typically used by the writer and the reader to determine the web page colors, fonts, layout, and display various aspects of web documents. CSS's main function is to separate the contents of documents (written in HTML or other markup language) with the presentation of documents (written in CSS). This separation aims to improve the accessibility of content, providing more flexibility and control to display the document, and reduce complexity and repetition in structural content.






CSS enables the same page to be displayed in different ways for different presentation methods, such as through a screen, print, voice (when read by a browser-based voice or screen reader), as well as braille readers. HTML or XML page that also can be displayed together in different ways, both in terms of style or color scheme of the display using CSS.

CSS Advantages:

   
1. Update the look is more easily
   
2. Smaller bandwidth burden
   
3. Modifications easier web templates
   
4. More easily used on mobile phones
   
5. Seacrh engine friendly
   
6. If we want to change a theme of a web page, just modify the css alone.
   
7. A CSS can be used many web pages.

Lack of CSS:

   
1. Views on different browsers.
   
2. Sometimes there is also a browser that does not support CSS (older browsers).
   
3. Must know how to use it.
   
4. needed more time in the making.
   
5. Not to mention there is a bug / error in the CSS.
 

CSS can be applied in 3 ways:

   
1. Directly written to the tag head.

   
2. Using an external file. That is, any css code stored in a file with type. Css and later declared head tag in the following manner:

   
3. Applied directly to the relevant tag

In writing CSS code has its own rules. Perhaps for those of you who are still very common on CSS, this article could be used as learning material for you.

How to declaring and writing CSS

   
1. Using sign # as the prefix. Examples:

      
# my_style (
      
background-color: # 000;
      
font-color: # fff;
      
)

      
To declare, as will be labeled # then attribute that is used is id. So the example declaration is:

      
blah blah blah

      Well .. so the result will be like this:

      
bla bla bla

      
But remember, the nature of the id is unique. Hence there can be no other elements that use the same id in a CSS.

   
2. Using the dot or dot (.). as a prefix, for example:

      
. my_style (
      
background-color: red;
      
font-color: # fff;
      
)

      
To declare, for wearing the sign (.) Then the attribute is the class used. So the example declaration is

      
text

      Well .. so the result will be like this:

      
bla bla bla

      
Well .. if the nature of the id is unique, then the other hand, if the class is not unique and can be applied more than the same class 1 in a html doc.

   
3. Without wearing a # or (.) But directly applied to a html code, for example:

      
div (
      
background-color: blue;
      
)

      
Well if you use this way, then all the div tags will have the same style as CSS code.

 

Read More...

View blog reactions