Target this HTML tag... | with this CSS selector |
---|---|
<div>...</div> | div |
<p>...</p> | p |
<hl>...</hl> | h1 |
<ul>...</ul> | ul |
Note the use of curly brackets, colons, and semi-colons for separating the elements...
selector {
property: value;
property2: value2;
}
Let's say we want a certain amount of spacing around our page header (h1). This is done with the margin property. There are two ways of describing this in CSS. First the fully described method...
h1 {margin-top: 5px; margin-right: 10px; margin-bottom: 5px; margin-left: 10px;}
Many CSS properties also have a shorthand method for values...
h1 {margin: 10px 20px 10px 20px;}
Which translates as...
h1 {margin: top right bottom left;}
The numbers are always clockwise from the top -- top/right/bottom/left
For further exploration... if values repeat, the values statement can be shortened even further.
This CSS code would now describe every single H1 in the website in the same way. But what if we want them to look in different ways in the same site?
Contact information goes here