- 1). Write the HTML code for the elements you want the user to interact with. Note that you can apply the mouse-over effect to all elements of a certain type, or all elements of a certain class, or specific elements of a given ID. Be sure to identify your elements correctly. Examples:
<a href="/links/?u=linked_url">Any link and its background that will change color</a>
<a href="/links/?u=linked_url">A link in class "turn-red" and its background that will change color</a>
<a href="/links/?u=linked_url">A link with the ID of "unique-color" and its background that will change color</a> - 2). Write the style rules in the <head> section of the page. You can set any styles, including text color and background color by designating a style with the pseudo-class ":hover." Examples (element, class and ID types respectively):
a:hover {color: blue; background-color: white; }
a.turn-red:hover{ color: red; background-color: black; }
a#unique-color:hover { color: purple; background-color: yellow; } - 3). Publish the Web page and test the settings.
SHARE