CSS syntax
example
p {
color: red;
text-align: center;
}
element selector
id selector
class Selector
</p><p class="center large">This paragraph refers to two classes.</p>
grouping selectors
- If you have elements with the same style definitions, like this:
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p {
text-align: center;
color: red;
}
- It will be better to group the selectors, to minimize the code.
- To group selectors, separate each selector with a comma.
- In the example below we have grouped the selectors from the code above:
- Example:
h1, h2, p {
text-align: center;
color: red;
}CSS comments
/* This is
a multi-line
comment */
In the following declaration block, which elements are considered properties?
{font-family: Avenir, Arial, sans-serif;
font-size: 20px;
padding: 8px;}