CSS has several options for redefining the style of links.
LINK PROPERTIES
DEFINING STYLES FOR LINKS
As mentioned in the above table, there are four different selectors with respect to links.
You can specify whatever style you'd like to each of these selectors, just like you'd do with normal text.
The four selectors are:
PRACTICAL EXAMPLES
Here you can see a few examples on how CSS can be used to replace the traditional image based mouseover effects for links.
The hover style is not supported by Netscape browsers prior to version 6, but since it does no harm, you can still use it for the benefit of the +90% of visitors that arrive using MSIE).
One of the most common uses of CSS with links is to remove the underline. Typically it's done so that the underline appears only when a hover occurs. In the example below, we did just that. In addition we added a red color for hovered links.
Example: Hover
The link from the above example would look like this:
Another example would be to create links that are both underlined and overlined.
Example: Underline/Overline
The link from the above example would look like this:
A third example would be to create links that change in size
when hovered.
Example: Size changing links
The link from the above example would look like this:
A final example would be to create links that have a permanent background color, obviously standing out from the rest.
Example: Background colored links
The link from the above example would look like this:
MULTIPLE LINKSTYLES ON SAME PAGE
The final topic deals with how to add multiple link styles that can be used on the same page.
In the above examples we addressed the HTML selector - A:link etc - and thus redefined the overall link style.
How do we define a link style that is only active in a certain area of the page?
The answer is: context dependent selectors.
Rather than addressing the A:link selector we will address it while being dependant on a certain outer class that surrounds the area where we'd like our link style to be effective.
For example:
Note how we use the <span> to define the context.
This is smart for two reasons:
1) The obvious, that it allows us to use different link styles on
the same page, rather than being limited to using a single
overall link style.
2) We can define entire areas where a certain link style works for all links within that area. Thus, we don't have to add a style definition to each and every link in that area.
LINK PROPERTIES
|
DEFINING STYLES FOR LINKS
As mentioned in the above table, there are four different selectors with respect to links.
You can specify whatever style you'd like to each of these selectors, just like you'd do with normal text.
The four selectors are:
|
PRACTICAL EXAMPLES
Here you can see a few examples on how CSS can be used to replace the traditional image based mouseover effects for links.
The hover style is not supported by Netscape browsers prior to version 6, but since it does no harm, you can still use it for the benefit of the +90% of visitors that arrive using MSIE).
One of the most common uses of CSS with links is to remove the underline. Typically it's done so that the underline appears only when a hover occurs. In the example below, we did just that. In addition we added a red color for hovered links.
Example: Hover
|
The link from the above example would look like this:
LOOK HERE |
Another example would be to create links that are both underlined and overlined.
Example: Underline/Overline
|
The link from the above example would look like this:
LOOK HERE |
A third example would be to create links that change in size
when hovered.
Example: Size changing links
|
The link from the above example would look like this:
LOOK HERE |
A final example would be to create links that have a permanent background color, obviously standing out from the rest.
Example: Background colored links
|
The link from the above example would look like this:
LOOK HERE TO SEE |
MULTIPLE LINKSTYLES ON SAME PAGE
The final topic deals with how to add multiple link styles that can be used on the same page.
In the above examples we addressed the HTML selector - A:link etc - and thus redefined the overall link style.
How do we define a link style that is only active in a certain area of the page?
The answer is: context dependent selectors.
Rather than addressing the A:link selector we will address it while being dependant on a certain outer class that surrounds the area where we'd like our link style to be effective.
For example:
|
Note how we use the <span> to define the context.
This is smart for two reasons:
1) The obvious, that it allows us to use different link styles on
the same page, rather than being limited to using a single
overall link style.
2) We can define entire areas where a certain link style works for all links within that area. Thus, we don't have to add a style definition to each and every link in that area.
0 comments:
Post a Comment