^^CSS selectors.

CSS rule
selector {
    property:value;
}
CSS selector
selector is a pattern used to select the elements to style.
Selector Description  

 

Simple selectors

 
p tag name selector
#carbon id selector
.chimica class selector
span.chimica to specify which HTML elements select  
h1, h2, p To group selectors, separate each selector with a comma.  
 

Combinator selectors

 
div p

elm elm

descendant selector  (space) selects

all elements that are descendants of a specified element.

es: all p elements inside a div element

 
div > p

elm > elm

child selector  (>)selects

all elements that are the children of a specified element

es: all p elements children of a div element

 
div + p

elm + elm

immediately after selector (+) selects

all elements that are immediately after of a specified element.

es: all p elements immediately after a div element

 
div ~ p

elm ~ elm

siblings_after selector (~) selects

all sibling elements after of a specified element.

es: all siblings p elements after a div element

 

w3/Level 3 Selectors specification

w3schools/css_selectors

MDN Mozilla Developers Network

Selectors, in particolare Types of selectors.

Piu' in generale, il modulo cui appartiene questo capitolo >>>

 

element.className.

 

# (hash character) select id

to select an element with a specific id, write a hash (#) character, followed by the id of the element.

 

<style>
#myHeader {
background-color: lightblue;
color: black;
}
</style>

 

<h1 id="myHeader">My Header</h1>

 

CSS element+element Selector

Syntax

element + element {
  css declarations;
}

select the element after (not inside) the first specified element.

Es Hover over a <span> element to show a <div> element (like a tooltip)

span:hover + div {
display: block;
}