Interactivity
This lesson discusses the interactivity properties in CSS and how they affect the behavior of elements on a web page.
Hover
The hover
property is used to change the style of an element when the
mouse hovers over it. The hover property can be used to change the color,
background color, or other styles of the element.
<button>Hover Over Me</button>
The code above shows an example of the hover
property. In this example,
the background color of the <button>
element is changed to lightcoral
when the mouse hovers over it.
Focus
The focus
property is used to change the style of an element when it
receives focus. The focus property can be used to change the color, background
color, or other styles of the element.
<input type="text" placeholder="Enter your name" />
The code above shows an example of the focus
property. In this example,
the background color of the <input>
element is changed to lightcoral
when
it receives focus.
Active
The active
property is used to change the style of an element when it
is activated. The active property can be used to change the color, background
color, or other styles of the element.
<button>Click Me</button>
The code above shows an example of the active
property. In this example,
the background color of the <button>
element is changed to lightcoral
when it is activated.