PDF download Download Article PDF download Download Article

When coding a website in HTML/CSS, a fun trick to learn is to add effects when you hover over an item. The first method will teach you how to hover over text to change the CSS. There are many different tricks with the hover selector; the second method will demonstrate how to make an image appear when you hover over text.

Method 1
Method 1 of 2:

Changing the Page Appearance

PDF download Download Article
  1. 1
    Open your HTML editor. Any code editor will work.
  2. 2
    Advertisement
  3. 3
    Give your item a class. A class is an attribute that lets one style HTML code easily.
     <h1 class="testColor">Hello!</h1>
    
  4. 4
  5. 5
    Call on your class and add :hover in your CSS. The `:hover` selector must be written inside your stylesheet or within the `<style>` block in the `<head>`, not inside the HTML body. To target the class, write a period, then the class name, then `:hover`. Add the hover effects inside the curly brackets.


    .testColor:hover {
    color: pink;
    }
    
  6. 6
    Save and test your code. If working properly, the page will change when you hover over the text.
  7. Advertisement
Method 2
Method 2 of 2:

Making Something Appear

PDF download Download Article
  1. 1
    Write a line of code that you want the hover to be connected to. Use whatever type of tag you want.
  2. 2
  3. 3
    Put the items you want to appear in the div tag. You might choose to copy an image URL or add your own images.
  4. 4
  5. 5
  6. 6
    Go to a browser and test your code. If working properly, the items will appear when you hover your cursor over the header.
  7. Advertisement


Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement

Tips

Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time.
How helpful is this?
Co-authors: 5
Updated: November 26, 2025
Views: 170
Categories: CSS
Thanks to all authors for creating a page that has been read 170 times.

Is this article up to date?

Advertisement