Unit-1 (HTML & CSS)
Unit-1 (HTML & CSS)
Management of data?
1. communication,
2. information sharing,
3. interoperability,
4. user-centered design
5. and collaboration on the World Wide Web.
2
INTRODUCTION
3
A website has a distinct
fully qualified domain name
Ex:- www.google.com.
4
Contents:
1. HTML Introduction
2. Common tags –List, Tables, images
3. Forms
4. Frames
5. Cascading Style sheets
5
HTML Introduction
web pages are written in
HyperText Markup Language (HTML).
Web pages contain text ,hyperlinks (links
to other web pages), tables, images.
6
7
Markup: Markup refers to the sequence of
characters or other symbols that you insert at
certain places in a text or word processing file to
indicate how the file should look when it is printed
or displayed or to describe the document's logical
structure. The markup indicators are often called
"tags.
Hypertext:Apart from text, hypertext is sometimes
8
WEB BROWSER
9
Title bar
Menu bar
Tool bar
Address bar
Status bar
10
CATEGORIES OF TEXT
11
HTML is a language used to design web pages.
In
other words ,HTML is all about specifying structure
and format of web page.
12
HTML Tags
HTML tags are used to mark-up HTML elements.
The first tag in a pair is the start tag, the second tag is the end
tag.
HTML tags are not case sensitive, <b> means the same as
<B>
13
AnHTML file is a text file containing small markup
tags.
14
<html>
<head>
<title>Title of the
page
</title>
</head>
<body>
</body>
</html>
15
EXAMPLE
<html>
<head>
<title>This is my first web page ! </title>
</head>
<body>
<b> welcome to snist </b>
</body>
</html>
16
17
Tag<HTML> indicates this page is written in HTML
language.
19
Common HTML tags:-
Understanding the following table:
20
Document Structure
21
Formatting
WIDTH = % of Document to
"number %" Span
NOSHADE Removes
Shading
23
Character
24
Links
Opening Tag Closing Attribute Description
Tag
25
Images
26
Tables
Opening Tag Closing Tag Attribute Description
<TABLE> </TABLE> Adds Table
BORDER="number" Border for Rows & Columns
CELLPADDING Size of Cell Wall
CELLSPACING Spacing between Border and
Cell Contents
BGCOLOR Background Color of Cells
<TR> </TR> Table Row (Start & End)
ALIGN="Left, Center, Aligns Text in Row
Right" Horizontally
VALIGN="Top, Aligns Text in Row Vertically
Middle, Bottom"
<TD> </TD> Defines Data Cell
COLSPAN="number" Spans Cells across Column
ROWSPAN="number" Spans Cells across Row
<TH> </TH> Header Cell in Table
COLSPAN="number" Spans Cells across Column
ROWSPAN="number" Spans Cells across Row
<CAPTION> </CAPTION> Text outside Table
ALIGN="Top, Bottom" Aligns Caption at Top or
Bottom 27
<!– Table Example
<body>
<center><b> <caption > Table Example </caption></b> </center>
<table border="2" align="center" bgcolor="pink" cellpadding="10"
cellspacing="2">
<tr align=“center”>
<th> RollNo </th>
<th> Name </th>
</tr>
<tr>
<td align=“right”> 1 </td>
<td> abc </td>
</tr>
<tr>
<td align=“right”> 2 </td>
<td> pqr </td>
</tr>
</table>
28
Example for colspan attribute of td tag
<table border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$100</td>
</tr>
<tr>
<td colspan="2">Sum: $180</td>
</tr>
</table>
29
Opening Tag Closing Tag Attribute Description
<OL> </OL>
30
<caption> List </caption>
<UL>
<LI>Unordered information.
<LI>Ordered information.
<LI>Definitions.
<OL>
<LI> ... Level one, number one...
<LI> ... Level one, number two...
<OL start="1" type="a">
<LI> ... Level two, number one...
</OL>
<LI> ... Level one, number three...
</OL>
<DL>
<DT><STRONG>Lower cost</STRONG>
<DD>The new version of this product costs significantly less than the
previous one!
<DT><STRONG>Easier to use</STRONG>
<DD>We've changed the product so that it's much easier to use!
</DL>
31
HTML forms
32
<form> :- another kind of HTML tag
used to create GUIs on Web pages
◦ Purpose: to ask the user for information
◦ The information is then sent back to the server
33
FormPage1
SERVER
Name,address,
gender, interests
SUBMIT
Form elements:
checkboxes, text fields, radio buttons, drop-down menus, etc
Other kinds of HTML tags can be mixed in with the form elements
Contains a Submit button to send the information in the
form elements to the server
34
<form parameters> ... </form> tag encloses form
elements and other HTML
◦ method="get" (default)
Form data is sent as a URL with ?form_data info appended to
the end
Used if data is all ASCII and not more than 100 characters
35
◦ method="post"
Form data is sent in the body of the URL request
Cannot be bookmarked by most browsers
◦ target="target"
Tells where to open the page sent as a result of the request
target= _blank means open in a new window
target= _top means use the same window
target= <framename> means use the same window
36
form elements use the input tag, with a type="..."
argument to tell which kind of element it is.
A password field:
<input type="password" name="textfield3" value="secret">
• Note that two of these use the input tag, but one uses textarea
38
A checkbox:
<input type="checkbox" name="checkbox” value="checkbox"
checked>
type: "checkbox“
39
A submit button:
<input type="submit" name="Submit" value="Submit">
A reset button:
<input type="reset" name="Submit2" value="Reset">
A plain button:
<input type="button" name="Submit3" value="Push Me">
If two or more radio buttons have the same name, the user can
only select one of them at a time
◦ This is how you make a radio button “group”
If you ask for the value of that name, you will get the value
specified for the selected radio button
Additional arguments:
◦ size: the number of items visible in the list (default is "1")
42
<input type="hidden" name="hiddenField" value="nyah">
<-- right there, don't you see it?
◦ This is a way to include information that the user doesn’t need to see (or
that you don’t want her to see)
43
<html>
<head>
<title>Get Identity</title>
</head>
<body>
<p><b>Who are you?</b></p>
<form method="post" action="">
<p>Name:
<input type="text" name="textfield">
</p>
<p>Gender:
<input type="radio" name="gender" value="m">Male
<input type="radio" name="gender" value="f">Female</p>
</form>
</body>
</html>
44
Frames
45
HTML frames are used to divide your browser window
into multiple sections
47
<frameset></frameset>
Replaces the <body> tag in a frames document; can
also be nested in other framesets
<frameset rows="value, value">
Defines the rows within a frameset, using number in
pixels, or percentage of width
<frameset cols="value,value">
Defines the columns within a frameset, using number in
pixels, or percentage of width
<frame>
Defines a single frame — or region — within a frameset
<noframes></noframes>
Defines what will appear on browsers that don't support
frames
48
Browser Support for Frames
If a user is using any old browser or any browser which
49
<frame src="URL">
Specifies which HTML document should be displayed
<frame name="name">
Names the frame, or region, so it may be targeted by other frames
<frame marginwidth=#>
Defines the left and right margins for the frame; must be equal to or
greater than 1
<frame marginheight=#>
Defines the top and bottom margins for the frame; must be equal to
or greater than 1
<frame scrolling=VALUE>
Sets whether the frame has a scrollbar; value may equal "yes," "no,"
or "auto." The default, as in ordinary documents, is auto.
<frame noresize>
Prevents the user from resizing a frame
50
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows="10%,80%,10%">
<frame name="top" src="/html/top_frame.htm" />
<frame name="main" src="/html/main_frame.htm" />
<frame name="bottom" src="/html/bottom_frame.htm" />
<noframes>
<body>
Your browser does not support frames.
</body>
</noframes>
</frameset>
</html>
51
52
Let’s create a page that has a left hand menu and a
right hand content area where when we click on the
menu links the content on the right hand side
changes
53
54
4 HTML files
Filenames are:
◦ Home.htm
◦ Content1.htm
◦ Content2.htm
◦ Content3.htm
55
This File needs the list of links
◦ Home Links to Home.htm
◦ Content1 Links to Content1.htm
◦ Content2 Links to Content2.htm
◦ Content3 Links to Content3.htm
56
In Code view (Save file as FrameExample.htm):
Code What it does
<frameset cols="30%,*"> Splits browser into 2 vertical areas. First is a column
that is 30% of the width of the browser window,
second is rest of the browser window
This is the left frame and it is called “LeftMenu”. The
<frame name="LeftMenu" src="leftMenu.htm" default source to be displayed in this frame is
marginwidth="0" marginheight="0" scrolling="auto" “leftMenu.htm” NOTE: Any changes to “leftMenu.htm”
frameborder="1"> will appear on all pages
This is the main area for content and is a frame called
<frame name="MainContentArea" “MainContent”. The default source to be displayed in
src=“Home.htm" marginwidth="0" marginheight="0" this frame is “Home.htm”
scrolling="auto" frameborder="1">
57
Move all the pages to your folder
◦ Home.htm
◦ Content1.htm
◦ Content2.htm
◦ Content3.htm
◦ LeftMenu.htm
◦ FrameExample.htm
58
Nest a second frameset into your initial frameset as
shown below:
Save file as “FrameExample2.htm”
<frameset cols="30%,*">
<frame name="LeftMenu" src="LeftMenu.htm“ >
<frameset rows="50,*">
<frame name="TopMenu" src="TopMenu.htm“ >
<frame name="MainContent" src="MainContent.htm“
frameborder="1">
</frameset>
</frameset>
59
Copy the Files you created over to your folder
◦ FrameExample2.htm
◦ TopMenu.htm
60
Disadvantages of Frames
◦ There are few drawbacks with using frames, so it's never
recommended to use frames in your web pages:
Some smaller devices cannot cope with frames often
because their screen is not big enough to be divided
up.
Sometimes your page will be displayed differently
user hopes.
There are still few browsers that do not support
frame technology.
61
62
CSS
◦ Used to describe the presentation of a document
written in a mark up language.
◦ CSS is style sheet language used for describing the look
and formatting of a document.
h1 {
color: #0000FF;
font-size: 24pt; Declarations
}
Value
Property
64
CSS rule set consists of Selector and a declaration
block.
65
Inline Styles
◦ coded in the body of the web page as an attribute of an
HTML tag.
◦ Applies to the specific element that contains it as an
attribute
67
<html>
<style type="text/css">
body {background-color: yellow; color:red}
p {color:green; font-size=60%}
p.change { color:rgb(0,0,255); font-size:195%}
</style>
</head>
<body>
<h1>This is heading 1</h1>
<p> color is green. font size=60%.</p>
<p class="change">This is a paragraph with class="change". font-
size=90%.</p>
</body>
68
<html>
<head>
<link rel="stylesheet“
type="text/css“
href="style.css“ />
</head>
<body>
An external style sheet can be written in any text
editor. The file should not contain any html tags. The
style sheet file must be saved with a .css extension.
69
Instead of this…
CSS: H1 { color: #FFFF00; }
H2 { color: #FFFF00; }
70
The class selector selects elements with a specific
class attribute.
To select elements with a specific class, write a
71
<html>
<head>
<style> o/p:
p.center {
text-align: center; This heading will not be affected
color: red; This paragraph will be red and center-aligned
}
</style>
</head>
<body>
</body>
</html>
72
Classes
◦ Allow styles for groups of elements
CSS: .warning { color: red; }
HTML: <h3 class=“warning”>
File not found.
</h3>
73
CSS: p.black {color: #000000;}
p.blue {color: #000080;}
74
background-color
color
font-family
font-size
padding
margin
text-decoration
line-height
text-align
background-image
75
font-family
◦ Ordered list of font names
◦ Quote names with spaces: ex. “Arial Black”
CSS: p.arial {
font-family: Arial, Helvetica, sans-serif;
}
font-size
◦ larger, smaller, or specific height
CSS: p.big { font-size: 60px; }
76
color:
◦ Named Colors: red, blue, green
◦ Hex: #FFCC00, #FC0
◦ RGB values: rgb(123, 123, 123)
CSS: p.green { color: #00FF00; }
background-color:
◦ color or transparent
CSS: p.highlight { background-color: #FFCC00; }
77
Text Text Text Text Text Text
Text Text Text Text Text Text
margin padding Text Text Text Text Text Text
padding margin
Text Text Text Text Text Text
Margin
◦ The space between this and other elements
◦ margin-top, margin-right, margin-bottom, margin-left
78
Text Text Text Text Text Text
Text Text Text Text Text Text
margin padding Text Text Text Text Text Text
padding margin
Text Text Text Text Text Text
Padding
◦ The CSS padding properties define the white space
between the element content and the element border.
◦ The space between the margin and the element
◦ padding-top, padding-right, padding-bottom, padding-left
(can use same shortcut as with margins)
◦ Comparable to TABLE’s cell-padding
79
This “cascade” applies the styles in order from outermost
(External / Linked Styles) to innermost (actual XHTML code
on the page).
This way site-wide styles can be configured but overridden
when needed by more granular (or page specific) styles.
80
CSS was a revolution in the world of web design.
control layout of many documents from one
single style sheet;
more precise control of layout;
apply different layout to different media-types
(screen, print, etc.)
81
END
82