CSS Hover Selector :hover
Hello Coders!
It's been a while since my last tutorial, I'm hoping to get a lot more out within the next couple of weeks. This tutorial is going to show you how to change the element's appearance when you hover over them using
In this tutorial, I will quickly go over the:hover selector and how it can be used. Firstly, is understanding the syntax required in order to add a hover effect. The
[CODE lang="css" title="This shows how :hover is implemented into the CSS syntax." highlight="1"]h1:hover {
property: value;
}[/CODE]
In most cases, you will probably have two declarations, one is without the
Example of usage:
You can use
Changing height & width of an image when hovering: In this example, the
Changing an H1 background colour when hovering: In this example, the
Now you should have an understanding of how :hover works and how to implement it. If you have any questions please feel free to reply to this thread!
Hello Coders!
It's been a while since my last tutorial, I'm hoping to get a lot more out within the next couple of weeks. This tutorial is going to show you how to change the element's appearance when you hover over them using
:hover
. You should have an understanding of both HTML & CSS. You can What is HTML and What is CSS to get you started.In this tutorial, I will quickly go over the:hover selector and how it can be used. Firstly, is understanding the syntax required in order to add a hover effect. The
:hover
is place right after the main selector (e.g. h1 h1:hover
. Then followed by properties and its values. An example is down below:[CODE lang="css" title="This shows how :hover is implemented into the CSS syntax." highlight="1"]h1:hover {
property: value;
}[/CODE]
In most cases, you will probably have two declarations, one is without the
:hover
and one with the :hover
.Example of usage:
You can use
:hover
to change the appearance of text, images, buttons etc when you hover over them. For example, you can change the width and height of an image when you hover over it. Like shown below:Changing height & width of an image when hovering: In this example, the
img
has the properties width and height with values 100px and 200px. When you hover the width and height increase in size to make the image bigger. [CODE lang="css" title="CSS when not hovering EXAMPLE."]img { width: 100px; height: 200px; }[/CODE] | |
Code:
|
Changing an H1 background colour when hovering: In this example, the
h1
has the property color with the value black. When you hover that color property changes to red.Now you should have an understanding of how :hover works and how to implement it. If you have any questions please feel free to reply to this thread!