HTML
HTML
• HTML is an acronym which stands for Hyper Text Markup Language which
is used for creating web pages and web applications. Let's see what is
meant by Hypertext Markup Language, and Web page.
• Hyper Text: HyperText simply means "Text within Text." A text has a link
within it, is a hypertext. Whenever you click on a link which brings you to a
new webpage, you have clicked on a hypertext. HyperText is a way to link
two or more web pages (HTML documents) with each other.
• Markup language: A markup language is a computer language that is used
to apply layout and formatting conventions to a text document. Markup
language makes text more interactive and dynamic. It can turn text into
images, tables, links, etc.
• Web Page: A web page is a document which is commonly written in HTML
and translated by a web browser. A web page can be identified by entering
an URL. A Web page can be of the static or dynamic type. With the help of
HTML only, we can create static web pages.
• Hence, HTML is a markup language which is used for creating attractive
web pages with the help of styling, and which looks in a nice format on a
web browser. An HTML document is made of many HTML tags and each
HTML tag contains different content.
EXAMPLE
<!DOCTYPE>
<html>
<head>
<title>Web page title</title>
</head>
<body>
<h1>Write Your First Heading</h1>
<p>Write Your First Paragraph.</p>
</body>
</html>
Description of HTML Example
• <!DOCTYPE>: It defines the document type or it instruct the browser
about the version of HTML.
• <html > :This tag informs the browser that it is an HTML document. Text
between html tag describes the web document. It is a container for all
other elements of HTML except <!DOCTYPE>
• <head>: It should be the first element inside the <html> element, which
contains the metadata(information about the document). It must be
closed before the body tag opens.
• <title>: As its name suggested, it is used to add title of that HTML page
which appears at the top of the browser window. It must be placed inside
the head tag and should close immediately. (Optional)
• <body> : Text between body tag describes the body content of the page
that is visible to the end user. This tag contains the main content of the
HTML document.
• <h1> : Text between <h1> tag describes the first level heading of the
webpage.
• <p> : Text between <p> tag describes the paragraph of the webpage.
•
Building blocks of HTML
• An HTML document consist of its basic building blocks
which are:
– Tags: An HTML tag surrounds the content and apply
meaning to it. It is written between < and > brackets.
– Attribute: An attribute in HTML provides extra information
about the element, and it is applied within the start tag.
An HTML attribute contains two fields: name & value.
– Syntax
– <tag name attribute_name= " attr_value"> content </ tag
name>
– Elements: An HTML element is an individual component of
an HTML file. In an HTML file, everything written within
tags are termed as HTML elements.
EXAMPLE
<!DOCTYPE html>
<html>
<head>
<title>The basic building blocks of HTML</title>
</head>
<body>
<h2>The building blocks</h2>
<p>This is a paragraph tag</p>
<p style="color: red">The style is attribute of paragraph tag</p>
<span>The element contains tag, attribute and content</span>
</body>
</html>
HTML Tags
• HTML tags are like keywords which defines that how web browser will format and
display the content. With the help of tags, a web browser can distinguish between
an HTML content and a simple content. HTML tags contain three main parts:
opening tag, content and closing tag. But some HTML tags are unclosed tags.
• When a web browser reads an HTML document, browser reads it from top to
bottom and left to right. HTML tags are used to create HTML documents and
render their properties. Each HTML tags have different properties.
• An HTML file must have some essential tags so that web browser can differentiate
between a simple text and HTML text. You can use as many tags you want as per
your code requirement.
• All HTML tags must enclosed within < > these brackets.
• Every tag in HTML perform different tasks.
• If you have used an open tag <tag>, then you must use a close tag </tag> (except
some tags)
• Syntax
• <tag> content </tag>
•
EXAMPLES
• <p> Paragraph Tag </p>
• <h2> Heading Tag </h2>
• <b> Bold Tag </b>
• <i> Italic Tag </i>
• <u> Underline Tag</u>
HTML Attribute
• HTML attributes are special words which provide additional
information about the elements or attributes are the modifier of
the HTML element.
• Each element or tag can have attributes, which defines the
behaviour of that element.
• Attributes should always be applied with start tag.
• The Attribute should always be applied with its name and value
pair.
• The Attributes name and values are case sensitive, and it is
recommended by W3C that it should be written in Lowercase only.
• You can add multiple attributes in one HTML element, but need to
give space between two attributes.
• Syntax
<element attribute_name="value">content</element>
EXAMPLE
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1> This is Style attribute</h1>
<p style="height: 50px; color: blue">It will add style pro
perty in element</p>
<p style="color: red">It will change the color of content
</p>
</body>
</html>
HTML Elements
• An HTML file is made of elements. These elements are
responsible for creating web pages and define content
in that webpage. An element in HTML usually consist of
a start tag <tag name>, close tag </tag name> and
content inserted between them. Technically, an
element is a collection of start tag, attributes, end
tag, content between them.
• Note: Some elements does not have end tag and
content, these elements are termed as empty elements
or self-closing element or void elements.
• Such as:
<p> Hello world!!! </p>
EXAMPLE
<!DOCTYPE html>
<html>
<head>
<title>WebPage</title>
</head>
<body>
<h1>This is my first web page</h1>
<h2> How it looks?</h2>
<p>It looks Nice!!!!!</p>
</body>
</html>
HTML Formatting
• HTML Formatting is a process of formatting text
for better look and feel. HTML provides us ability
to format text without using CSS. There are many
formatting tags in HTML. These tags are used to
make text bold, italicized, or underlined. There
are almost 14 options available that how text
appears in HTML and XHTML.
• In HTML the formatting tags are divided into two
categories:
– Physical tag: These tags are used to provide the visual
appearance to the text.
– Logical tag: These tags are used to add some logical or
semantic value to the text.
HTML FORMATTING TAGS
• <b>This is a physical tag, which is used to bold
the text written between it.
• <strong>This is a logical tag, which tells the
browser that the text is important.
• <i>This is a physical tag which is used to make
text italic.
• <u>This tag is used to underline text written
between it.
• <sup>It displays the content slightly above the
normal line.<sub>It displays the content slightly
below the normal line.
HTML Heading
• A HTML heading or HTML h tag can be defined as a title or a subtitle which you want to
display on the webpage. When you place the text within the heading tags <h1>.........</h1>, it
is displayed on the browser in the bold format and size of the text depends on the number of
heading.
• There are six different HTML headings which are defined with the <h1> to <h6> tags, from
highest level h1 (main heading) to the least level h6 (least important heading).
• h1 is the largest heading tag and h6 is the smallest one. So h1 is used for most important
heading and h6 is used for least important.
• Headings in HTML helps the search engine to understand and index the structure of web
page.
• Note: The main keyword of the whole content of a webpage should be display by h1 heading
tag.
• See this example: