Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does symbol tilde (~) mean in CSS [duplicate]

Tags:

css

tilde

I want to know what does (~) mean in css.

#img1:hover ~ #img2 {     opacity: 0; } 

In visual studio, i get 'unexpected character sequence' error when i use this symbol. what is the actual meaning of this in CSS. what does it do?

like image 391
Monie corleone Avatar asked Mar 18 '13 07:03

Monie corleone


People also ask

What does the Tilda Wave (~) symbol means?

The English language does not use the tilde as a diacritic, though it is used in some loanwords. The standalone form of the symbol is used more widely. Informally, it means "approximately", "about", or "around", such as "~30 minutes before", meaning "approximately 30 minutes before".

What does tilde mean in less?

The symbol of tilde of ~ in less style file, it is a escaping symbol. Escaping allows you to use any arbitrary string as property or variable value. Anything inside ~"anything" or ~'anything' is used as is with no changes except interpolation.

What does greater than symbol mean in CSS?

The greater than sign (>) selector in CSS is used to select the element with a specific parent. It is called as element > element selector. It is also known as the child combinator selector which means that it selects only those elements which are direct children of a parent.

How do I select a previous sibling in CSS?

No, there is no "previous sibling" selector. On a related note, ~ is for general successor sibling (meaning the element comes after this one, but not necessarily immediately after) and is a CSS3 selector. + is for next sibling and is CSS2. 1.


1 Answers

http://www.w3.org/TR/selectors/

8.3.2. General sibling combinator

The general sibling combinator is made of the "tilde" (U+007E, ~) character that separates two sequences of simple selectors. The elements represented by the two sequences share the same parent in the document tree and the element represented by the first sequence precedes (not necessarily immediately) the element represented by the second one.

example

h1 ~ pre 

matches that <pre> here:

<h1>Definition of the function a</h1> <p>Function a(x) has to be applied to all figures in the table.</p> <pre>function a(x) = 12x/13.5</pre> 

There is also + selector, for adjacent sibling combinator: with h1 + pre the <pre> tag would have to be right after <h1>

like image 106
MarcinJuraszek Avatar answered Sep 22 '22 08:09

MarcinJuraszek