Every developer would like to come with a nice button on the website. But he would never want to create a separate image for each one of them. He would always like to come up with one CSS style that can be used across all the buttons. It should also have a nice hover effect and in case you are looking to learn all this, this is a tutorial you must read then. In order to accomplish this, we require a text editor, a normal state background image and a hover state background image.
In order to obtain the effective and attractive hover effect on buttons present in the website, one needs to define a pseudo-class. After accomplish this, you are ready to completion of your task.
Listing 1: Defining the Pseudo Class
a{
text-decoration:none;
}
a:hover{
text-decoration:underline;
}
The above example is used to bring in all HTML link tags underlined when there is a hover-over done on them which is made possible because of CSS :hover pseudo-class. pseudo-classes need to be defined after their parent classes.
This will make it inherit all their properties. Hence in order to make some hover effect, you need to define a :hover pseudo-class after its parent class. This would then require modifications or incorporation of new properties.
Point to note here are that the older versions of Internet Explorer i.e. IE6, have pseudo-classes that are supported only for link (a) tag whereas in other browsers, this works for any other HTML tag.
Example:

Figure 1: Illustrating Hover over Effect on buttons
Here in you need to define a parent class that will suffice the purpose of separating an ordinary link form a button that can be done by making a class of links. The below lists the example of the same:
Listing 2: Defining the Parent Class
a{
color:#00F; /* blue */
}
a.button{
color:#F00; /* red*/
}The above code will help in separation of an ordinary link form a link with class="button".
We will come to our actual process after we are through with the understanding of CSS class that will be 32px high and 92px wide with centred text. However the size can be specified as per the desire. The below code lists the example of the same:
Listing 3: Defining the attributes of a button
a.button{
display:inline-block;
width:80px;
height:20px;
padding:5px;
border:1px #D7D7D7 solid;
text-align:center;
text-decoration:none;
color:#666666;
background:url(button_bg.png) repeat-x;
}
a.button:hover{
background:url(button_bg_hover.png) repeat-x;
text-decoration:none;
}The below code lists the example of a button made with CSS.
Listing 4: Creating a button with CSS
<html>
<head>
<title>Attractive CSS Buttons by MrBool</title>
<style type="text/css">
a.button{
display:inline-block;
width:80px;
height:20px;
padding:5px;
border:1px #D7D7D7 solid;
text-align:center;
text-decoration:none;
color:#666666;
background:url(button_bg.png) repeat-x;
}
a.button:hover{
background:url(button_bg_hover.png) repeat-x;
text-decoration:none;
}
</style>
</head>
<body>
<h1>Attractive CSS Buttons Article by MrBool</h1>
<a class="button" href="http://www.mrbool.com/">Design</a>
</body>
</html>Example:

Figure 2: Illustration of a Web Button
The point to note here is that, you need to put the images in the same directory as this example page. The other thing could be to modify the background url so as to point to the place where you put them.
We learned with the help of this article how to make attractive and appealing buttons for the website, looked at the hover-over effect on the same making use of HTML. Hope the article was useful and will help you to implement some real stuff in your websites.
.jpg)








See the prices for this post in Mr.Bool Credits System below: