UNIT 1-HTML5&CSS3
UNIT 1-HTML5&CSS3
HTML5 – Document Structure, Basic HTML Tags, Section elements, text, links,
tables, images, forms
CSS3( Cascading Style Sheet)- Evolution of CSS3, Syntax of CSS3, Types,
Selectors, Background, Font, Text, Borders.
INTRODUCTION TO HTML:
• HTML stands for Hyper Text Markup Language.
• HTML is a method of describing the format of web
documents
• It is used to display the document in the web browsers.
• HTML was developed by Tim Berners-Lee. HTML
standards are created by a group of interested
organizations called W3C (World Wide Web consortium).
HTML Tags:
o In HTML, formatting is specified by using tags.
o A tag is a format name surrounded by angle
brackets.
o End tags which switch a format off also contain
a forward slash.
Points to be remembered for HTML tags:
• They are not case sensitive i.e., <head>, <HEAD> and
<Head> is equivalent.
• If a browser does not understand a tag it will usually
ignore it.
• White spaces, tabs and newlines are ignored by the
browser.
STRUCTURE OF A HTML DOCUMENT:
2. Body Section
</body>
</html>
Output:
Example: Headings.html
<html>
<head>
<title>Heading Tage</title>
</head>
<body bgcolor=yellow text=blue>
<! - - This is a Comment - - >
<h1 align="left">This is Heading 1</h1>
<h2 align="center">This is Heading 2</h2>
<h3 align="right">This is Heading 3</h3>
<h4>This is Heading 4</h4>
<h5>This is Heading 5</h5>
4 Chapter 1 - HTML5 and CSS3
FULL STACK TECHNOLOGIES
7. <font>:
The <font> tag specifies the font face, font size, and color of
text.
Attribute Value Meaning
Color rgb(x,x,x) Specifies the color of text
#xxxxxx
colorname
Face font_family Specifies the font of text
Size Number Specifies size of text
8. <link>:
• The <link> tag defines a link between a document and
an external resource.
• The <link> tag is used to link to external style sheets.
9. <div>:
• The <div> tag defines a division or a section in an HTML
document.
• The <div> tag is used to group block-elements to format
them with CSS.
Attribute Value Meaning
Align Left, Specifies the
Right, alignment of a
Center heading
Justify
10. <br>:
• The <br> tag inserts a single line break.
Text
The following HTML tags are used for format the
appearance of the text on your web page.
(a). Headings – <h1> to <h6>
(b). Bold - <b> </b> or <strong> </strong>
7 Chapter 1 - HTML5 and CSS3
FULL STACK TECHNOLOGIES
Link
<a>: Anchor Tag
• The <a> tag defines a hyperlink, which is used to link
from one page to another.
• The most important attribute of the <a> element is the
href attribute, which indicates the link's destination.
• By default, links will appear as follows in all browsers:
▪ An unvisited link is underlined and blue
▪ A visited link is underlined and purple
▪ An active link is underlined and red
Attribute Value Meaning
Specifies the destination of
href URL
the link
_blank
_self
Specifies where to open the
target _parent
linked document
_top
framename
Example: Link.html
<html>
<body>
<a href="http://www.google.com" target="_self">
GOOGLE</a>
<br>
<a href="http://www.yahoo.com"
target="_blank">YAHOO</a>
<br>
<a href="Headings.html" target="_parent"> My
Page</a>
</body>
</html>
Output:
TABLES:
</tr>
<tr>
<td>r1,c1</td>
<td>r1,c2</td>
<td>r1,c3</td>
</tr>
<tr>
<td colspan="2">r2,c1</td>
<td>r2,c2</td>
<td>r2,c3</td>
</tr>
<tr>
<td>r3,c1</td>
<td>r3,c2</td>
<td colspan="2">
<table border="1" bgcolor="cyan"
cellspacing="0" bordercolor="red">
<tr>
<th colspan="2">Nested
Table</th>
</tr>
<tr>
<td>One</td>
<td>Two</td>
</tr>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Output:
IMAGE:
• The <img> tag has two required attributes: src and alt.
Attributes of <img> tag:
Name Value Meaning
src URL Specifies the URL of an image
Top,
bottom Specifies the alignment of an image
align
middle according to surrounding elements
left, right
alt text Specifies an alternate text for an image
Specifies the width of the border
border pixels
around an image
width pixels Specifies the width of an image
height pixels Specifies the height of an image
Specifies the whitespace on left and
hspace pixels
right side of an image
Example:
<html>
<body>
<br>
<img src="14.jpg" width="400" height="200" align="right">
<img src="C:\\Users\\Admin\\Desktop\\Others\\13.jpg"
width="300" height="250" border="3" alt="Alternative Text">
</body>
</html>
Output:
FORMS:
<input>:
▪ The <input> tag specifies an input field where the
user can enter data.
▪ <input> elements are used within a <form> element
to declare input controls that allow users to input
data.
▪ An input field can vary in many ways, depending on
the type attribute.
Attributes of <input > tag:
image,
month,
number
password,
radio,
reset
submit,
text
Name text Specifies the name of an
<input> element
Specifies that an <input>
element should be pre-
Checked checked selected when the page
loads (for type="checkbox"
or type="radio")
Specifies the value of an
Value Text
<input> element
<textarea>:
o The <textarea> tag defines a multi-line text input
control.
o A text area can hold an unlimited number of
characters, and the text renders in a fixed-width
font (usually Courier).
o The size of a text area can be specified by the cols
and rows attributes
Attributes of <textarea > tag:
1. ORDERED LIST:
• These are those in which the items are arranged in
some specific order.
Attributes:
Name Value Meaning
1
A
Specifies the kind of marker to
type a
use in the list
I
i
Specifies the start value of an
start number
ordered list
Specifies that the list order
reversed reversed
should be descending
</ol>
</body>
</html>
Output:
2. UNORDERED LIST:
• The Unordered lists are those in which the items are
not arranged in any order.
</ul>
<ul type="circle">
<li>Red</li>
<li>Black</li>
<li>White</li>
</ul>
<ul type="square">
<li>Red</li>
<li>Black</li>
<li>White</li>
</ul>
</body>
</html>
Output:
3. DEFINITION LIST
• These are lists of items that have 2 parts, a term to be
defined and the definition.
• This create lists similar to a dictionary.
o <dl> tag: defines a definition list. It is used
in conjunction with <dt> and <dd>
o <dt> tag: defines a term/name in a
definition list.
o <dd> tag: used to describe a term/name in
a definition list.
23 Chapter 1 - HTML5 and CSS3
FULL STACK TECHNOLOGIES
• Example:
<html>
<body>
<dl>
<dt>HTML:</dt>
<dd>Hyper Text Markup Language</dd>
<dt>CSS:</dt>
<dd>Cascading Style Sheets</dd>
</dl>
</body>
</html>
Output:
FRAMES:
• <frameset>:
▪ The <frameset> tag defines a frameset.
▪ The <frameset> element holds one or
more <frame> elements. Each <frame> element can
hold a separate document.
▪ The <frameset> element specifies how many
columns or rows there will be in the frameset, and
how much percentage/pixels of space will occupy
each of them.
Attributes of <frameset> tag:
Name Value Meaning
Pixels, % Specifies the number and size of columns
cols
* in a frameset
Pixels, % Specifies the number and size of rows in a
rows
* frameset
<frame>:
▪ The <frame> tag defines one particular window
(frame) within a <frameset>.
▪ Each <frame> in a <frameset> can have different
attributes, such as border, scrolling, the ability to
resize, etc.
Attributes of <frame> tag:
• Advantages of CSS:
1. Improves the formatting capability of a HTML page
2. Reduced Document size
3. Reduced Complexity and repetition – can reuse
the same style sheet with many different HTML
documents.
4. Saves time
5. A style sheet can import and use styles from other
style sheets.
CSS RULES:
• Syntax:
Selector { property1:value ; property2:value; }
• Example:
h1
{
font-family : arial;
color : blue;
text-align : center;
}
• Syntax:
selector.classname
{
• Syntax:
.classname
{
Property1 : valuel; property2 : value;
}
THE ‘id’ SELECTOR:
• Syntax:
#id
{
Property1 : valuel; property2 : value;
}
EXAMPLE:
<html>
<head>
<style type="text/css">
p.center
{ text-align:center; }
p.right
{ text-align:right; }
h2
{ text-align:center; color:orange; font-family:calibri; }
.cl1
29 Chapter 1 - HTML5 and CSS3
FULL STACK TECHNOLOGIES
{ color:green; }
#id1
{ color:blue; background-color:orange; }
</style>
</head>
<body>
<p class="center">This paragraph is styled by class
'center'</p>
<p class="right">This paragraph is styled by class
'right'</p>
<p class="cl1">This paragraph is styled by class
'cl1'</p>
<p id="id1">This paragraph is selected by ID
selector</p>
<h1 class="cl1">This Heading is styled by class
'cl1'</h1>
</body>
</html>
Output:
TYPES OF CSS:
<html>
<head>
<style>
body {
background-color:pink;
}
h1 {
color: maroon;
font-family: verdana;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Output:
CSS PROPERTIES:
CSS BACKGROUND PROPERTIES:
}
body
{
background-position:center top;
background-image:url('bunny giving flower.gif');
background-repeat:no-repeat;
background-attachment:fixed;
background-color:green;
}
</style>
</head>
<body>
<h1>This element is Styled</h1>
</body>
</html>
Output:
PROPERTY VALUE
NAME
color Color name
direction ltr,rtl
text-align left, right, center, justify
text- Underline, overline, Line-through,
decoration blink
text- none, uppercase, lowercase,
transform capitalize
text-indent length, %
vertical-align length, %, top, middle, bottom,
sup, super
letter-spacing normal, length(-ve)
word-spacing normal, length
Example:
TextFont.css:
p.right
{
color:red;
font-size:large;
text-transform:capitalize;
text-align:right;
font-weight:200;
letter-spacing:-3;
word-spacing:5;
}
p.center
{
color:blue;
text-align:center;
text-decoration:underline;
text-tranform:uppercase;
font-style:italic;
font-size:30;
}
.left
{
color:green;
text-indent:20;
text-decoration:overline;
text-transform:lowercase;
font-family:tahoma;
font-size:small;
font-style:italic;
}
#id1
{
color:purple;
font-weight:900;
font-family:verdana;
text-decoration:line-through;
text-align:right;
font-variant:small-caps;
font-size:20;
}
TextFont.html:
<html>
<head>
<link rel="stylesheet" type="text/css" href="TextFont.css">
</head>
<body>
<p>This Paragraph is not styled</p>
<p class="left">This paragraph is styled by class left</p>
<p class="right">This paragraph is styled by class right</p>
<p class="center">This pragraph is styled by class center</p>
<p id="id1">This paragraph is styled by id</p>
</body>
</html>
Output:
Example:
<html>
<body>
<h1 style="position:relative;left:10;top:10;z-
index:3;background-color:yellow">This is layer 1</h1>
<h1 style="position:relative;left:50;top:-20;z-
index:2;background-color:red"> This is layer 2</h1>
<h1 style="position:relative;left:100;top:-50;z-
index:1;background-color:green"> This is layer 3</h1>
<br><br><br>
<h1 style="position:relative;left:10;top:10;z-
index:2;background-color:yellow"> This is layer 1</h1>
<h1 style="position:relative;left:50;top:-20;z-
index:3;background-color:red"> This is layer 2</h1>
<h1 style="position:relative;left:100;top:-50;z-
index:1;background-color:green"> This is layer 3</h1>
<br><br><br>
<h1 style="position:relative;left:10;top:10;z-
index:1;background-color:yellow"> This is layer 1</h1>
<h1 style="position:relative;left:50;top:-20;z-
index:2;background-color:red"> This is layer 2</h1>
<h1 style="position:relative;left:100;top:-50;z-
index:3;background-color:green"> This is layer 3</h1>
</body>
</html>
Output: