Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Creating Effects with Decorative Pseudo-Elements | Adding Decorative Effects with CSS
CSS Fundamentals

bookCreating Effects with Decorative Pseudo-Elements

Pseudo-elements ::before and ::after are special selectors that allow us to insert content before or after an element's content. We use them to add decorative elements, such as icons or borders, to an element's content without modifying the actual HTML content.

selector::before {
  /* some properties */
}

selector::after {
  /* some properties */
}
  • ::before adds the content before the element content;
  • ::after adds the content after the element content.

Let's consider the following example, where our task is to add some decoration for the hover effect on the links:

index.html

index.html

index.css

index.css

copy

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 5. Kapitel 4

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Awesome!

Completion rate improved to 2.5

bookCreating Effects with Decorative Pseudo-Elements

Svep för att visa menyn

Pseudo-elements ::before and ::after are special selectors that allow us to insert content before or after an element's content. We use them to add decorative elements, such as icons or borders, to an element's content without modifying the actual HTML content.

selector::before {
  /* some properties */
}

selector::after {
  /* some properties */
}
  • ::before adds the content before the element content;
  • ::after adds the content after the element content.

Let's consider the following example, where our task is to add some decoration for the hover effect on the links:

index.html

index.html

index.css

index.css

copy

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 5. Kapitel 4
some-alt