Hover Links in CSS (part 1)

Hover Links in CSSThis 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!


Close    To Top
  • Prev Article-Web Design:
  • Next Article-Web Design:
  • Now: Tutorial for Web and Software Design > Web Design > HTMLCSS > Web Design Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction