Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS attr() Function

CSS attr() Function

CSS Functions CSS Functions

Example

The following example inserts content after each link:

a

:after

{

content:

" ("

attr

(

href

) ")"

;

}

Try it »


Definition and usage

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

Supported version: CSS2


Browser support

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

function
attr() 2.0 8.0 1.0 3.1 9.0

Note: IE8 requires a !DOCTYPE declaration to support the attr() function.


CSS Syntax



attr(attribute-name)

Value Description
attribute-name Required. The attribute name of the HTML element.

CSS Functions CSS Functions