HTML CSS examples for CSS:Function
The attr() function returns the value of an attribute of the selected elements.
Value | Require | Description |
---|---|---|
attribute-name | Required. | The name of the attribute of the HTML element(s) |
The following example inserts the value of the href attribute in parenthesis after each link:
<!DOCTYPE html> <html> <head> <style> a:after {content: " (" attr(href) ")";} </style><!--from w w w .jav a 2 s. c o m--> </head> <body> <p><a href="http://java2s.com">Visit http://java2s.com</a></p> <p><a href="http://java2s.com"> HTML tutorial</a></p> </body> </html>