CSS: Syntax
CSS Syntax
CSS source code looks like this:
p { line-height: 1.5; width: 600px; font-family: sans-serif; } li { margin-top: 10px; } blockquote { color: blue; } img { max-width: 100%; height: auto; margin: 1px; } table.xyz { border: solid 1px grey; }
In general, CSS code has lines like this:
selector {
propertyName1 : value1;
propertyName2 : value2;
propertyName3 : value3;
}
The selector means the tag matching syntax.
Semicolon is used as separator, and is optional for the last item.
Space or line return has no meaning, unless they are inside a quoted string such as "Courier New".
code { font-family: "Courier New", monospace; }