Pseudoelement ::after w CSS
- Poprzednia strona ::after
- Następna strona ::backdrop
- Wróć do poprzedniego poziomu Podręcznik referencyjny pseudo-elementów CSS
Definition and usage
CSS ::after
Pseudo-elements are used to insert some content after the content of the specified element.
Use content
The attribute specifies the content to be inserted. The value of content can be:
- String: content: "Hello world!";
- Image: content: url(myimage.jpg);
- No content: content: none;
- Counter: content: counter(li);
- Quotation marks: content: close-quote;
- Attribute value: content: " (" attr(href) ")";
Tip:Note that the content inserted is still inside the specified element. The inserted content will be added after the other content inside the element.
Use ::before
Insert some content before the content of a specific element.
Example
Example 1
Insert a string after the content of each <p> element:
p::after { content: " - Remember this"; }
Example 2
Insert a string after the content of each <p> element and set the style of the inserted content:
p::after { content: " - Remember this"; background-color: yellow; color: red; font-weight: bold; }
CSS syntax
::after { css declarations; }
Technical details
Version: | CSS2 |
---|
Browser support
The numbers in the table indicate the first browser version that fully supports this pseudo-element.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
4.0 | 9.0 | 3.5 | 3.1 | 7.0 |
Related pages
Tutorial:CSS pseudo-element
Odniesienia:Pseudoelement ::before w CSS
- Poprzednia strona ::after
- Następna strona ::backdrop
- Wróć do poprzedniego poziomu Podręcznik referencyjny pseudo-elementów CSS