Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is caret symbol ^ used for in css when selecting elements?

I encountered a css selector in a file like this:

#contactDetails ul li a, a[href^=tel] {....} 
like image 854
Yannis Dran Avatar asked Jan 02 '13 23:01

Yannis Dran


People also ask

How do you select an element in CSS?

The CSS class Selector The class selector selects HTML elements with a specific class attribute. To select elements with a specific class, write a period (.) character, followed by the class name.

What is the carrot in CSS?

href carrot CSS selector is used to target “a” tag having href value and starting with the keyword. In this case, This will change color of all “a” tag having external link.

How do I make a caret in CSS?

C^ret is an online tool that helps you create a caret (or an arrow symbol) in pure CSS. The caret can be pointing in any direction, the border width, the color can be changed and the code is generated as you move the slider.

Why do we use symbol in CSS?

The symbols CSS descriptor is used to specify the symbols that the specified counter system will use to construct counter representations.


1 Answers

The circumflex character “^” as such has no defined meaning in CSS. The two-character operator “^=” can be used in attribute selectors. Generally, [attr^=val] refers to those elements that have the attribute attr with a value that starts with val.

Thus, a[href^=tel] refers to such a elements that have the attribute href with a value that starts with tel. It is probably meant to distinguish telephone number links from other links; it’s not quite adequate for that, since the selector also matches e.g. <a href="tel.html">...</a> but it is probably meant to match only links with tel: as the protocol part. So a[href^="tel:"] would be safer.

like image 69
Jukka K. Korpela Avatar answered Sep 23 '22 12:09

Jukka K. Korpela