CSS - Attribute Selector Value


CSS - Attribute Selector

  • The [attribute] selector is used to select elements with a specific attribute values.
  • It represents an element with an attribute name of attribute.

Example :

a[target] 
{
text-decoration: none;
}

Sample code:

<!DOCTYPE html>          
<html>
<head>
    <style>

        a[target] 
        {
            text-decoration: none;
        }
    </style>
</head>
<body>
    <a
href="http://www.wikitechy.com" target="_target”>
        Click wikitechy
    </a>
</body>
</html>

Code Explanation :


    a[target] selector directs the user from one web page to another web page.

    Text-decoration property removes the underlined line from the link text (Click wikitechy) by displaying them as a normal text. 

Note :In general, almost all the links appear in blue color with underlined.

    The anchor <a> tag defines a hyperlink which directs the user from one page to another. target=”_blank” opens the linked website in a new window. Here we defined to open http://www.wikitechy.com website.

Output:


    Click wikitechy is a link which appears without underline. Clicking on the link directs us to the wikitechy website as displayed in the following browser window.