CSS attr() Function

❮ CSS Functions Reference

Example

The following example inserts the value of the href attribute in parenthesis after each link:

a:after {
  content: " (" attr(href) ")";
}
Try it Yourself »

Definition and Usage

The attr() function returns the value of an attribute of the selected elements.

Version: CSS2

Browser Support

The numbers in the table specify the first browser version that fully supports the function.

Function
attr() 2.0 8.0 1.0 3.1 9.0

CSS Syntax

attr(attribute-name)
Value Description
attribute-name Required. The name of the attribute of the HTML element(s)

❮ CSS Functions Reference

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.