Chapter - 3
Chapter - 3
3.1 INTRODUCTION
HTML also provides tags to make the document look attractive using graphics,
font size and co lors. User can make a link to the other document or the different
section of the same document by creating hypertext links,known as hyperlinks.
All the web sites in the web that comprising of web pages are created using
HTML.
3.2 OBJECTIVES
-
After going through this lession, you will be able to :
Websites comprising of web pages are created using the language Hypertext
Markup Language (HTML). Each HTML document corresponds to a single
web page. HTML document is written in the form of HTML elements
consisting of 'tags'. An HTML tag comprises a left angular bracket «),
followed by name of the tag, and closed by a right angular bracket (». Tags
are not case-sensitive i.e. there is no difference in small and capital letters in
tags. HTML elements can be categorized as Container elements and Empty
elements.
Container Elements: Tags which have both the opening and closing i.e.
<TAG> and </TAG> are called container elements. The closing tag is the same
as the opening tag, except for the slash (I) mark. Container Elements holds
the text and other HTML tags in between the tags. The <HTML>, <HEAD>,
<TITLE> and <BODY> tags are all container tags.
Example:
<BODY>This is a container tag. It holds both the text and HTML tag
</BODY>
Empty Elements: elements which have no content are called empty elements.
Empty elements do not have closing tags. <HR>, which is used to draw
- Horizontal rule across the width of the document, line break <BR> tags are
empty tags.
48 :: Certificate in Web Designing and Development
The essential elements that are required to create a HTML documents are:
1. HTML Element
2. HEAD Element
3. BODY Element
HTML Element
Every HTML document must include the opening <HTML> tag at the top of
the file, and the closing </HTML> tag at the very end ofthe file.
<HTML>
Your Title and Document (contains text with HTML tags) goes here
</HTML>
An HTML document has two distinct parts HEAD and BODY element
<HTML>
<HEAD>
</HEAD>
<BODY>
</BODY>
</HTML>
HTML Attributes
HEAD Element
<HEAD>
<TITLE>
Your title goes here
<lTITLE>
</HEAD>
BODY Element
The BODY element contains all the text and graphics of the document with
all the HTML tags that are us.ed for control and formatting ofthe page.
<BODY>
</BODY>
An HTML document, web page can be created using a text editor, Notepad,
WordPad or any HTML editor. All the HTML documents should have the
extension .htm or .html. A web browser like Internet Explorer or Mozilla
Firefox or Chrome or Safari Netscape Navigator/Communicator is required
to view the document.
My first Page
</TITLE>
</HEAD>
<BODY>
WELCOME TO MY FIRST WEB PAGE
</BODY>
</HTML>
Step-3: Save the file as myfirstpage.html (go to File- choose SaveAs,
type: All Files' giveFile name: myfirstpage.html'.
click save
Step-4: Viewing document in web browser (open Internet Explorer Click
on File - Open - Browse select the file myfirstpage.html
Oii libraries
~ Documents I
./1-
~PictJ.res
ail Videos
~ local Disk (f
11,,--_.--.-,,,5 ""stem Resr- r --
--
Rename: ~ge.htl1~ __ __ _ _ _
~.~'~-A~J1~fiI~es ~l
-
- Fig. 3.1 : Shows creating and saving the HTML document using Notepad
Basics ofHTML and CSS:: 47
Websites comprising of web pages are created using the language Hypertext
Markup Language (HTML). Each HTML document corresponds to a single
web page. HTML document is written in the form of HTML elements
consisting of 'tags'. An HTML tag comprises a left angular bracket «),
followed by name of the tag, and closed by a right angular bracket (». Tags
are not case-sensitive i.e. there is no difference in small and capital letters in
tags. HTML elements can be categorized as Container elements and Empty
elements.
Container Elements: Tags which have both the opening and closing i.e.
<TAG> and </TAG> are called container elements. The closing tag is the same
as the opening tag, except for the slash (I) mark. Container Elements holds
the text and other HTML tags in between the tags. The <HTML>, <HEAD>,
<TITLE> and <BODY> tags are all container tags.
Example:
<BODY>This is a container tag. It holds both the text and HTML tag
</BODY>
Empty Elements: elements which have no content are called empty elements.
Empty elements do not have closing tags. <HR>, which is used to draw
Horizontal rule across the width of the document, line break <BR> tags are
empty tags. •
48 :: Certificate in Web Designing and Development
The essential elements that are required to create a HTML documents are:
1. HTML Element
2. HEAD Element
3. BODY Element
HTML Element
Every HTML document must include the opening <HTML> tag at the top of
the file, and the closing </HTML> tag at the very end of the file.
<HTML>
Your Title and Document (contains text with HTML tags) goes here
</HTML>
An HTML document has two distinct parts HEAD and BODY element
<HTML>
<HEAD>
</HEAD>
<BODY>
</BODY>
</HTML>
- HTML Attributes
HEAD Element
<HEAD>
<TITLE>
Your title goes here
<lTITLE>
</HEAD>
BODY Element
The BODY element contains all the text and graphics of the document with
all the HTML tags that are used for control and formatting of the page.
<BODY>
</BODY>
An HTML document, web page can be created using a text editor, Notepad,
WordPad or any HTML editor. All the HTML documents should have the
extension .htm or .html. A web browser like Internet Explorer or Mozilla
Firefox or Chrome or Safari Netscape Navigator/Communicator is required
to view the document.
My first Page
</TITLE>
</HEAD>
<BODY>
WELCOME TO MY FIRST WEB PAGE
</BODY>
</HTML>
Step-3: Save the file as myfirstpage.html (go to File- choose SaveAs,
type: All Files 'giveFile name: myfirstpage.html' .
click save
Step-4: Viewing document in web browser (open Internet Explorer Click
on File - Open - Browse select the file myfirstpage.html
Iml~
Orgar'tto:. Nowfi>lder Il= •• ~;
~ RecentPia<:J:.If ......,. _o- I Sze I~~l
j I~'.
" Libraries
No items IMtcn yo.x search.
~ DoaJments
JI~
~ Pictu-es
IiIVodeos
I 1:_.
-
,al~
-
Fig. 3.1 : Shows creating and saving the HTML document using Notepad
Basics ofHTML and CSS:: 51
fJMyfirstPage
Example:
<BODY BGCOLOR="yellow">
Your document text goes here.
</BODY>
Example:
<BODY LEFTMARGIN="60">
This document is indented 60 pixels from the left hand side of the page.
</BODY>
Example:
<BODY TOPMARGIN="60">
This document is indented 60 pixels from the top of the page.
<fBODY>
Example:
<BODY BACKGROUND="filename.gif'>
Your document text goes here
</BODY>
<HTML>
<HEAD>
<TITLE>
Use of Attributes with the Body Tag
</TITLE>
</HEAD>
<BODY BACKGROUND="computer.gif' text="blue"
TOPMARGIN="75 " LEFTMARGIN="75">
Your document text will be indented 75 pixels from the left hand and 75
pixels from the top of the page. The background image computer.gifwill
be tiled across the document. Your image and HMTL document should
present at the same place.
</BODY>
f::IHTML>
N.B: Ensure that image "computer.gif" is available in the same path where
the attribute.html is stored.
-
- Fig. 3.3
1. The language that is used to create document on the World Wide Web
IS:
4. What part of a web page should the <TITLE> tag be used in:
</TITLE>
</HEAD>
<BODY>
<HI> This is Section Heading 1 </HI>
<H2> This is Section Heading 2 </H2>
<H3> This is Section Heading 3 </H3>
<H4> This is Section Heading 4 </H4>
<H5> This is Section Heading 5 </H5>
<H6> This is Section Heading 6 </H6>
</BODY>
</HTML>
Browsers ignore any additional space you type, and compress the text as if
the space did not exist. For Example: You can have text "My
First Page" in HTML document but in browser it display, "My First Page".
Generally you press enter when you want to create line and paragraph breaks, but
it will not be displayed when you view the document in browser.
In order to control your paragraph and line breaks <P> and <BR> tags are
used.
-
Basics of HTML and CSS :: 55
This tag <P> indicates a paragraph, used to separate two paragraphs with a blank:
line.
Example:
Output:
Bin~
The empty tag<BR> used, where the text needs to start from a new line and
not continue on the same line. To get every sentence on a new line, it is
necessary to use a line break.
Example:
- <BODY>
National Institute of Open Schooling <BR> •
A 31, Institutional Area, Sector - 62 <BR>
Distt - GautamBudh Nagar, Noida, Uttar Pradesh, India
</BODY>
56 :: Certificate in Web Designing and Development
Output:
r I
<PRE> tag can be used, where it requires total control over spacing and line
breaks such as typing a poem. Browser preserves your space and line break
in the text written inside the tag.
Example:
<BODY>
<PRE>
National Institute of Open Schooling
A 31, Institutional Area, Sector - 62
Distt - GautamBudh Nagar, Noida, Uttar Pradesh, India
</PRE>
</BODY>
Output:
I
Distt - GautL~ Budh Nagar, N01da, Utter Pradesr., Ind1a
.:JI
~Ir-!Ir ?' MYCompu~
--I ffj.l00% • A<l
Example:An HTML document control. html shows the use of <P>, <BR> and
<PRE>
<HTMl>
<HEAD>
<TITLE>
Use of Paragraph, Line break and preforrnatted text Tag
<lfITLE>
</HEAD>
<BODY>
HTML Tutorial
<P>
HTML stands for Hypertext Markup Language.
It is used for creating web page. It is very simple
and easy to learn.
</P>
<P>
HTML stands for Hypertext Markup Language.<BR>
It is used for creating web page. It is very simple<BR>
and easy to learn. <BR>
</P>
<PRE>
HTML stands for Hypertext Markup Language.
It is used for creating web page. It is very simple
and easy to learn.
</PRE>
</BODY>
</HTML>
58 :: Certificate in Web Designing and Development
HTML stands for Hypertext Markup Language. It is used for creating web page. It is
very simple and easy to learn.
An empty tag <HR> basically used to draw lines and horizontal rules. It can be
used to separate two sections oftext.
Example:
<BODY>
Your horizontal rule goes here.
<HR>
The rest of the text goes here.
</BODY>
Output:
- ~ SIZE: Determines the thickness of the horizontal rule. The value given
is a pixel value.
-
Example:<HR SIZE="3 ">
Example:<HR COLOR="BLUE">
The character formatting tags are used to specify how a particular text should
be displayed on the screen to distinguish certain characters within the
document.
There are certain specialcharacters that can be used whilecreating document. These
are called HTML entities.
Symbols Entity
©,® ©,®
1,4,~,% ¼, ½, ¾
7, <, >, ~ >-+ ÷, &It, >, &le, &ge
& &
0,.,0 &spades, &clubs, &hearts
Example:<PRE>
The copyright symbol is: ©
The registered rank: is: ®
<!PRE>
Output: The copyright symbol is:©
The registered rank: is:®
HTML Supports several ways of arranging items in lists. The most commonly
used are: '
Ordered list also called as Numbered list, is used to present a numbered list
of item in the order of importance or the item (paragraph) is marked with a
number.
An ordered list must begin with the <OL> followed by an <LI> list item
tag.
Basics ofHTML and CSS:: 61
<HTML>
<HEAD>
<TITLE>
An Ordered List
<lTITLE>
</HEAD>
<BODY>
<Hl><U> Various Terms Used In Intemet<IU></Hl>
<OL>
<U> WWW-World Wide Web<ILI>
<U> URL- Uniform Resource Locator<ILI>
<U> HTTP-HypertextTransfer Protocol</U>
<U> FTP-FileTransferProtocol</U>
<U> HTML-Hypertext Markup Language<ILI>
</OL>
</BODY>
</HTML>
~ TYPE: allows marking list items with different types. By default the list Item
markers are set to numbers 1,2,3 ... so on.
Attribute Description
Type=A Capital letter egoA, B, C .........
Type = a Small letter egoa, b, c, .........
Type=I Uppercase Roman Numbers egoI, II, III ......
Type=i Lowercase Roman Numbers egoi, ii, iii......
Type = 1 ego 1,2,3 .............
~ START: used for liststhat need to start at values other than 1. START always
specified in default numbers, and is completed based on TYPE before display,
For example, If START =5 it would display either an 'E', 'e', 'V', 'v', or '5'
based an TYPE attribute.
One ordered list might contain one or more ordered list that is called as Nested
Order lists.
Example: An HTML document nested. html shows the use 0/ Nested Order
Lists with attributes.
<HTML>
<HEAD>
<TITLE> Use of Nested Ordered Lists</TITLE>
</HEAD>
<BODY>
<OL TYPE = A START =3>
<LI> Fruits</LI>
<OLTYPE=I>
<LI> Apple</LI>
<LI> MANGO</LI>
</OL>
<LI>Orange</LI>
-
<LI> VEGETABLES</LI>
<OLTYPE=I>
Basics of HTML and CSS :: 63
<LI>Brinjal<ILI>
<LI> Cabbage</LI>
<LI> Tomato</LI>
</OL>
</OL>
</BODY>
</HTML>
C. Fruits
1. Apple
II. MANGO
III. Orange
D. VEGETABLES
I. Brinjal
II. Cabbage
III. Tomato
Unordered List also called as bulleted list, used to present list of items marked
with bullets. An unordered list starts with in <UL> followed by <LI> (List
Item) tag. Use of<UL> is very similar to <OL> (ordered list).
<HTML>
<HEAD>
<TITLE> Use of Unordered List </TITLE>
</HEAD> -
<BODY>
<UL>
<LI> FRUITS<ILI>
64 :: Certificate in Web Designing and Development
<VI>
<U> Apple<ILI>
<LI> Mango<ILI>
<LI>Orange<ILI>
<IUI>
<U> VEGETABLE<ILI>
<VI>
<LI>Brinjal<ILI>
<LI> Cabbage</LI>
<LI> Tomato<ILI>
<IUL>
<IUI>
</BODY>
</HTML>
• FRUITS
o Apple
o Mango
o Orange
• VEGETABLE
o Brinjal
o Cabbage
o Tomato
The unordered list also used the attributes COMPACT and TYPE = CIRCLE or
DISC (filled Circle used as a bullet)
Points to remember:
JPEG
• JPEG can display large number of colours therefore use for jpeg for
photographs.
• JPEG is not good at preserving exact colors - do not use them for logos or
text.
GIF
• GIF can display only 256 colours
• Use GIF to save images that have sharp lines (like text) and solid colors.
• Use GIF to save images that need to have a transparent background.
• GIF was invented for creating screen graphics - do not use GIF for images
that you want to print on paper.
PNG
- • Use PNG if you want to have images with blended transparent
backgrounds.
It is an empty tag (only start tag, no end tag) and is written as:
Example:<IMG SRC="file:IIIC:INIOSlogo.GIF">
o ALT
Height and Width of an image can be controlled by using the HEIGHT and WIDTH
attributes in the <IMG> tag as follows:
AL T (Alternative Text)
This attribute is used to give alternative text that can be displayed in place ofthe
image. This is required when the user needs to stop display of images while retrieving
a document in order to make the retrieval faster, or when the browser does not
support graphics. It is also used a too I tips - displaying description ofthe image
when the mouse is over the image.
- It is mandatory to use alt attribute with every image. Ifthe image is for decoration
alt = " " should be used.
Basics ofHTML and CSS :: 67
BORDER
Border around the image can be controlled by using BORDER attribute of <IMG>
tag. By default image displays with a thin border. To change the thickness or
turn the border off the value in pixels should set to BORDER attribute.
Web pages are linked to one another through Hypertext Links. Section oftext
or image in the HTML document can be linked to an external document or to
a specific place within the same document. The text or image that provides
such linkage is known as Hypertext or Hotspot.
HTML provides <A> Anchor Tag to create links. The format of using anchor
tag is as follows:
HREF (Hyper Link Reference) is a mandatory attribute used to refer the URL
of the resource. URL (Uniform resource locator) is an address tells the browser
about the file to link to. It identifies file locations (Addresses) on the web or
on the local hard drive. These addresses can be those ofHTML documents or
elements such as images, scripts, applets and other files. It is always enclosed
in quotes.
Example:
-
<A HREF = ••http://www.nios.ac.in ••>Link to Website ofNIOS</A>
In the above example the link text "Link to Website ofNIOS" would appear
68 :: Certificate in Web Designing and Development
underlined and in a color differentfrom any other text inthe document to distinguish
a link from normal text. Also you would find that the mouse pointer changes into a
hand like symbol when taken over the hyperlink.
Example:
This link text jumps to the section named with HREF on click. The #
symbol before the section name is must.
One can also jump to a specific section of different document specifying the
path on HREF attribute.
Example:
document:<A
name">
HREF="document.html#
-
section name">
Basics of HTML and CSS :: 69
TITLE
This attribute is used to provide additional/advisory information (expand on
the meaning ofthe link). The anchor text is supposed to "name" the link, while
the title text provides-information about where the link will send the user.
Title attribute must be used with non descriptive links like 'click here' or 'Read
More'.
<HTML>
<HEAD><TITLE> Use of Anchor Tag</TITLE></HEAD>
<BODY>
<A HREF= ••http://www.nios.ac.in ••TITLE="Click here to access national
institute of open schooling(NIOS) web site"> Click here to Access NIOS
Website</ A>
</BODY>
</HTML>
- -
70 :: Certificate in Web Designing and Development
,
J PI I:
j
i ~:lSt • Use of Anchor Tag J9. :I
Click here to Access NIOS Website
I
Irllllli.My~ter
You simply specify which areas of the image should link to where.
Example:
<HTML>
<BODY>
<MAP NAME="PLANETMAP">
</MAP>
</BODY>
</HTML>
Source: http://www.w3schools.com
N.B:Ensure that image "Planets.gif' and the page sun.htm, mercur.htm and
venus.htm are available in your system at one place.
There are three different shapes (commonly termed "hot spots") that can be
used in image maps. Those are as follows:
RECT
CIRCLE
POLYGON
12. HTML does not allow a web page to include an image. (True/False)
Cascading Style Sheets is a simple mechanism for adding style (e.g., fonts,
colors, spacing) to Web documents written in HTML.
CSS is used by both the authors and readers of web page to define colors,
fonts, layouts and other aspects of document presentation. It is designed
72 :: Certificate in Web Designing and Development
• Web browser software can store a copy of the CSS file in computer's cache,
so that it doesn't have to be downloaded each time the user views a page
that reference it, hence improving the access time.
• Different users can have different style sheets: for example a large text
alternative for visually impaired users or a layout optimized for small
displays for mobile phones.
• The document code is reduced in size and complexity, since it does not
need to contain any presentational markup.
Quite interesting!
FT T'TT'T"] MvCon1'UtI:r -
Fig. 3.13 : HTMLFile
The resulting HTML page, with colors and layout, all done with CSS
Basics of HTML and CSS :: 73
<HTML>
<HEAD>
<TITLE>My First Styled Page<ffITLE>
</HEAD>
<BODY>
<!- Site Navigation Menu->
<UL>
<LI><A HREF="absolute.html"> About Me</A><ILl>
<LI><A HREF=''http://www.nios.ac. in">
My School</ A></LI>
<LI><A HREF="myfriends.html">My Friends</ A></U>
<LI><A HREF="contactme.html">Contact Me</ A></U>
</uL>
<!- Main content ->
<Hl>My First styled page</Hl>
<P>Welcome to my styled page!</P>
<P>It lacks images, but at least it has style. I feel it is very easy to
apply colors to my page.</P>
<P>Quite interesting!</P>
</BODY>
</HTML>
• AboutMe
• ).ivSchool
• ).iv Friends
• ContactMe
It lacks images. but at least it bas style. I feel it is very easy to apply colors to my page.
Quite iote1"esting!
.:::.J
Done 100% • hi
You probably see some black text on a white background, but it depends on how
the browser is configured. So one easy thing you can do to make the page more
stylish is to add some colors.
You need to add a <style> element to the HTML file.The style sheet will be inside
that element. Go back to the editor notepad( click on start' >
AllPrograms'!Accessories'!Notepad) -> open the HTML document
'style.html' and add the following five lines in the head part of the HTML
file then Save the file. The lines to add are shown in bold.
<HTML>
<HEAD>
<TITLE>My first styled page</TITLE>
<STYLE Type="text/css">
BODY {
COLOR: Purple;
BACKGROUND-COLOR: #d8da3d}
</STYLE>
</HEAD>
<BODY>
[etc.]
The first line says that this is a style sheet and that is written in CSS ("textl
css"). The second line says that you add style to the "body" element. The third
line sets the color of the text to purple and the next line sets the background
to a sort of greenish yellow.
Style sheets in CSS are made up of rules. Each rule has three parts:
1. the selector (in the example: "body"), which tells the browser which part
of the document is affected by the rule;
2. the property (in the example, 'color' and 'background-color' are both
properties), which specifies what aspect of the layout is being set;
-
3. and the value ('purple' and '#d8da3d'), which gives the value for the style
property.
Basics ofHTML and CSS:: 75
The example shows that rules can be combined. You have set two properties, so
you could have made two separate rules:
but since both rules affect the body, you only wrote "body" once and put the
properties and values together.
The background ofthe body element will also be the background of the whole
document. You have not given any of the other elements (p, li, address ... ) any
explicit background by default they will have none (or: will be transparent). The
'color' property sets the color of the text for the body element, but all other elements
inside the body inherit that color, unless explicitly overridden. Apart from the list of
links at the top, the text should now be purple against a greenish yellow background.
Now save this file (use "Save" from the File menu) and go back to the browser
window and open to get the page as shown below.
1:' My first styled page - Windows Interne~ Explorer ~ , . --, ';,_ '_ ;: ,BIilE!
~. l~c:~tsandsettWlgs~..:J .! X I .' p.
• AboutMe
• MvSchool
• MyFriends
• ContactMe
It Jacks images. but at least it has style, I feel it is very easy to apply colors to my page.
Quite interesting!
.:J
. ~iOo% • hi
On the web, you can never be sure what fonts your readers have on their computers,
you add some alternative fonts as well.
<HTML>
<HEAD>
<TITLE>My first styled page</TITLE>
<STYLE Type="text/css">
BODY {
FONT - FAMILY: Georgia, "Times New Roman",
Times, Serif;
COLOR: purple;
BACKGROUND_COLOR: #d8da3d }
HI {
FONT_FAMILY: Helvetica, Geneva, Arial, SunSans_Regular,
Sans_Serif}
</STYLE>
</HEAD>
<BODY>
[etc. ]
I,J ••..
"'" fdt _ Favorites Tools H$
• AboutMe
• MvScboal
• MvFftspd<
• CoatactMe
It 1achiaJaees. bat lit Ieest it bas style. I feel it is WI}' aDY to IIFIJIYcolao to my ~
-
rrrrrr My~
Fig. 3.16 : Viewing HTML document style.html in browser after adding fonts
to the body and header using CSS
Basics ofHTML and CSS :: 77
The list at the top ofthe HTML page is meant to become a navigation menu. Many
web sites have some sort of menu along the top or on the side ofthe page and this
page should have one as well. You will put it on the left side, because that is a little
more interesting than at the top.
The menu is already in the HTML page. It is the <ul> list at the top. The links in it
do not work, since our "Website" so far consists of only one page, but that does
not matter now. On a real Website, there should not be any broken links, of course.
You need to move the list to the left and move the rest of the text a little to the right,
to make room for it. The CSS properties you use for that are 'padding-left' (to
move the body text) and 'position', 'left' and 'top' (to move the menu).
<HTMl>
<HEAD>
<TITLE>My first styled page<ffITLE>
<STYLE TYPE="textlcss''>
BODY {
PADDING_LEFT: Hem;
FONT_FAMILY: Georgia, ''Times New Roman",
Times, serif;
COLOR: Purple;
BACKGROUND_COLOR: #d8da3d }
HI {
FONT_FAMILY: Helvetica, Geneva, Arial,
SunSans _ Regular, Sans Serif}
<lSTYLE>
</HEAD>
<BODY>
[etc.]
78 :: Certificate in Web Designing and Development
• AboutMe
• MyScbool
• MyFrieods
• CoatactMe
It IacIcs images, but at ~ it bas style. I feel it is wry easy to apply colors to my page..
Quite interesling!
The navigation menu still looks like a list, instead of a menu. Let's add some
style to it. You will remove the list bullet and move the items to the left, to
where the bullet was. You will also give each item its own white background
and a black square.
In this example blue color is used for links and purple color for visited links.
<HTML>
<HEAD>
<TITLE>My first styled page</TITLE>
<STYLE TYPE="text/css">
BODY {
PADDING-LEFT: l Iem;
FONT-FAMILY: Georgia, "Times New Roman",
Times, serif;
COLOR: purple;
BACKGROUND-COLOR: #d8da3d }
UL.NAVBAR {
- LIST-STYLE- TYPE: none;
PADDING: 0;
Basics of HTML and CSS :: 79
MARGIN: 0;
POSITION: absolute;
TOP:2ern;
LEFT: l em;
WIDTH: gern}
HI {
FONT- FAMILY: Helvetica, Geneva, Arial,
SunSans- Regular, sans-serif}
UL.NAVBAR LI {
BACKGROUND: white;
MARGIN: 0.5ern 0;
PADDING: 0.3ern;
BORDER-RIGHT: I ern solid black}
UL.NAVBARA {
TEXT-DECORATION: none}
A:LINK {
COLOR: blue}
A:VISITED {
COLOR: purple}
</STYLE>
<!HEAD>
<BODY>
[etc.]
About Me
My School
My Friends
•
I
My first styled page
Welcome to my styled pagel
- ..:.l
Traditionally, browsers show hyperlinks with underlines and with colors. Usually,
the colors are similar to what we specified here: blue for links to pages that you
haven't visited yet (or visited a long time ago), purple for pages that you have already
seen.
In HTML, hyperlinks are created with <a> elements, so to specify the color, you
need to add a style rule for "a". To differentiate between visited and unvisited links,
CSS provides two "pseudo-classes" (:link and :visited). These are called ''pseudo-
classes" to distinguish these from class attributes, that appear in the HTML directly,
e.g., the c1ass="navbar" in our example.
You now have an HTML file with an embedded style sheet. But if our site grows
you probably want many pages to share the same style. There is a better method
than copying the style sheet into every page: if we put the style sheet in a separate
file, all pages can point to it.
To make a style sheet file, you need to create another empty text file using notepad.
BODY {
PADDING-LEFT: IIEM;
FONT-FAMILY: Georgia, ''Times New Roman",
Times, serif;
COLOR: purple;
BACKGROUND-COLOR: #d8da3d }
UL.NAVBAR{
LIST-STYLE- TYPE: none;
PADDING: 0;
MARGIN: 0;
POSITION: absolute;
TOP: 2em;
LEFT: lern;
WIDTH: gem}
Ht{
FONT-FAMILY: Helvetica, Geneva,Arial,
SunSans- Regular, sans-serif}
UL.NA VBAR LI {
- BACKGROUND: white;
MARGIN: O.SemD;
Basics ofHTML and C~S :: 81
PADDING: O.3em;
BORDER-RIGHT: lemsolidblack}
UL.NAVBARA {
TEXT-DECORATION: none}
A:LINK {
COLOR: blue}
A:VISlTED {
COLOR: purple}
Choose "Save As ... " from the File menu, make sure that you are in the same
directory/folder as the style.html file, and save the style sheet as "mystyle.css".
Now go back to the HTML document remove everything from the <style> tag up .
to and including the <lstyle> tag and replace it with a <link> element, as follows:
<HTML>
<HEAD>
<TITLE>My first styled page<ITITLE>
<LINK REL="stylesheet" href="mystyle.css">
</HEAD>
<BODY>
<!- Site navigation menu->
<UL CLASS="navbar">
<LI><A href="aboutme.html"> About Me<!A><ILI>
<LI><A href=••http://www.nios.ac.in ••>MySchool<lA><ILI>
<LI><A href="myfriends.html">My Friends<lA><ILI>
<LI><A href="contactme.html">Contact Me<!A></LI>
</UL>
<!- Main content->
<Hl>My first styled page<lHl>
<P>Welcome to my styled page!</P>
<P>It lacks images, but at least it has style.</P>
I feel it is very easy to apply colors to my page.
<P>Quite interesting!</P>
</BODY>
-
82 :: Certificate in Web Designing and Development
.I!i}Page. @T"" »
About Me
My first styled page
Welcome to my styled pagel
My School
It lacks images, but at least it has style. I feel it is
My Friends
very easy to apply colors to my page.
Quite interestingl
100% • A<
This will tell the browser that the style sheet is found in the file called "mystyle.css"
and since no directory is mentioned, the browser will look in the same directory
where it found the HTML file.
If you save the HTML file and reload it in the browser, you will notice that there is
no change: the page is still styled the same way, but now the style comes from an
external file.
In this lesson you have learnt how to create, save and view a HTML document,
formatting a web page, use of hypertext links. Also you have learnt about image
mapping (the technique of making links in different parts of an image to several
pages), and applying CSS to a HTML document.
-
Basics of HTML and CSS :: 83
1. Create a HTML file for the fo llowing web page as shown in figure:
Hello World!
Its my first web page.
JITML (Hypertext Markup Language) contains some predefined tags to create web pages.
n is very simple and easy to learn.
There are munb er ofJITML editors available. Most popular are:
MIcrosoft FrootPage
Dreamweaver
You can download some JITML editors that fteeIy available on the Internet
~:'?tftrj;
••• Edt v_ FilVortH lods ....,
4o'ad< - ••• @ @l~ I iQ_m Cii_ .- G I~· ~ iii • I!l @
-It! c,.•••
_,_""'dj,jt""".hbn1 !I ('>,. I•.••••
»
m_-I LP-J:l©••.•••.
""'" f!lSa_, I>"'""'~
~·lt-I """'h_I·IEO- """'_1..l>doIe e"",-,
·1121•••••• »
.:
Tennlnoiogies used In Internet
IITML
• <htm1>
• <head>
• <title>
• <body>
-
.. ....
.:J
'= rl'F~"-,',,,
em
.,.,
lilll<re ~
- 3. Write the tag that is used to place images in a web page. Give five attributes
that you can associate with this type oftag. Define Image Maps.
4. Explain Hypertext links. What is the method to link a specific place within the
same document?
84 :: Certificate in Web Designing and Development
Add"·"I~c:\Iinl<s.htm
m,1\oIIIIJIIeIIIr -I
Useful Links
Yahoo
Hotmail
Times of India
Hinduslan times
l. B
2. False
3. Head, Body
4. Head
5. True
6. B
7. True
Basics ofHTML and CSS:: 85
8. <UL>
9. D
10. False
11. True
[0
12. False
13. B
14. <IMG>
15. BORDER