Lab 14 HTML
Lab 14 HTML
Lab 14 HTML
Practical No. 14
HTML – OVERVIEW
HTML stands for Hypertext Markup Language, and it is the most widely used language to write Web
Pages.
Hypertext refers to the way in which Web pages (HTML documents) are linked together. Thus,
the link available on a webpage is called Hypertext.
As its name suggests, HTML is a Markup Language which means you use HTML to simply
"mark-up" a text document with tags that tell a Web browser how to structure it to display.
1
BASIC HTML DOCUMENT
HTML TAGS
HTML use various tags to format the content. These tags are enclosed within angle braces <Tag Name>.
Most of the tags have their corresponding closing tags. For example, <html> has its closing tag </html>
and <body> tag has its closing tag </body> tag etc.
HEADING TAGS
Any document starts with a heading. You can use different sizes for your headings. HTML also has six
levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>. While displaying
any heading, browser adds one line before and one line after that heading.
2
PARAGRAPH TAG
The <p> tag offers a way to structure your text into different paragraphs. Each paragraph of text should
go in between an opening <p> and a closing </p> tag as shown below in the example –
3
CENTERING CONTENT
You can use <center> tag to put any content in the center of the page or any table cell.
HORIZONTAL LINES
Horizontal lines are used to visually break-up sections of a document. The <hr> tag creates a line from the
current position in the document to the right margin and breaks the line accordingly.
HTML ATTRIBUTE
An attribute is used to define the characteristics of an HTML element and is placed inside the element's
opening tag. All attributes are made up of two parts − a name and a value.
The Name is the property you want to set. For example, the paragraph <p> element in the
example carries an attribute whose name is align, which you can use to indicate the alignment of
paragraph on the page.
The Value is what you want the value of the property to be set and always put within quotations.
The below example shows three possible values of align attribute: left, center and right.
CORE ATTRIBUTES
The four core attributes that can be used on the majority of HTML elements (although not all) are:
4
i) Id
ii) Title
iii) Class
iv) Style
The Id Attribute
The id attribute of an HTML tag can be used to uniquely identify any element within an HTML page.
The title attribute gives a suggested title for the element. The behavior of this attribute will depend upon
the element that carries it, although it is often displayed as a tooltip when cursor comes over the element
or while the element is loading.
The class attribute is used to associate an element with a style sheet and specifies the class of element.
The Style Attribute
The style attribute allows you to specify Cascading Style Sheet (CSS) rules within the element.
HTML - FORMATTING
Bold Text
Strike Text
5
Anything that appears within <strike>...</strike> element is displayed with strikethrough.
Superscript Text
The content of the <big>...</big> element is displayed one font size larger than the rest of the text
surrounding it.
Smaller Text
The content of the <small>...</small> element is displayed one font size smaller than the rest of the text
surrounding it.
Comments
HTML – LISTS
6
HTML offers web authors three ways for specifying lists of information. All lists must contain one or
more list elements. Lists may contain:
<ul> − An unordered list. This will list items using plain bullets.
<ol> − An ordered list. This will use different schemes of numbers to list your items.
<dl> − A definition list. This arranges your items in the same way as they are arranged in a
dictionary.
An unordered list is a collection of related items that have no special order or sequence. This list is
created by using HTML <ul> tag. Each item in the list is marked with a bullet.
If you are required to put your items in a numbered list instead of bulleted, then HTML ordered list will
be used. This list is created by using <ol> tag. The numbering starts at one and is incremented by one for
each successive ordered list element tagged with <li>.
7
3. HTML Definition Lists
HTML supports a list style which is called definition lists where entries are listed like in a dictionary or
encyclopedia. The definition list is the ideal way to present a glossary, list of terms, or other name/value
list.
Definition List makes use of following three tags.
<dl> − Defines the start of the list
<dt> − A term
<dd> − Term definition
</dl> − Defines the end of the list
EXERCISE
1. Explain and use following attributes of tables in HTML:
a. Cellpadding and Cellspacing
b. Colspan and Rowspan
c. Table Background
d. Table caption
e. Table Height and Width.
2. Change the Numbering order of list to A, B, C,… and So on.
3. Explain and use <img> tag.