Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Adding Hover Effects | Getting Started with CSS
CSS Fundamentals

bookAdding Hover Effects

Swipe to show menu

Web elements can respond to user interaction. One of the most common interactions is hovering the mouse over an element.

In CSS, this is handled using the :hover pseudo-class.

What Is :hover?

The :hover pseudo-class applies styles when the user places the mouse pointer over an element.

Basic syntax:

selector:hover {
  property: value;
}

Example:

index.html

index.html

styles.css

styles.css

copy

When the user hovers over the button, the background color changes. When the cursor is over the link, the link becomes underlined.

Note
Note

:hover works on most HTML elements. It only activates when the pointer is over the element.

Why Hover Effects Matter

Hover effects improve the user experience, provide visual feedback, and make interfaces feel more interactive.

They are commonly used for links (<a>) and buttons, as well as navigation menus.

Everything was clear?

How can we improve it?

Thanks for your feedback!

Sectionย 1. Chapterย 5

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Sectionย 1. Chapterย 5
some-alt