HTML Tutorial
HTML Tutorial
Definitions
2
RAHUL SAXENA
<HTML>
<HEAD>
<TITLE> Demo </TITLE>
</HEAD>
<BODY>
<H1> Hello World </H1>
<!-- Rest of page goes here. This is a comment. -->
</BODY>
</HTML>
RAHUL SAXENA
EXAMPLE1
BODY Element
4
<BODY attributename="attributevalue">
Deprecated attributes (but still used)
BACKGROUND=Sunset.jpg
BGCOLOR=color
TEXT=color
LINK=color (unvisited links)
VLINK=color (visited links)
ALINK=color (when selected)
RAHUL SAXENA
Headings
5
<H1
<H2
<H3
<H4
<H5
<H6
...>
...>
...>
...>
...>
...>
text
text
text
text
text
text
RAHUL SAXENA
Headings
6
<HTML>
<HEAD>
<TITLE>Document Headings</TITLE>
</HEAD>
<BODY>
Samples of the six heading types:
<H1>Level-1 (H1)</H1>
<H2 ALIGN="center">Level-2 (H2)</H2>
<H3><U>Level-3 (H3)</U></H3>
<H4 ALIGN="right">Level-4 (H4)</H4>
<H5>Level-5 (H5)</H5>
<H6>Level-6 (H6)</H6>
</BODY>
</HTML>
RAHUL SAXENA
Example 1.
<P> Paragraph
7
RAHUL SAXENA
<P> Paragraph
8
<BODY>
<P>Here is some text </P>
<P ALIGN="center"> Centered text </P>
<P><P><P>
<P ALIGN="right"> Right-justified text
<! Note: no closing /P tag is not a problem>
</BODY>
RAHUL SAXENA
<PRE>
if (a < b) {
a++;
b = c * d;
}
else {
a--;
b = (b-1)/2;
}
</PRE>
RAHUL SAXENA
Example 3
Special Characters
10
RAHUL SAXENA
Character
Use
<
<
>
>
&
&
"
"
Space
Colors
11
RAHUL SAXENA
Fonts
12
RAHUL SAXENA
<OL TYPE="1">
<LI> Item one </LI>
<LI> Item two </LI>
<OL TYPE="I" >
<LI> Sublist item one </LI>
<LI> Sublist item two </LI>
<OL TYPE="i">
<LI> Sub-sublist item one </LI>
<LI> Sub-sublist item two </LI>
</OL>
</OL>
</OL>
RAHUL SAXENA
<UL TYPE="disc">
<LI> One </LI>
<LI> Two </LI>
<UL TYPE="circle">
<LI> Three </LI>
<LI> Four </LI>
<UL TYPE="square">
<LI> Five </LI>
<LI> Six </LI>
</UL>
</UL>
</UL>
RAHUL SAXENA
Naming a Section
18
RAHUL SAXENA
Images
19
SRC is required
WIDTH, HEIGHT may be in units of pixels or
percentage of page or frame
WIDTH="357"
HEIGHT="50%"
RAHUL SAXENA
Images
20
Align=position
Image/Text Placement
Left
Right
Top
Bottom
Middle
RAHUL SAXENA
Images
21
<BODY>
<img src=12.jpg" align="left" width="150" height="150" alt="dolphin
jump!">
This is a very cute dolphin on the left!<br>
This is a very cute dolphin on the left!<br>
This is a very cute dolphin on the left!<br>
This is a very cute dolphin on the left!<br>
This is a very cute dolphin on the left!<br>
This is a very cute dolphin on the left!<br>
This is a very cute dolphin on the left!<br>
This is a very cute dolphin on the left!<br>
This is a very cute dolphin on the left!<br>
This is a very cute dolphin on the left!<br>
You can see text wrap around it<br>
</BODY>
</HTML>
RAHUL SAXENA
Tables
22
<TABLE>
<CAPTION>
<TR>
<TH>
<TD>
RAHUL SAXENA
table tag
optional table title
table row
table column header
table data element
Tables
23
<TABLE BORDER=1>
<CAPTION>Table Caption</CAPTION>
<TR><TH>Heading1</TH>
<TH>Heading2</TH></TR>
<TR><TD>Row1 Col1 Data</TD><TD>Row1 Col2 Data</TD></TR>
<TR><TD>Row2 Col1 Data</TD><TD>Row2 Col2 Data</TD></TR>
<TR><TD>Row3 Col1 Data</TD><TD>Row3 Col2 Data</TD></TR>
</TABLE>
RAHUL SAXENA
RAHUL SAXENA
cellspacing=10
cellpadding=10
RAHUL SAXENA
RAHUL SAXENA
RAHUL SAXENA
Frames
29
RAHUL SAXENA
Frames
30
RAHUL SAXENA
Frames
31
<FRAMESET ROWS="75%,25%">
<FRAMESET COLS="*,*,*">
<FRAME SRC="http://www.jnujaipur.ac.in">
<FRAME SRC="http://www.w3schools.com">
<FRAME SRC="http://www.">
</FRAMESET>
<FRAMESET COLS="*,*">
<FRAME SRC="http://www.virginia.edu">
<FRAME SRC="http://www.virginia.edu">
</FRAMESET>
</FRAMESET>
RAHUL SAXENA
Frames
32
<FRAMESET ROWS="25%,75%"
<FRAMESET COLS="*,*,*">
<FRAME SRC="http://www.virginia.edu">
<FRAME SRC="http://www.virginia.edu">
<FRAME SRC="http://www.virginia.edu">
</FRAMESET>
<FRAMESET COLS="*,*">
<FRAME SRC="http://www.virginia.edu">
<FRAME SRC="http://www.virginia.edu">
</FRAMESET>
</FRAMESET>
RAHUL SAXENA
Frames
33
<FRAMESET ROWS="*,*">
<FRAMESET COLS="15%, 2*, *">
<FRAME SRC="http://www.cs.virginia.edu/">
<FRAME SRC="http://www.cs.virginia.edu/">
<FRAME SRC="http://www.cs.virginia.edu/">
</FRAMESET>
<FRAMESET COLS="40%, *">
<FRAME SRC="http://www.cs.virginia.edu/">
<FRAME SRC="http://www.cs.virginia.edu/">
</FRAMESET>
</FRAMESET>
RAHUL SAXENA
RAHUL SAXENA
35
RAHUL SAXENA
Why CSS?
CSS removes the presentation attributes from the structure allowing
reusability, ease of maintainability, and an interchangeable presentation
layer.
HTML was never meant to be a presentation language. Proprietary vendors
have created tags to add presentation to structure.
<font> <b> <i>
CSS allows us to make global and instantaneous changes easily.
RAHUL SAXENA
The Cascade
The power of CSS is found in
the cascade which is the
combination of the browsers
default styles, external style
sheets, embedded, inline, and
even user-defined styles.
The cascade sets priorities on
the individual styles which
effects inheritance.
RAHUL SAXENA
CSS Inheritance
Allows elements to inherit styles from parent elements.
Helpful in reducing the amount of CSS to set styles for child elements.
Unless a more specific style is set on a child element, the element looks
to the parent element for its styles.
Each style has a numeric specificity value that is given based on its
selector.
RAHUL SAXENA
Embedded Styles
<style type=text/css>
body {}
</style>
Inline Styles
<p style=font-size: 12px>Lorem ipsum</p>
RAHUL SAXENA
CSS Syntax
selector/element {
property: value;
}
The selector can either be a grouping of elements,
an indentifier, class, or single XHTML element
(body, div, etc)
RAHUL SAXENA
RAHUL SAXENA
Grouping Elements
Allows you to specify a single style for multiple
elements at one time.
h1, h2, h3, h4, h5, h6 {
font-family: Trebuchet MS, sans-serif;
}
RAHUL SAXENA
RAHUL SAXENA
RAHUL SAXENA
CSS Selectors
Identifier or class? Whats the difference?
An identifier is specified only once on a page and has a
higher inheritance specificity than a class.
A class is reusable as many times as needed in a page.
Use identifiers for main sections and sub-sections of
your document.
The difference between an ID and a class is that an ID
can be used to identify one element, whereas a class can
be used to identify more than one.
RAHUL SAXENA
RAHUL SAXENA
RAHUL SAXENA
CSS Fonts
Font-family
Font-weight
Font-style
Font-size
RAHUL SAXENA
CSS Layout
Margin
Padding
Border
Z-index
Positioning
Width
Height
Float
Text-align
Vertical-align
RAHUL SAXENA
CSS Text
Text-indent
Text-align
Text-decoration
Letter-spacing
Text-transform
Word-spacing
White-space
RAHUL SAXENA
CSS Background
Background-color
Background-image
Background-position
Background-repeat
RAHUL SAXENA
CSS Lists
List-style
square
List-style-image
(url())
List-style-position (inside/outside)
List-style-type (circle/decimal/disc/lower-alpha/lowerroman/upper-alpha/upper-roman)
RAHUL SAXENA
CSS Shorthand
Consolidates many styles into a single declaration.
55
RAHUL SAXENA