The difference between pseudo-classes and pseudo-elements in CSS

PHPz
Release: 2023-08-27 09:33:02
forward
897 people have browsed it

Pseudo-class

Pseudo-class represents the status of the selector, such as:hover, :active, :last-child, etc. They begin with a colon (:).

The syntax of CSS pseudo-class is as follows -

:pseudo-class{ attribute: /*value*/ }
Copy after login

Pseudo-element

Similarly, pseudo-element is used to select virtual elements, such as::after, ::before, ::first -line etc.

These start with a double colon (::).

The syntax of CSS pseudo-elements is as follows -

::pseudo-element{ attribute: /*value*/ }
Copy after login

Examples

The following examples illustrate CSS pseudo-classes and pseudo-element properties.

Live Demonstration

    

You're somebody else

Dummy link 1 Dummy link 2
Copy after login

Output

This will produce the following results-

The difference between pseudo-classes and pseudo-elements in CSS

Example

Live Demo

    

Anymore Snare?

Donec in semper diam. Morbi sollicitudin sed eros nec elementum. Praesent eget nisl vitaeneque consectetur tincidunt. Ut molestie vulputate sem, nec convallis odio molestie nec.

Hit

Pop

Copy after login

Output

This will produce the following results -

The difference between pseudo-classes and pseudo-elements in CSS

The above is the detailed content of The difference between pseudo-classes and pseudo-elements in CSS. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!