PHP前端开发

使用 CSS 返回所选元素的属性值

百变鹏仔 4周前 (09-19) #CSS
文章标签 所选

attr() CSS函数使用CSS返回所选元素的属性值

示例

您可以尝试运行以下代码来实现CSS 中的 attr() 函数

实时演示

<!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>