CSS3 > Selectors

[attribute=value] selector in CSS3

How to select elements with the specified attribute and value in CSS3?

By using [attribute=value] selector we can select the elements with the specified attribute and value.


        a[target=_self] {
            background-color: lightgreen;

    <p>Hyperlink without attribute :<a href="http://www.techfunda.com" title="www.TechFunda.com">TechFunda</a></p>
    <p>Hyperlink with attribute target=_blank:<a href="http://www.dotnetfunda.com" target="_blank">DotNetFunda</a></p>
    <p>Hyperlink with attribute target=_self:<a href="http://www.itfunda.com" target="_self">ITFunda</a></p>

In the above code snippet we have given style to the [attribute=value] selector. So that the selector selcts the attribute with the specified value and applies the style to it.


 Views: 459 | Post Order: 37

Write for us