Learn HTML step-by-step from A to Z or improve your professional skills.  Home HTML and CSS Tutorials Hover Links in CSS (part 1)

Hover Links in CSS (part 1)

Browse Pages: 2  > >>

Hover Links in CSS (part 1)This tutorial will show you how to create hover effects with your links using CSS Styles!

1. Create a new document in your favorite text editor, and type the following code into it:

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>CSS Hover Links</title>
</head>
<body>
This is my Text.  <a href="http://www.greycobra.com">This is a Link to GreyCobra.com</a>.  Here is some more text.
</body>
</html>

2. Save this document as hover.html.  Open hover.html in your web browser, and you will see that it displays some text, a link, and then some more text.  Not very interesting.  Now lets use CSS Styles to change the way our link looks:

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>CSS Hover Links</title>
<style type="text/css" media="all">
a {
color: #007431;
}
</style>
</head>
<body>
This is my Text.  <a href="http://www.greycobra.com">This is a Link to GreyCobra.com</a>.  Here is some more text.
</body>
</html>

3. Save and open in your web browser, and you will see that your links color has changed from its standard color, to a dark green!  In the code shown above, we made a few changes to make this possible.  First off, we added the <style> tag in the <head> tag.  In the <style> tag, we made a style for our "a" tags by typing a {.  In this style, we told the color to be #007431, and ended this specification with a ";".  We then ended our "a" tag style with a "}".  As you continue learning CSS, you will become more familiar with how this all works.  Now we need to create a style for when we hover over our links:

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>CSS Hover Links</title>
<style type="text/css" media="all">
a {
color: #007431;
}
a:hover {
color: #9A0319;
}
</style>
</head>
<body>
This is my Text. <a href="http://www.greycobra.com">This is a Link to GreyCobra.com</a>. Here is some more text.
</body>
</html>

4. As you can see, we added another style called "a:hover".  This tells our "a" tags what to do when they are hovered over.  In our style, we told the color to turn to #9A0319, a deep red color.  Save this and open in a web browser of your choice.  As you can see, the link changes colors when scrolled over! 

Result

Good Luck!



Author's URL: GreyCobra.com
Browse Pages: 2  > >>
Learn HTML step-by-step from A to Z or improve your professional skills. More Tutorials: Featured Materials | Fresh Materials | More HTML Tutorials at Markuptutorials.com

Reader's comments
comments home loans January 06, 2012 says:
If you want to buy a car, you would have to receive the loan. Moreover, my sister always takes a short term loan, which supposes to be the most reliable.
Reply
comments credit loans December 29, 2011 says:
If you are willing to buy a car, you will have to receive the mortgage loans. Moreover, my brother always uses a college loan, which seems to be the most fast.
Reply
comments home loans September 27, 2011 says:
I took 1 st home loans when I was a teenager and it helped me a lot. Nevertheless, I need the credit loan once again.
Reply
Add comments to "Hover Links in CSS (part 1)"

Captcha