CSS Purpose
mainly to prescribe how the various HTML elements in a set of HTML documents should render, on the screen, on paper, or in other media.
Three different ways in that CSS can be used in HTML documents:
When multiple CSS styles are defined for the same element,
the value from the last read style sheet will be used.
Styles application priority:
CSS rule-set components:
- declaration block(s)
The declaration block contains one or more declarations separated by semicolons.
Each declaration includes a CSS property name and a
value separated by a colon.
The declaration block contains one or more declarations separated by semicolons.
Each declaration includes a CSS property name and a
value separated by a colon.
CSS selectors are used to find elements in the HTML document based on
element name, ID, class, attribute, or other specifiers.
CSS Selector: Elements div with an attribute class=”even”
div.even
CSS Selector: An element with id=”login”
login
CSS Selector: All elements
*
CSS Selector: All input elements
input
CSS Selector: All p and all div elements
p,div
CSS Selector: All input elements (descendents) inside all div elements
div input
CSS Selector: All input elements that have the div element as the (direct) parent
div > input
CSS Selector: Selects all p elements that are placed immediately after element br
br + p
CSS Selector: Selects all p elements that are placed immediately before element br
p ~ br
XPATH: Elements div with an attribute class=”even”
//div[@class=”even”]
XPATH: An element with id=”login”
//*[@id=”login”]
XPATH: All elements
//*
XPATH: All input elements
//input
XPATH: All input elements inside all div elements
//div//input
XPATH: All input elements that have the div element as the parent
//div/input
CSS Selector: All elements with the lang attribute
[lang]