41
loading...
This website collects cookies to deliver better user experience
:hover
pseudo-class./*When the link is hovered with a mouse pointer this code is fired*/
a:hover {
color: blue;
text-decoration: underline;
}
Pseudo-classes let you apply CSS based on state changes. This means that your design can react to user input and changes accordingly.
:invalid
, this is one of many browser-provided pseudo-class:hover
class to apply different style when user hovers on it.<p> This is link <a href="#"> Try hovering me! </a> </p>
/*This line is to remove the default behavior of anchor tag we want underline effect one hover */
a{
text-decoration: none;
}
/*When the user hover on a tag this code will be fired*/
a:hover{
text-decoration: underline;
color: #8e44ad;
}
<div>
<button class="btn">Click and hold to see the active state</button>
</div>
.btn:active {
transform: scale(0.99);
box-shadow: none;
}
A pseudo-element is like adding or targeting an extra element without having to add more HTML.
::first-letter
pseudo-element to achieve this sort of design detail.p::first-letter {
color: blue;
float: left;
font-size: 2.6em;
font-weight: bold;
line-height: 1;
}
::before
and ::after
pseudo-elements create a child element inside an element only if you define a content property..my-element::before {
content: "";
}
.my-element::after{
content: "";
}
::before
pseudo-element to insert content at the start of an element, or the ::after
pseudo-element to insert content at the end of an element.url
, which will insert an image at its original dimensions, so we won't be able to resize it.