CSS: Syntax
The syntax for CSS styling looks like this:
element { property:value; property:value }
The element is an HTML element. The property is a CSS property. The value is a CSS value. The combination of property and value is a CSS style. Multiple styles are separated with semicolon and enclosed by curly brackets (marked in red in the example above.).
HTML file: |
Displayed by browser: |
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color:lightgray}
h1 {color:blue}
p {color:green}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
|
This is a heading
This is a paragraph.
|