Introduction to CSS
Basic CSS Structure
A CSS sheet is made up of a list of rules which contain three parts
for example
A CSS sheet is made up of a list of rules which contain three parts
- Type Selector
- Property
- Value
for example
body {color:red}
- 'body' is the type selector - referring to an existing HTML tag
- 'color' is the property
- 'red' is the value
Embedded and External style sheets
Embedding is a 'quick and dirty' approach where re-usability is not an issue. External style sheets are to be preferred where possible
<style type="text/css">
body {color:red}
</style>
External style sheets need a link in the HTML file
<link rel = "stylesheet" type="text/css" href="mystylesheet.css" />
IDs and Classes
In the stylesheet:
ID selectors start with a #
Class selectors start with a .
ID selectors start with a #
Class selectors start with a .