Return Attribute Value of Selected Element Using CSS



The attr() CSS function returns the value of an attribute of the selected element using CSS

Example

You can try to run the following code to implement the attr() function in CSS

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         a:before {content: " (" attr(href) ")";}
      </style>
   </head>
   <body>
      <h2>Information Resource</h2>
      <p>
         Resource:<a href="https://www.qries.com">Welcome to Qries </a>
      </p>
   </body>
</html>
Updated on: 2020-07-04T07:03:06+05:30

254 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements