Lesson 12 Css
Lesson 12 Css
Div, Span
and Link
LESSON 12
Objectives
• Identify the kinds of elements in CSS
• Understand class, id and multiple selectors
and grouping selectors
• Use display property, div tag, span tag, class,
id selector, pseudo-classes and links
DISPLAY PROPERTY
• CSS display property allows you to
control how an element is diplayed.
• Block level element is laid out vertically.
The new paragraph starts with a new line
after the end of another paragraph.
• Inline level element is laid out horizontally
and will only proceed to the next line when
the end of the line is reached.
TYPES OF ELEMENTS IN CSS
Inline level
Laid out horizontally <em> element <b> element
elements
<html>
<head>
<title>Jemma Inc</title>
<style type="text/css">
<!--
p.blue { color : blue}
h1#red { color: red ; }
-->
</style>
</head>
<body>
<h1 id="red"> Visual Guide Series </h1>
<p class="blue">Creative Design CS5</p>
<p class="blue">Web Design</p>
<p>Animation and Multimedia</p>
</body>
</html>
PROPERTY FOR DISPLAY
PROPERT KEYWORD DESCRIPTION
Y
display: inli Inline display or horizontal
ne lay out
display: bloc Block display or vertical
k lay out
display: list- Display as a list item
item <li>
No box or the element has
display: no
no effect on the layout
ne
display: inher inherit value from
<html
<head>
<title>Jemma Inc</title>
<style type="text/css">
<!--
p.blue { color : blue;}
h1#red { color: red ; }
Inline display p { display: inline; }
-->
</style>
</head>
<body>
<h1 id="red"> Visual Guide Series </h1>
Paragraphs will <p class="blue">Creative Design CS5</p>
aligned <p class="blue">Web Design</p>
<p>Animation and Multimedia</p>
vertically
</body>
</html>
Div Tag
• Div divides the contents of a web page
into individual sections. It also allows you
to apply styles to different sections of
• your
It is apages.
generic way adding structure in
HTML Document.
• Div tag is a block level and will provide
line spacing and after a block element.
Atttributes for <Span></span>and
<div></div>
Attributes Definition Values
Indicates the CSS style to be
Class applied CSS class
name
ex: <div class="style1"></div>
<html
<head>
<title>Jemma Inc</title>
<style type="text/css">
<!--
p.blue { color : blue;}
h1#red { color: red ; }
. background {
Div class background-color : #cccccc;
font-weight : bold;
}
-->
</style>
</head>
<body>
<h1 id="red"> Visual Guide Series </h1>
Div class
<div class="background">
<p class="blue">Creative Design CS5</p>
<p class="blue">Web Design</p>
</div>
<p>Animation and Multimedia</p>
</body>
</html>
Span Tag
• Span tag is a generic way of adding
structure to an HTML document.
• It is also applied to an inline element
and used to emphasize words or
sentences within a paragraph.
<html>
<head>
<title>Jemma Inc</title>
<style type="text/css">
<!--
p.blue { color : blue; }
h1#red { color: red ; }
. backgnd {
background-color : #ccc;
font-weight: bold;
}
Span . txtcol { color: blue ;}
-->
class </style>
</head>
<body>
<h1 id="red"> Visual Guide Series </h1>
<div class="backgnd">
<p class="blue">Creative Design CS5</p>
<p class="blue">Web Design</p>
</div>
Span class <p>Animation <span class="txtcol">and</span>
Multimedia</p>
</body>
</html>
Span Tag and
Div
• Span and Div tags do not styling
information.
• Span and Div usually used to
format a part of the content by
using CSS.
• The general difference between
the Span and Div;
• Div is has a line breaks before
and after it.
• Span is used for small chunk of
code while Div is for larger ones.
<html
<head>
<title>Jemma Inc</title>
<link rel="stylesheet"
href="jemmainc.css" link.css>
</head>
Div <body>
<div class="Style1">
Class <p><font size="4"> Creative Design CS5 contains Adobe Photoshop,
Illustrator, InDesign and Acrobat. The book aims to educate the
students in creating, designing and editing graphics using the different
software that may work relatively.
<span class="style2"> Creative </span> Design
Span <span class="style2"> CS5</span> targets both knowledge and
class application toward specific output that would basically develop skills
towards a career. </font></p>
</div>
</body>
</html>
.style1 {
boarder: dotted blue;
font-family: Verdana;
font-size: 14px;
width: 400px;
}
.style2 {
font-family: Courier New;
font-size: 14px;
font-weight: bold;
color: red;
What are classes
• Class is a user-defined selector. You can create a
class to apply a style rule to specific HTML tags.
• Classes are defined dot (.).
• Two methods of writing class: First, by
indicating the HTML element to followed
by a dot and followed by the class name.
Second, by writing the class name
p. blueFont {
color: blue }
.redFont {
color: red
}
<html>
<head>
<title>Jemma Inc</title>
<style type="text/css">
<!--
p.blue { color: blue; }
-->
</style>
</head>
<body>
<h1> Visual Guide Series </h1>
<p class="blue">Creative Design CS5</p>
<p class="blue">Web Design</p>
<p>Animation and Multimedia</p>
</body>
</html>
ID Selector
• Id selector is applied to one element in a
page. It is normally used once, usually in
a page title or the navigation part of the
page.
• ID selector defined "#" and uses the id
attributed of the HTML element.
<html>
<head>
<title>Jemma Inc</title>
<style type="text/css">
<!--
p.blue { color : blue; }
h1#red { color: red ; }
-->
</style>
</head>
<body>
<h1 id="red"> Visual Guide Series </h1>
<p class="blue">Creative Design CS5</p>
<p class="blue">Web Design </p>
<p class="blue">Animation and Multimedia</p>
<p>Visual Basic and Access</p>
<p>Spreadsheets and Database</p>
<p>Office Productivity MS Office 2010</p>
</body>
</htm>
Multiple Selectors
• When two or more selectors
have the same properties and
values, a comma is used to
separate the selectors and use
only one set of properties and
values.
<html>
<head>
<title>Jemma Inc</title>
<link rel="stylesheet">
href="jemmainc.css" type="text/css">
</head>
<body>
<h1> Visual Guide Series </h1>
<p>Creative Design CS5</p>
<p>Web Design </p>
<p>Animation and Multimedia</p>
<p>Visual Basic and Access</p>
</body>
</html>
p, h1 {
font-family: Arial;
color: green;
}
Grouping Selectors
• You can group selectors and
combines it in one CSS file.
• Each selector should be
separated with a comma.
h1 { color: blue;
}
p { color: blue;
}
p { background-color:
black;
}
h1, p { color: blue;
}
p { background-color:
black;
}
Nesting Selectors
max-height max-height: 12 px
indicates the maximum height
min-height indicates the minimum min-height :12
height px