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.
background-color:grey;
color:white;
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.
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
<style type="text/css">
a {
background-color:grey;
color:white
}
</style>
</head>
<body>
<a href="http://java2s.com">Visit the website</a>
<a href="http://java2s.com">Visit the website</a>
</body>
</html>
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
CSS
- What is Cascading Style Sheets (CSS)
- Adding Styles to HTML
- Specifying the Character Encoding of a Stylesheet
- How Styles Cascade and Inherit
- Element Classification
- Cascading Style Sheets prefixes for the most popular browsers