B7. Introduction To CSS3
B7. Introduction To CSS3
Introduction to CSS3
Iden,fy
the
new
func,ons
of
CSS3
Explain
the
different
types
of
selectors
Explain
nested
tags
Define
Classes
and
IDs
for
applying
styles
Explain
the
process
to
apply
styles
to
hyperlink
Updates each level of CSS from the earlier version, by adding new features.
Denotes version as CSS1, CSS2, CSS3, and CSS4, where the numbers are different for
each version or level.
Is divided into multiple documents called “modules” and each of these modules have
new capabilities or extends the features present in CSS2.
Started drafting of CSS3 when publication of the original CSS2 recommendation was
released.
Selectors Level 3
Modules
that
are
stable
and
in
recommenda,on
stage
are
as
follows:
Media Queries
Modules that are in refining phase and in working draN stage are as follows:
CSS Transforms
CSS Transitions
Some of the following modules are in exploring phase and in working draN stage:
CSS Ruby
Modules that are in abandoned phase and in working draN stage are as follows:
Selector is an HTML element for which you want to specify the style or the formatting
instruction.
Property of a selected element is a CSS property that specifies the type of the style to be
applied to the selector.
Value refers to the value of the CSS property and a CSS property can have multiple
values.
Property and the value for a selector are separated with a colon (:).
They are enclosed within the curly brackets ({}) that is known as the declaration block.
You can specify multiple property-value pairs for a selector, which are separated by a
semicolon (;) within the declaration block.
You can specify multiple selectors for a single property by grouping the selectors. To
group the selectors, the selectors are separated by commas followed by a declaration
block of properties and values.
You can specify properties for multiple selectors. Here, the comma-separated selectors
are followed with multiple property-value pairs.
These units measure the horizontal and vertical length of the content.
CSS supports two types of length measurement units namely, relative and absolute.
An inline style sheet uses the style attribute within an HTML element to specify the style
for HTML elements.
An internal style sheet is also included within the HTML document and is defined using
the style element.
<head>
<meta charset=“utf-8”>
<title>Sample HTML5 Structure</title>
<style>
h1, h2 {
margin:0px;
font-size:1.5em;
}
footer{
background-color:#999;
text-align:center;
}
</style>
</head>
BODY {
background-color: gray;
font-family: arial;
font-style: italic;
}
<!DOCTYPE html>
<html>
<head>
<LINK rel=“stylesheet” type=“text/css” href=“body.css”/>
<title>Webex e-Server</title>
</head>
<body>
This is the fastest web server..!!
</body>
</html>
Universal selector
Class selector
Results in application of
the specified styles to all
the occurrence of that
element in a Web page
Sort the declarations by the source and type of style sheet. The source specifies the origin
from where the styles are rendered.
Highest priority is given to the external style sheet defined by an author. The next
priority is of the reader, which can be a software that reads the content, and the last
priority is of the browser.
Sort the declarations by the priority of a selector, where the ID selector has the highest
priority.
Sometimes unknowingly the same Web page get open that you have already visited.
Description
State feel the need for a mechanism that could differentiate the already visited links
You might
from the remaining ones.
active Defines a different style to an element that is activated by the user.
This
hover is possible by using
Defines pseudo
a different classes.
style to an element when the mouse pointer is moved over it.
:first-letter Is used for selecting the first letter of every <p> element
:first-line Is used for selecting the first line of every <p> element
:first-child Is used for selecting every <p> elements that is the first child of its parent
a:link {
color: white; Specifies the styles for an
unvisited link
background-color: black;
border: 2px solid white;
}
a:visited {
color: white; Specifies the styles for a
visited link
background-color: brown;
border: 2px solid white;
}
a:hover {
color: black; Specifies the styles when
a mouse hovers over it
background-color: white;
border: 2px solid black;
©
Aptech
Ltd.
}
Introduc,on
to
CSS3
/
Session
5
30
Consider
a
scenario
where
you
are
designing
a
Web
site
that
explains
the
important
technical
terms.
While
defining
such
terms,
you
might
feel
the
need
to
emphasize
more
on
the
first
le]er
by
applying
different
styles.
Pseudo
elements
provide
you
with
a
flexibility
to
apply
styles
to
a
specific
part
of
the
content
such
as
a
first
le]er
or
first
line.
Pseudo
element
adds
some
special
effects
to
HTML
elements
such
as
<p>,
<body>,
and
so
on.
Syntax
for
declaring
psuedo
elements
is:
The :first-line pseudo element allows you to apply styles to the first line.
The
Code
Snippet
declares
the
style
that
will
be
applied
to
the
first
line
in
the
paragraph.
p:first-line
Specifies the styles to be
{ applied to the first line of
font-family: “Tahoma”; the paragraph content
font-weight: bolder;
background-color: #FFFFCC;
}
The
Code
Snippet
declares
the
style
that
will
be
applied
to
the
first
le]er
in
the
paragraph.
p:first-letter
{ Specifies the styles to be
font-family: “fantasy”; applied to the first letter
of the paragraph content
font-size: xx-large;
font-weight: bold;
}
There are two other ways to assign hyperlink styles namely, div specific and Link
specific.
A div specific hyperlink styles can be created and assigned to a specific div and will have
all the hyperlinks present within the div to follow the specified rules.
Class specific hyperlink styles generally uses a class than an id. A point to note that an id
can only be used once on a page whereas a class can be used multiple times as required.
A hyperlink style can be assigned either through DIV or through link class.