CSS after selector

Last update: 2023-01-01
Type
Quick Win's logo Quick Win
Membership
πŸ†“
Tech
CSS CSS
CSS
Share:

In CSS, the after selector is used to add content after an element. This content can be text, images, or other HTML elements. The after selector is often used to add visual elements, such as arrows or icons, to a page.

To use the CSS after selector, follow these steps:

  1. Open your HTML and CSS files in a text editor.

  2. In your CSS file, add the after selector for the element you want to add content after. For example, to add content after all p elements, you would use the following syntax:

p:after {
	/* styles go here */
}
  1. Use the content property to specify the text or HTML that should be inserted after the element. For example, to add an arrow symbol after each p element, you would use the following syntax:
p:after {
	content: 'β†’';
}

If you want to insert an image after the element, you can use the content property and set it to the url of the image. For example:

p:after {
	content: url(arrow.png);
}

Save your CSS file and refresh your HTML page to see the changes.

It’s important to note that the after selector only works on elements that can contain content, such as p, div, or article. It cannot be used on empty elements, such as br or hr.

Simon Grimm

Β© 2023 Galaxies.dev. All rights reserved.