CSS Properties: How to set the content as one of the selector's attribute?
Solution:
HTML Code:
Explanation:
- This HTML document demonstrates how to use the attr() CSS function to insert the value of an attribute as content.
- The CSS rule a:before selects the pseudo-element ::before of all <a> elements.
- The content: attr(href); property inserts the value of the 'href' attribute of the <a> element before the content of the <a> element.
- In this example, the hyperlink text "(w3resource Tutorial)" is preceded by the URL specified in the href attribute of the <a> element.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics