3. WT Unit 1 (HTML)
3. WT Unit 1 (HTML)
Web Page Designing: HTML: List, Table, Images, Frames, forms, CSS, Document type definition, XML:
DTD, XML schemes, Object Models, presenting and using XML, Using XML Processors: DOM and SAX,
Dynamic HTML
HTML
What is HTML?
Stands for Hypertext Markup Language.
Most documents that appear on the World Wide Web were written in HTML.
HTML is a markup language, not a programming language. In fact, the term HTML is an
acronym thatstands for Hypertext Markup Language.
We can apply this markup language to your pages to display text, images, sound and movie
files, andalmost any other type of electronic information.
We use the language to format documents and link them together, regardless of the type of
computer with which the file was originally created.
HTML Elements
An element consists of three basic parts: an opening tag, the element's content, and finally,
a closing tag.
<p> - opening paragraph tag
Element Content - paragraph
words
</p> - closing tag
Every (web) page requires four critical elements: the html, head, title, and body elements.
1. <html> Element...</html>
o <html> begins and ends each and every web page.
o Its purpose is to encapsulate all the HTML code and describe the HTML document
to theweb browser.
<html></html>
2. <head> Element
o The <head> element is "next" as they say. As long as it falls somewhere between your
<html>tag and your web page content (<body>).
o The head functions "behind the scenes." Tags placed within the head element are not
directly displayed by web browsers.
o We will be placing the <title> element here.
o Other elements used for scripting (JavaScript) and formatting (CSS) will eventually be
introduced and you will have to place them within your head element.
<html>
<head>
</head>
</html>
The <title> Element
o Place the <title> tag within the <head> element to title your page.
o The words you write between the opening and closing <title></title> tags will be
displayed at thetop of a viewer's browser.
<html><head><title>My WebPage!</title></head></html>
HTML Tags
o A web browser reads an HTML document top to bottom, left to right.
o Each time the browser finds a tag, it is displayed accordingly (paragraphs look like
paragraphs, tables look like tables, etc).
o Tags have 3 major parts: opening tag(s), content(s), and closing tag(s).
o Recall that a completed tag is termed an element.
<html><body>
<h1>This is heading 1</h1><h2>This is heading 2</h2><h3>This is heading 3</h3>
<h4>This is heading 4</h4><h5>This is heading 5</h5><h6>This is heading 6</h6>
</body></html>
3. Line Breaks
o Line breaks are different then most of the tags we have seen so far. A line break ends
the lineyou are currently on and resumes on the next line.
<p>Darshan<br /> Computer<br /></p>
HTML Lists
o There are 3 different types of lists.
o A <ol> tag starts an ordered list, <ul> for unordered lists, and <dl> for definition lists.
1. <ul> - unordered list; bullets
2. <ol> - ordered list; numbers
3. <dl> - definition list; dictionary
<ol>
<li>Find a Job</li>
<li>Move Out</li>
</ol>
o Start your ordered list on any number besides 1 using the start attribute.
o There are 4 other types of ordered lists. Instead of generic numbers you can replace
them with Roman numerals or letters, both capital and lower-case. Use the type
attribute to change the numbering.
<oltype="a">
<oltype="A">
<oltype="i">
<ol type="I">
</ol>
<ul>
<li>Milk</li>
<li>Chocolate</li>
</ul>
<oltype="square">
<ol type="disc">
<oltype="circle">
</ol>
<dl>
<dt><b>Fromage</b></dt>
<dd>French word for cheese.</dd>
<dt><b>Voiture</b></dt>
<dd>French word for car.</dd>
</dl>
4. HTML Nested Lists
o You can also nest one list within another, so you could make an unordered list
inside a
<html>
<ol>
<li> Clear out garage</li>
<ul>
<li> Tomatoes</li>
</ul>
<li> repair fence </li>
</ol>
</html
numbered >
one:
HTML Color Coding System - Color Names
There are 3 different methods to set color.
<body bgcolor=”red”>
<font color=”red”>
<body bgcolor=”rgb(72,0,0)”>
<font color=”rgb(72,0,0)”>
<body bgcolor=”#ffff00”>
<font color=”#ffff00”>
1. Font Size
o Set the size of your font with size. The range of accepted values is from 1(smallest) to
7(largest).The default size of a font is 3.
2. Font Color
o Set the color of your font with color.
3. Font Face
o Choose a different font face using any font you have installed.
HTML Code:
<html><body>
<basefont size="2" color="green"><p>This paragraph has had its font...</p>
</basefont>
</body></html>
Internal - href="#anchorname"
Local -
href="../pics/picturefile.jpg"
Global -
href=http://www.xyz.com/
HTML – Images
o Use the <img /> tag to place an image on your web page.
<imgsrc="sunset.gif" />
1. Image src
o Above we have defined the src attribute.
o Src stands for source, the source of the image or more appropriately, where the picture
file is located.
o There are two ways to define the source of an image. First you may use a standard URL.
(src=http://www.Xyz.com/pics/htmlT/sunset.gif) As your second choice, you may copy
or upload the file onto your web server and access it locally using standard directory tree
methods. (src="../sunset.gif")
o The location of this picture file is in relation to your location of your .html file.
URL Types:
Local Src Location Description
src="sunset.gif" picture file resides in same directory as .html
file
src="../sunset.gif" picture file resides in previous directory as
.htmlfile
src="../pics/sunset.gif" picture file resides in the pic directory in a
previous directory as .html file
2. Alternative Attribute
o The alt attribute specifies alternate text to be displayed if for some reason the browser
cannot find the image, or if a user has image files disabled.
5. Images as Links
o Images are very useful for links and can be created with the HTML below.
<a href="http://www.xyz.com/"><imgsrc="sunset.gif"></a>
HTML Forms
o A form will take input from the viewer and depending on your needs, you may store that
data into a file, place an order, gather user statistics, register the person to your web
forum, or maybe subscribe them to your weekly newsletter.
Making a Form
o <form> is main tag to build a form.
o It has a few optional attributes too. Below is an example of the form element.
o The action attribute tells the HTML where to send the collected information, while the
methodattribute describes the way to send it.
Type of Input
o The main tag for collecting information from the user is <input>.
o The tag itself contains a name attribute, so that we can refer to the input by a name, and
the sizeof the entry box in characters.
o There are quite few different types of input to choose from:
o <input type=”text”/> this is the default input type and accepts characters and numbers
into a text box. It can also have a value attribute attached to it, which will give it an initial
value.
o <input type=”password”/> this is similar to the above text box but anything that is typed
cannot be seen; instead an asterisk is printed to cover up the entry. As the name
suggests, this is used for password entry.
o <input type=”checkbox”/> this gives a box that can be toggled between checked and
unchecked. It can initially be set to one or the other with checked=”checked”.
o <input type=”radio”/> this is similar to checkbox but in group of radio buttons only one
can be selected at a time. This can also have an initial checked state on one of the radio
buttons.
o <input type=”file”/>This will give a box to allow you to choose a file similar to when you
open or save files usually on your machine. It can be used to select a file on the local
machine for upload to a server.
<form method="post"
action="mailto:[email protected]">What kind of
shirt are you wearing? <br />
Shade:
<input type="radio" name="shade" value="dark">Dark
<input type="radio" name="shade" value="light">Light <br />
</form>
<form method="post"
action="mailto:[email protected]"> Select your
favorite cartoon characters.
<input type="checkbox" name="toon" value="Goofy">Goofy
<input type="checkbox" name="toon" value="Donald">Donald
<input type="checkbox" name="toon" value="Bugs">Bugs Bunny
</form>
HTML Drop Down Lists
o Drop down menues are created with the <select> and <option> tags. <select> is the list
itself and each <option> is an available choice for the user.
<form method="post"
action="mailto:[email protected]"> College Degree?
<select name="degree">
<option>Choose One</option>
<option>Some High School</option>
<option>High School Degree</option>
</select>
</form>
<form method="post"
action="mailto:[email protected]"> Musical Taste
<select multiple name="music" size="4">
<option value="emo" selected>Emo</option>
<option value="metal/rock" >Metal/Rock</option>
<option value="hiphop" >Hip Hop</option><option value="ska" >Ska</option>
<option value="jazz" >Jazz</option>
</form>
HTML Tables
o The <table> tag is used to begin a table. Within a table element are the <tr> (table rows)
and
<td> (table columns) tags.
<table border="1">
<tr><td>Row 1 Cell 1</td><td>Row 1 Cell 2</td></tr>
<tr><td>Row 2 Cell 1</td><td>Row 2 Cell 2</td></tr>
</table>
o And now we will change the cellpadding of the table and remove the cellspacing
from the previous example.
1. Name:
Thename attribute specifies
thenameofaformwhichisusedtoreferenceelementsinaJavaScript.
2. Action:
The required action attribute specifies where to send the form‐data when
a form issubmitted.
<form action="URL"> Value : URL
Description : Where to send the form
data.
3. Method :
The method attribute specifies how to send form‐data (the form‐data is
sent to thepagespecified in the action attribute).
<form
method="get|post">
Value : get
Description : Default. Appends the form‐data to the URL in
name/value pairs:URL?name=value&name=value
Value : post
Description : Sends the form‐data as an HTTP post transaction.
4. Target
The target attribute specifies a name or a keyword that indicates where to
display the response that is received after submitting the form.
<form target="_blank|_self|_parent|_top|framename">
Value Description
_blank Theresponseisdisplayedinanewwindowortab
_self Theresponseisdisplayedinthesameframe(thisisdefault)
_parent Theresponseisdisplayedintheparentframe
_top Theresponseisdisplayedinthefullbodyofthewindow
framename Theresponseisdisplayedinanamedframe
What is CSS?
CSS stands for Cascading Style Sheets
Styles define how to display HTML elements
External Style Sheets can save a lot of work
External Style Sheets are stored in CSS files
Importance of CSS
CSS defines HOW HTML elements are to be displayed.
Styles are normally saved in external .css files. External style sheets enable you to
change theappearance and layout of all the pages in a Web site, just by editing one single
file.
Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended to simplify the
process of making web pages presentable.
CSS handles the look and feel part of a web page. Using CSS, you can control the color of the text, the
style of fonts, the spacing between paragraphs, how columns are sized and laid out, what background
images or colors are used, layout designs,variations in display for different devices and screen sizes as
well as a variety of other effects.
CSS is easy to learn and understand but it provides powerful control over the presentation of an HTML
document. Most commonly, CSS is combined with the markup languages HTML or XHTML.
Advantages of CSS
CSS saves time − You can write CSS once and then reuse same sheet in multiple HTML pages. You
can define a style for each HTML element and apply it to as many Web pages as you want.
Pages load faster − If you are using CSS, you do not need to write HTML tag attributes every time.
Just write one CSS rule of a tag and apply it to all the occurrences of that tag. So less code means
faster download times.
Easy maintenance − To make a global change, simply change the style, and all elements in all the
web pages will be updated automatically.
Superior styles to HTML − CSS has a much wider array of attributes than HTML, so you can give a
far better look to your HTML page in comparison to HTML attributes.
Multiple Device Compatibility − Style sheets allow content to be optimized for more than one
type of device. By using the same HTML document, different versions of a website can be
presented for handheld devices such as PDAs and cell phones or for printing.
Global web standards − Now HTML attributes are being deprecated and it is being recommended
to use CSS. So its a good idea to start using CSS in all the HTML pages to make them compatible to
future browsers.