The attr() CSS expression is used to retrieve the value of an attribute of the selected element and use it in the style sheet. It can be used on pseudo-elements too and, in this case, the value of the attribute on the pseudo-element’s originated element is returned.
Example :

        <title>CSS Tutorials</title>
            p:before {
                content: attr( data-foo) " ";
        <p data-foo="hello">

Output :

hello world