Introduction To CSS and CSS Selectors
Introduction To CSS and CSS Selectors
STYLE
SHEETS
Introduction to CSS
WHAT IS
CSS?
• CSS stands for Cascading Style Sheets. It is
a style sheet language which is used to
describe the look and formatting of a
document written in markup language.
CSS Syntax
A CSS rule set contains
a selector and a
declaration block.
Selector: Selector indicates the
HTML element you want to style.
It could be any tag like <h1>,
<title> etc.
Declaration
The Block:
declaration block can contain one or
more declarations separated by a
semicolon. For the above example, there
are two declarations:
• color: yellow;
CSS SYNTAX • font-size: 11 px;
Value
CSS SYNTAX : are assigned to CSS properties. In
Values
the given example, value "yellow" is
assigned to color property.
CSS
Element
Selector
2) CSS Id Selector
The id selector selects the id attribute of an HTML element to select a
specific element. It is used with a # hashtag character. An id is
always unique within the page so it is chosen to select a single,
unique element.
#para1 {
Example
Result:
CSS
ID Selector
3) CSS Class Selector
The class selector selects HTML elements with a specific class
attribute. It is used with a period character . (full stop symbol)
followed by the class name.
3) CSS Class Selector
The class selector selects HTML elements with a specific class
attribute. It is used with a period character . (full stop symbol)
followed by the class name.
.center {
Example
Result:
CSS
ID Selector
4) CSS Universal
Selector
The * selector selects all elements.
The * selector can also select all elements
inside another element
4) CSS Universal
Selector
5) CSS Group Selector
The grouping selector is used to select all the elements with the
same style definitions.