3. CSS syntax
3. CSS syntax
First, use a DOCTYPE in your HTML. If you don't, most browsers revert to
a non-standard backward-compatibility "quirks" mode.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Styles can be specified in 3 places HTML:
- inline style: a list of properties in the "style" attribute of an individual HTML element
<a href="home.html" style="color: green;">
(This is generally the least useful/flexible way.)
- internal style sheet: a set of rules in a <style> element
<style>a { color: green; }</style>
- external style sheet: a set of rules in an external file named in a <link>
<link rel="stylesheet" type="text/css" href="/mystyle.css">
(This is generally the most useful/flexible way.)
Style sheet files can also import other style sheet files (but only before normal rules):
@import "another.css";