ࡱ > 3 O Q 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N o q s u w y { } A c '` p bjbjLULU 7( .? .? ( G z z z z z z z r r r 8 . /M j @ N ) ) ) L L L L L L L N h =Q h L z ) ) L z z N L z z N L L 5 z z : @?uw r P 7 8 ^B t
L 0 /M 8 x Q Q p : : Q z &; 8 ) 9 A ) ) ) L L X ) ) ) /M r r z z z z z z What is an HTML File?
HTML stands for Hyper Text Markup Language
An HTML file is a text file containing small markup tags
The markup tags tell the Web browser how to display the page
An HTML file must have an htm or html file extension
An HTML file can be created using a simple text editor
If you are running Windows, start Notepad.
Type in the following text:
Title of page
This is my first homepage. This text is bold
Save the file as "mypage.htm".
Start your Internet browser. Select "Open" (or "Open Page") in the File menu of your browser. A dialog box will appear. Select "Browse" (or "Choose File") and locate the HTML file you just created - "mypage.htm" - select it and click "Open". Now you should see an address in the dialog box, for example "C:\MyDocuments\mypage.htm". Click OK, and the browser will display the page.
Example Explained
The first tag in your HTML document is . This tag tells your browser that this is the start of an HTML document. The last tag in your document is . This tag tells your browser that this is the end of the HTML document.
The text between the tag and the tag is header information. Header information is not displayed in the browser window.
The text between the tags is the title of your document. The title is displayed in your browser's caption.
The text between the tags is the text that will be displayed in your browser.
The text between the and tags will be displayed in a bold font.
HTM or HTML Extension?
When you save an HTML file, you can use either the .htm or the .html extension. We have used .htm in our examples. It might be a bad habit inherited from the past when some of the commonly used software only allowed three letter extensions.
With newer software we think it will be perfectly safe to use .html.
HTML documents are text files made up of HTML elements.
HTML elements are defined using HTML tags.
HTML Tags
HTML tags are used to mark-up HTML elements
HTML tags are surrounded by the two characters < and >
The surrounding characters are called angle brackets
HTML tags normally come in pairs like and
The first tag in a pair is the start tag, the second tag is the end tag
The text between the start and end tags is the element content
HTML tags are not case sensitive, means the same as
HTML Elements
Remember the HTML example from the previous page:
Title of page
This is my first homepage. This text is bold
This is an HTML element:
This text is boldThe HTML element starts with a start tag: The content of the HTML element is: This text is boldThe HTML element ends with an end tag:
The purpose of the tag is to define an HTML element that should be displayed as bold.
This is also an HTML element:
This is my first homepage. This text is bold
This HTML element starts with the start tag , and ends with the end tag .
The purpose of the tag is to define the HTML element that contains the body of the HTML document.
Why do we Use Lowercase Tags?
We have just said that HTML tags are not case sensitive: means the same as . When you surf the Web, you will notice that most tutorials use uppercase HTML tags in their examples. We always use lowercase tags. Why?
If you want to prepare yourself for the next generations of HTML, you should start using lowercase tags. The World Wide Web Consortium (W3C) recommends lowercase tags in their HTML 4 recommendation, and XHTML (the next generation HTML) demands lowercase tags.
Tag Attributes
Tags can have attributes. Attributes can provide additional information about the HTML elements on your page.
This tag defines the body element of your HTML page: . With an added bgcolor attribute, you can tell the browser that the background color of your page should be red, like this: .
This tag defines an HTML table:
. With an added border attribute, you can tell the browser that the table should have no borders:
Attributes always come in name/value pairs like this: name="value".
Attributes are always added to the start tag of an HTML element.
Attribute values should always be enclosed in quotes. Double style quotes are the most common, but single style quotes are also allowed.
In some rare situations, like when the attribute value itself contains quotes, it is necessary to use single quotes:
name='John "ShotGun" Nelson'
There are different tags used for creating different web pages. Tags are explained in details, as follows:
BASIC HTML TAGS
&
It defines an HTML document and it is required to be written in the starting of the HTML document.
&
It defines the body of a HTML document. Any thing written between these two tags will be considered as the main document to be displayed.
to
&
to
It defines the headings in different sizes.
defines the largest heading.
defines the smallest heading.
&
It defines the paragraph. HTML automatically adds an extra blank line before and after a paragraph.
&
It defines a horizontal rule.
It inserts a single line break. It is used when we want to end a line but not when we want to start a new paragraph.
The tag is an empty tag. It has no closing tag.
EXAMPLES ON BASIC HTML TAGS
1. & tags
Text written in notepad:
this Is the first web page !
hello world!
Browser window:
2.
to
& tags
Text written in notepad:
this Is the first web page !
this Is the first web page !
this Is the first web page !
this Is the first web page !
this Is the first web page !
this Is the first web page !
Browser window:
3.
tag
Text written in notepad:
this is text 1 in a paragraph.
this is text 2 in paragraph.
this is text 3 in paragraph.
Paragraph elements are defined by the p tag.
Browser window:
4. tag
Text written in notepad:
this is text 1 in a paragraph.
This is text 2 in paragraph.
this is text 3 in paragraphs.
Paragraph elements are defined by the p tag.
Second, third & fourth
text after horizontal rule inserted
Browser window:
TEXT FORMATTING TAGS
a) &
It defines bold text in a HTML document.
&
It defines bold text in a HTML document.
&
It emphasis the text in a HTML document. .
&
It defines text in italics in a HTML document.
&
It defines small text in a HTML document.
&
It defines subscripted text in a HTML document.
&
It defines superscripted text in a HTML document.
&
It is used to change the font, color and type of the text in HTML document.
EXAMPLES ON TEXT FORMATTING HTML TAGS
1. All formatting tags except tag
Text written in notepad:
This text is bold
This text is strong
This text is big
This text is emphasized
This text is italic
This text is small
This text contains subscript
eg : H 20
This text contains superscript
eg : 02-
Browser window:
2. tag
There are two methods by which we can format the text in HTML document.
First, by using the font tag and second, by using style attribute an any of the tags used in HTML document.
a) USING TAG
Font tag has different attributes. By using these attributes we can change the color, font and type of the text in the HTML document.
Different attributes used are:
Font Attributes
Attribute = ValueExamplePurposeSize="number"size="2"Defines the font sizeSize="+number"size="+1"Increases the font sizeSize="-number"size="-1"Decreases the font sizeFace="face-name"face="Times"Defines the font-nameColor="color-value"color="#eeff00"Defines the font colorColor="color-name"color="red"Defines the font color
i) How to change font, color and type of the text
Text written in notepad:
This is a paragraph.
This is another paragraph.
Browser window:
ii) How to change only font of the text
Text written in notepad:
This is a paragraph.
This is another paragraph.
Browser window:
NOTE: Similarly if only color & type of the text needs to be changed then only that attribute is used in the font tag.
b) USING style ATTRIBUTE
style attribute can be used in any tag in order to format the text in the HTML document.
USING style ATTRIBUTE IN THE
TAG
Text written in notepad:
This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it.
This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it.
This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it.
Browser window:
Similarly we can use style attribute in any other tag like in
,
, etc. except in tag.
Style attribute is mostly used for formatting the text.
LINK TAGS
Link tag is used to link one web page with another web page or file.
&
It is called as anchor tag which is used to create a link.
An anchor can point to any resource on the web: HTML page, an image, a sound file , a movie, etc.
The syntax of creating an anchor:
Text to be displayedThe href Attribute
The href attribute is used to address the document to link to, and the words between the open and close of the anchor tag will be displayed as a hyperlink.
This anchor defines a link to www.mait.com:
it is our college!The Target Attribute
With the target attribute, you can define where the linked document will be opened.
The line below will open the document in a new browser window:
Visit W3Schools!Basic Notes - Useful Tips
Always add a trailing slash to subfolder references. If you link like this: href="http://www.mait.com/html", you will generate two HTTP requests to the server, because the server will add a slash to the address and create a new request like this: href="http://www.mait.com/html/"
Named anchors are often used to create "table of contents" at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.
If a browser cannot find a named anchor thathas been specified, it goes to the top of the document. No error occurs.
Text written in notepad:
tag and href attribute
hello world !
please click here to open the university web site!!!!!!!!!!
Browser window:
On clicking the above link the page will be opened on the same page by refreshing the previous page.
The page opened will be:
tag and href attribute
Text written in notepad:
hello world !
please click here to open the university web site!!!!!!!!!!
Browser window:
On clicking the above link the page will be opened on the other blank page without refreshing the previous page.
The page opened will be:
NOTE: To open any other file on clicking the link then write the
Address of that file as the value of the href attribute.