Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryWeb Content Preparation

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Hover Changes Border

When a cursor hovers over a text link, the text may display different attributes. The hover attributes might be color or font change, or underlining appearing or disappearing.

This article shows how to change borders around link text when the cursor hovers over it.

Here is an example.

When the mouse hovers over any of those links, the border changes from double ruled blue to dotted red. (Older browsers that don't support the "dotted" property may render a dashed border, instead.)

Each link has 4 states.

  1. link (unvisited)
  2. visited (link has been visited)
  3. hover (mouse is hovering over link)
  4. active (link is active; i.e., getting the next page)

Each state can have its own borders. In the example, the link and visited states both have a double blue border. The hover and active states both have a dotted red border.

To make your own border changing links, create a div within which the links are published. The div needs a unique id value.

In the example, the id value is "example".

<div id="example">
<a href="//www.willmaster.com/">Home</a> &nbsp; 
<a href="//www.willmaster.com/library">Library</a> &nbsp; 
<a href="//www.willmaster.com/blog">Blog</a> &nbsp; 
<a href="//www.willmaster.com/software">Software</a>
</div>

Next, put the CSS on the page (or in the external style sheet).

The example CSS assumes the link div's id value is "example" (as above).

<style type="text/css">
#example a:link { 
   padding:0 5px 0 5px; 
   border:3px double blue; 
   }
#example a:visited { 
   padding:0 5px 0 5px; 
   border:3px double blue; 
   }
#example a:hover { 
   padding:0 5px 0 5px; 
   border:3px dotted red; 
   }
#example a:active { 
   padding:0 5px 0 5px; 
   border:3px dotted red; 
   }
</style>

Define the classes in the order given in the example.

a:link and a:visited may be switched. But a:hover must come after those two. And a:active must come after a:hover. See CSS Pseudo-classes at the w3schools website.

The classes may contain color, font-size, and other elements, in addition to the padding and border elements in the example.

That's all there's to it. The borders change when the cursor hovers over the links.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC