Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a[href^="..."] do in CSS?

I have used CSS before and I came across the below CSS style, don't have a clue what it does.

a[href^="http:"] {    background: url(img/keys.gif) no-repeat right top; } a[href^="http://mysite.com"], a[href^="http://www.mysite.com"] {    background-image: none; padding-right:0; } 
like image 707
user443946 Avatar asked Oct 04 '10 21:10

user443946


People also ask

What does a href link do?

The href attribute link (short for “Hypertext REFerence”) indicates the relationship between pages to search engines. href is an attribute of the anchor tag and contains two components: The URL (the actual link) and. The clickable text or object that users will see on the page (known as the “anchor text”)

Can you put href in CSS?

You cannot simply add a link using CSS. CSS is used for styling. You can style your using CSS.


1 Answers

a[href^="http:"]  

Selects an <a> element whose href attribute value begins with http:.

For example:

p[title^="para"] {background: green;} 

Will match the following:

<p title="paragraph"> This paragraph should have a green background. </p>  
like image 96
Russell Dias Avatar answered Sep 28 '22 18:09

Russell Dias