Cascading Style Sheets fondly referred to as CSS, is a simply designed language intended to simplify the process of making web pages presentable. CSS allows you to apply styles to web pages.
A CSS style rule consists of a selector, property, and its value. The selector points to the HTML element where CSS style is to be applied. The CSS property is separated by semicolons.
selector {
Property: value;
}
CSS selectors are used to target HTML elements to apply styles. There are several types:
p
, h1
, div
)..my-class
).#my-id
). IDs should be unique within a document.[type="text"]
, [data-attribute~="value"]
).:hover
, :active
, :focus
).::before
, ::after
, ::first-letter
).div p
, child selector div > p
, adjacent sibling selector h2 + p
, general sibling selector h2 ~ p
).