| A class is the blueprint from which individual objects | | | | rules in the CSS so they work together. The way |
| are created. In Java, a class is used to show a set of | | | | that it is designed to work in CSS, each selector has |
| like items. | | | | specificity. So just like anything else in the cascade, if |
| Here is an example of a hyper link going to a site | | | | there are two selectors that are both applied to one |
| using a class: Elite Web Strategies a:link { color: | | | | element, the one with the higher specificity is applied. |
| #000000; background-color: #ffffff } a:visited { color: | | | | If you put them in the wrong order, you could end |
| #0000ff; background-color: #ffffff } a:hover { color: | | | | up with a page that isn't showing your style rules as |
| #0000ff; background-color: #ffffff } a:active { color: | | | | you intended them. |
| #ff0000; background-color: #ffffff } So what is each | | | | The only two that you can change the order on are |
| part used for? | | | | the a:link and a:visited (primarily because a link is only |
| * "a:link" will specify what the hyperlink looks like on | | | | either or, never both). You can change many things |
| the page. * "a:visited" will specify what the hyperlink | | | | with links, but always keep in mind that specificity so |
| looks like once it has been visited (clicked on). * | | | | that they show properly on your page. |
| "a:hover" shows what the hyperlink will look like when | | | | Here is an example of a potential problem and how it |
| hovered and * "a:active" specifies what the active link | | | | is corrected. |
| will look like. | | | | Problem Ordera:link { color: #000000; |
| In the above example you'll also notice both color and | | | | background-color: #ffffff } a:visited { color: #0000ff; |
| background colors are designated. Color indicates the | | | | background-color: #ffffff } a:active { color: #ff0000; |
| actual color of the font, followed by the hex code | | | | background-color: #ffffff } a:hover { color: #0000ff; |
| for the color you want. The background color is the | | | | background-color: #ffffff } |
| color behind the text itself, followed by the hex code | | | | If you use the above CSS, all of it will work except |
| for that color. | | | | the active rules. Those will not show. This is because |
| It's important that these hyperlinks are written in the | | | | the active has to come after the hover to follow the |
| proper order which is why they are put in a class | | | | LVHA format. If the active is placed before the |
| such as above. | | | | hover, it breaks that part of the class. |
| CSS Link Specificity - How to Put Your Links in Order | | | | Simply swapping the places of the active and hover |
| There is an acronym to help you remember the | | | | will fix the order of the cascade and allow it to all |
| proper order to place your links in. You might think of | | | | work. |
| something to help you remember it easier but some | | | | Correct Ordera:link { color: #000000; |
| people simply remember LVHA. This simple acronym, | | | | background-color: #ffffff } a:visited { color: #0000ff; |
| LVHA will help you get your hyperlinks in the right | | | | background-color: #ffffff } a:hover { color: #0000ff; |
| order every time. | | | | background-color: #ffffff } a:active { color: #ff0000; |
| LVHA stands for: | | | | background-color: #ffffff } |
| 1. a:link 2. a:visited 3. a:hover 4. a:active | | | | Following the LVHA rules will help you keep your CSS |
| LVHA is the order you should designate your link | | | | hyperlinks in the right order to comply with W3C. |