This document aims to provide a basic understanding of Cascading Style Sheets (CSS), to help you learn how you can use CSS to enhance your documents for the World Wide Web.
In this section, we cover
- Implementing Styles
- Inline Styles
- Embedding Styles
- Linking Styles
- Style Precedence, Inheritance, Context
Styles for Web documents can be implemented in the following ways:
- To apply a particular style to a single HTML element, the inline style attribute is used.
- If styles for several elements will repeatedly be used within a document, the STYLE element provides a better way to group that information.
- For optimal flexibility, where similar styles will be applied to multiple documents, authors should define styles in external style sheets.
In CSS, styles are defined by way of a declaration, which consists of a property, followed by a colon (:), followed by a value, as in:
font-size: 12pt
NOTE: CSS is not case-sensitive, and spaces are insignificant in the property:value declaration. The conventions used here are only for clarity.
Any number of valid property:value pairs in any order may be set, and are separated by a semi-colon (;), as in:
font-size: 12pt; color: blue
Before delving into the complete list of CSS property names and valid values, let us first examine the fundamental concepts cited above, to help better understand succeeding discussions.