What is Cascading Style Sheets (CSS)

Cascading Style Sheets (CSS) specifies the appearance and the formatting of an HTML document.

Defining and Applying a Style

A CSS style is made up of one or more declarations separated by a semi-colon. Each declaration consists of a CSS property and a value separated by a colon.


In the code above, the style has two declarations. background-color and color are called properties. The first sets the value grey for the background-color property. The second sets the value white for the color property.

        <style type="text/css"> 
        a { 
        <a href="http://java2s.com">Visit the website</a> 
        <a href="http://java2s.com">Visit the website</a> 
Click to view the demo

The declaration block is always enclosed in curly brackets. A declaration block can contain several declarations.

Each declaration must be terminated with a semicolon (;). The semicolon for the final declaration in a declaration block is optional.

Each property is separated from its value by a colon (:). Property names in CSS are not case-sensitive.

  HTML CSS Book 

  1. What is Cascading Style Sheets (CSS)
  2. Adding Styles to HTML
  3. Specifying the Character Encoding of a Stylesheet
  4. How Styles Cascade and Inherit
  5. Element Classification
  6. Cascading Style Sheets prefixes for the most popular browsers