CSS | attr() Function
The attr() function is an inbuilt function in CSS which returns the value of an attribute of the selected elements.
Syntax:
attr( attr_name )
Parameter: This function accepts single parameter attr_name which is used to hold the name of attribute in HTML element. It is mandatory parameter.
Return Value: This function returns the value of attribute of selected elements.
Below example illustrates the attr() function in CSS:
Program:
<!DOCTYPE html> <html> <head> <title>attr function</title> <style> a:before { content: attr(href) " =>"; } a { text-decoration:none; } .gfg { font-size:40px; color:green; font-weight:bold; } body { text-align:center; } </style> </head> <body> <div class = "gfg">GeeksforGeeks</div> <h1>The attr() Function</h1> </body> </html> |
Output:

Recommended Posts:
- jQuery | attr() Method
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- D3.js | d3.map.has() Function
- D3.js | d3.min() function
- D3.js | d3.map.set() Function
- D3.js | d3.map.get() Function
- p5.js | cos() function
- PHP | pow( ) Function
- CSS | url() Function
- PHP | Ds\Set xor() Function
- p5.js | box() Function
- p5.js | hex() function
- p5.js | hue() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

