Professional Documents
Culture Documents
HTML
Html stands for Hyper Text Markup Language. Html mainly use for design a client side web pages, this
is a static page it means you can only view Html page not give request and not get response from
server. Using Html pages browser get user information through form (This is an Html element). Html
provides so many elements (like <p>, <img>, <h1>) to design a web page.
Hypertext: Hyper Text simply means "Text within Text". A text has a link within it. The
hypertext pages are interconnected by hyperlinks, when mouse click on these link which brings you to a
new webpage. A language that is used to define elements in a document or Web page by embedding codes (tags) surrounded by
common start and stop characters. For example, the tags in SGML, HTML, XML and WML all use the less-than
symbol (<) to start the tag and a greater-than symbol (>) to end it.
Markup language: Any tag based language known as markup language, for example gml, sgml, html,
xml etc.
Tim Berners-Lee
Focus Abhishek you can do it …
Tim Berners-Lee is known as father of Html. The first publicly available description of HTML was a document called "HTML
Html is platform independent language, it can be run on any platform like window, linux, Mac.
Each and every elements of html should be enclosed within the angular brackets (<>).
HTML TAG
Html Tag
Html Tag HTML tags contain three main parts: opening tag, content and closing tag.
But some HTML tags are unclosed tags.
Syntax
HTML Tag Examples
Note: HTML is not case sensitive language so you can write Html Tags in lowercase or uppercase letters. Some Html
<p>
Focus Abhishek you can do it …
Paragraph Tag
</p>
<h2>
Heading Tag
</h2>
<b>Bold Tag</b>
<u>Underline Tag</u>
<i>Italic Tag </i>
Some Html tags are not closed, for example<br>, <hr>, <img> etc.
<br> Tag: br stands for break line, it breaks the line of the code.
Html br tag
<br> tag are use for give the line break within any text line.
Example
<html>
<body>
</body>
</html>
Result
I am happy.
<hr> Tag: hr stands for Horizontal Rule. This tag is used to put a line across the webpage.
Html hr tag
<hr> (Horizontal Rules) tag are used for to create a horizontal line on html page. <hr> are used for separate the content
on html page.
Focus Abhishek you can do it …
Example
<hr/>
Result
<img> Tag: img tag are use for display image on web page.
Meta tag
<meta> tag provides all information related to web page like author name, keyword for search engine, description about what things page contain. By using
meta tag (<meta>) you can also refresh your web page within regular interval of time.
Example
<html>
<head>
</head>
<body>
</body>
</html>
<style> tag are used for define CSS styles required for the page. It must be inside the <head> tag.
Syntax
Focus Abhishek you can do it …
<!DOCTYPE>
<html>
<style>
.para
color:red;
<style>
<body>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Try it Yourself »
Example Explained
Web Browsers
The purpose of a web browser (Chrome, IE, Firefox, Safari) is to read HTML documents and display them.
The browser does not display the HTML tags, but uses them to determine how to display the document:
Title tag
<title> tag are used for provide the title of you web page. Title are show top of the web page. Title tag
are most useful in case of seo. Using page title search engine easily find you page on web. Each page
Result
<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Note: Only the content inside the <body> section (the white area above) is displayed in a browser.
It must only appear once, at the top of the page (before any HTML tags).
<!DOCTYPE html>
HTML Versions
Since the early days of the web, there have been many versions of HTML:
Version Year
HTML 1991
XHTML 2000
HTML5 2014
HTML Links
HTML links are defined with the <a> tag:
Example
<a href="https://www.w3schools.com">This is a link</a>
Try it Yourself »
HTML Images
HTML images are defined with the <img> tag.
The source file (src), alternative text (alt), width, and height are provided as attributes:
Example
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
Try it Yourself »
HTML Formatting
HTML Formatting
HTML Formatting is a process of formatting text for better look and feel. There are many formatting
tags in HTML. These tags are used to make text bold, italicized, or underlined. There are almost 12
options available that how text appears in HTML and XHTML.
1) Bold Text
Output:
2) Italic Text
If you write anything within <i>............</i> element, is shown in italic letters.
Output:
If you want to mark or highlight a text, you should write the content within <mark>.........</mark>.
Output:
4) Underlined Text
If you write anything within <u>.........</u> element, is shown in underlined text.
Output:
5) Strike Text
Anything written within <strike>.......................</strike> element is displayed with
strikethrough. It is a thin line which cross the statement.
Output:
6) Monospaced Font
If you want that each letter has the same width then you should write the content within
<tt>.............</tt> element.
Note: We know that most of the fonts are known as variable-width fonts because different letters have
different width. (for example: 'w' is wider than 'i'). Monospaced Font provides similar space among
every letter.
Output:
7) Superscript Text
If you put the content within <sup>..............</sup> element, is shown in superscript ; means it is
displayed half a character's height above the other characters.
Output:
8) Subscript Text
If you put the content within <sub>..............</sub> element, is shown in subscript ;
means it is displayed half a character's height below the other characters.
Output:
9) Deleted Text
Anything that puts within <del>..........</del> is displayed as deleted text.
Output:
Output:
Output:
If you want to put your font size smaller than the rest of the text then put the
content within <small>.........</small>tag. It reduces one font size than the
previous one.
Output:
used to wrap other Html page elements and divides the Html documents into sections. Suppose on your web page
lot of Html elements like <p>, <h2> and <img> and you want to separate these elements from others elements then
Mostly <div> are used for divide complete page into section like footer, header, left, right section.
Example
<html>
Focus Abhishek you can do it …
<body>
<div style="background:#00FF99">
</div>
<div style="background:#FFCAFF">
</div>
<div style="background:#66FFFF">
</div>
</body>
</html>
Result
Heading in a div
Text in a div.
Heading in a div
Text in a div.
Heading in a div
Text in a div.
pre tag
<pre> tag are show text on web page as it is written on html page including break line, number of
space. In Html if you enter more than one space between two text it not show on browser only single
space display, for show all given space you need to use <pre> tag.
Focus Abhishek you can do it …
If we give line brake or number of space between text it ignored by browser only show single space
Example
<html>
<head>
<p>
</p>
</body>
</html>
Result
In above example spaces are not display on web page and also not display break line.
<pre> tag are show text on web page as it is written on page including break line, number of space.
Example
<html>
<head>
<pre>
</pre>
</body>
</html>
Result
HTML Attributes
Focus Abhishek you can do it …
HTML Attributes
All HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like: name="value"
Example
<a href="https://www.w3schools.com">This is a link</a>
Try it Yourself »
Example
<img src="img_girl.jpg">
Try it Yourself »
Example
<img src="img_girl.jpg" width="500" height="600">
Try it Yourself »
The image size is specified in pixels: width="500" means 500 pixels wide.
Focus Abhishek you can do it …
The value of the attribute can be read by screen readers. This way, someone "listening" to the
webpage, e.g. a blind person, can "hear" the element.
Example
<img src="img_girl.jpg" alt="Girl with a jacket">
Try it Yourself »
The alt attribute is also useful if the image does not exist:
Example
Try it Yourself »
Example
<p style="color:red">I am a paragraph</p>
Try it Yourself »
You will learn more about styling later in this tutorial, and in our CSS Tutorial.
Declaring a language is important for accessibility applications (screen readers) and search engines:
<!DOCTYPE html>
<html lang="en-US">
<body>
...
Focus Abhishek you can do it …
</body>
</html>
The first two letters specify the language (en). If there is a dialect, use two more letters (US).
Example
<p title="I'm a tooltip">
This is a paragraph.
</p>
Try it Yourself »
The title attribute can be written with uppercase or lowercase like title or TITLE.
W3C recommends lowercase in HTML, and demands lowercase for stricter document types like XHTML.
Example
<a href=https://www.w3schools.com>
Try it Yourself »
W3C recommends quotes in HTML, and demands quotes for stricter document types like XHTML.
Sometimes it is necessary to use quotes. This example will not display the title attribute correctly, because it contains a space:
Example
<p title=About W3Schools>
Try it Yourself »
Focus Abhishek you can do it …
Using quotes are the most common. Omitting quotes can produce errors.
At W3Schools we always use quotes around attribute values.
In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes:
Or vice versa:
Chapter Summary
All HTML elements can have attributes
The title attribute provides additional "tool-tip" information
The href attribute provides address information for links
The width and height attributes provide size information for images
The alt attribute provides text for screen readers
At W3Schools we always use lowercase attribute names
At W3Schools we always quote attribute values with double quotes
HTML Attributes
Below is an alphabetical list of some attributes often used in HTML:
Attribute Description
alt Specifies an alternative text for an image, when the image cannot be displayed
HTML Heading
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.
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.
Output:
Heading no. 1
Heading no. 2
Focus Abhishek you can do it …
Heading no. 3
Heading no. 4
Heading no. 5
Heading no. 6
Heading elements (h1....h6) should be used for headings only. They should not be used just to make text bold or big.
Bigger Headings
Each HTML heading has a default size. However, you can specify the size for any heading with the style attribute:
Example
<h1 style="font-size:60px;">Heading 1</h1>
Try it Yourself »
The <head> element is a container for metadata. HTML metadata is data about the HTML document. Metadata is not displayed.
The <head> element is placed between the <html> tag and the <body> tag:
Example
<!DOCTYPE html>
<html>
<head>
<title>My First HTML</title>
<meta charset="UTF-8">
</head>
<body>
.
.
.
Try it Yourself »
Note: Metadata typically define the document title, character set, styles, links, scripts, and other meta information.
Have you ever seen a Web page and wondered "Hey! How did they do that?"
To find out, right-click in the page and select "View Page Source" (in Chrome) or "View Source" (in IE), or similar in other browsers.
This will open a window containing the HTML source code of the page.
Right-click on an element (or a blank area), and choose "Inspect" or "Inspect Element" to see what elements are made up of (you
will see both the HTML and the CSS). You can also edit the HTML or CSS on-the-fly in the Elements or Styles panel that opens.
You will learn more about HTML tags and attributes in the next chapters of this tutorial.
Tag Description
<head> A container for all the head elements (title, scripts, styles, meta information, and more)
HTML Paragraphs
The HTML <p> element defines a paragraph:
Focus Abhishek you can do it …
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
Try it Yourself »
Note: Browsers automatically add some white space (a margin) before and after a paragraph.
HTML Display
You cannot be sure how HTML will be displayed.
Large or small screens, and resized windows will create different results.
With HTML, you cannot change the output by adding extra spaces or extra lines in your HTML code.
The browser will remove any extra spaces and extra lines when the page is displayed:
Example
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser
ignores it.
</p>
<p>
This paragraph
contains a lot of spaces
in the source code,
but the browser
ignores it.
</p>
Try it Yourself »
HTML Styles
Example
I am Red
I am Blue
I am Big
Try it Yourself »
Focus Abhishek you can do it …
<tagname style="property:value;">
Example
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
Example
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
Try it Yourself »
HTML Fonts
The font-family property defines the font to be used for an HTML element:
Example
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
Try it Yourself »
The font-size property defines the text size for an HTML element:
Example
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
Try it Yourself »
Example
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>
Try it Yourself »
Chapter Summary
Use the style attribute for styling HTML elements
Use background-color for background color
Use color for text colors
Use font-family for text fonts
Use font-size for text sizes
Use text-align for text alignment
Text Formatting
This text is bold
Try it Yourself »
HTML also defines special elements for defining text with a special meaning.
HTML uses elements like <b> and <i> for formatting output,
like bold or italic text.
Example
<b>This text is bold</b>
Try it Yourself »
The HTML <strong> element defines strong text, with added semantic
"strong" importance.
Focus Abhishek you can do it …
Example
<strong>This text is strong</strong>
Try it Yourself »
Example
<i>This text is italic</i>
Try it Yourself »
The HTML <em> element defines emphasized text, with added semantic
importance.
Example
<em>This text is emphasized</em>
Try it Yourself »
Note: Browsers display <strong> as <b>, and <em> as <i>. However, there is
a difference in the meaning of these tags: <b> and <i> defines bold and italic
text, but <strong> and <em> means that the text is "important".
Example
<h2>HTML <small>Small</small> Formatting</h2>
Try it Yourself »
Example
<h2>HTML <mark>Marked</mark> Formatting</h2>
Try it Yourself »
Example
<p>My favorite color is <del>blue</del> red.</p>
Try it Yourself »
Example
<p>My favorite <ins>color</ins> is red.</p>
Focus Abhishek you can do it …
Try it Yourself »
Example
<p>This is <sub>subscripted</sub> text.</p>
Try it Yourself »
Example
<p>This is <sup>superscripted</sup> text.</p>
Try it Yourself »
Tag Description
Quotation
For 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF
works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million
globally.
Try it Yourself »
Example
<p>WWF's goal is to: <q>Build a future where people live in harmony with nature.</q></p>
Try it Yourself »
Example
<p>Here is a quote from WWF's website:</p>
<blockquote cite="http://www.worldwildlife.org/who/index.html">
For 50 years, WWF has been protecting the future of nature.
The world's leading conservation organization,
WWF works in 100 countries and is supported by
1.2 million members in the United States and
close to 5 million globally.
</blockquote>
Try it Yourself »
Marking abbreviations can give useful information to browsers, translation systems and search-engines.
Example
<p>The <abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>
Try it Yourself »
The <address> element is usually displayed in italic. Most browsers will add a line break before and after the element.
Example
<address>
Written by John Doe.<br>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>
Try it Yourself »
Example
<p><cite>The Scream</cite> by Edvard Munch. Painted in 1893.</p>
Try it Yourself »
Example
<bdo dir="rtl">This text will be written from right to left</bdo>
Focus Abhishek you can do it …
Try it Yourself »
Tag Description
HTML Comments
Comment tags are used to insert comments in the HTML source code.
Notice that there is an exclamation point (!) in the opening tag, but not in the closing tag.
Note: Comments are not displayed by the browser, but they can help document your HTML source code.
With comments you can place notifications and reminders in your HTML:
Example
<!-- This is a comment -->
<p>This is a paragraph.</p>
Try it Yourself »
Comments are also great for debugging HTML, because you can comment out HTML lines of code, one at a time, to search for
errors:
Example
<!-- Do not display this at the moment
<img border="0" src="pic_mountain.jpg" alt="Mountain">
-->
Try it Yourself »
HTML Colors
HTML colors are specified using predefined color names, or RGB, HEX, HSL,
RGBA, HSLA values.
Color Names
In HTML, a color can be specified by using a color name:
Tomato
Focus Abhishek you can do it …
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
LightGray
Try it Yourself »
Background Color
You can set the background color for HTML elements:
Focus Abhishek you can do it …
Hello World
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi
enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis
nisl ut aliquip ex ea commodo consequat.
Example
<h1 style="background-color:DodgerBlue;">Hello World</h1>
<p style="background-color:Tomato;">Lorem ipsum...</p>
Try it Yourself »
Text Color
You can set the color of text:
Hello World
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
lobortis nisl ut aliquip ex ea commodo consequat.
Example
<h1 style="color:Tomato;">Hello World</h1>
<p style="color:DodgerBlue;">Lorem ipsum...</p>
<p style="color:MediumSeaGreen;">Ut wisi enim...</p>
Try it Yourself »
Focus Abhishek you can do it …
Border Color
You can set the color of borders:
Hello World
Hello World
Hello World
Example
<h1 style="border:2px solid Tomato;">Hello World</h1>
<h1 style="border:2px solid DodgerBlue;">Hello World</h1>
<h1 style="border:2px solid Violet;">Hello World</h1>
Try it Yourself »
Color Values
In HTML, colors can also be specified using RGB values, HEX values, HSL
values, RGBA values, and HSLA values:
#ff6347
Example
<h1 style="background-color:rgb(255, 99, 71);">...</h1>
<h1 style="background-color:#ff6347;">...</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">...</h1>
Try it Yourself »
RGB Value
In HTML, a color can be specified as an RGB value, using this formula:
For example, rgb(255, 0, 0) is displayed as red, because red is set to its highest
value (255) and the others are set to 0.
To display the color black, all color parameters must be set to 0, like this:
rgb(0, 0, 0).
To display the color white, all color parameters must be set to 255, like this:
rgb(255, 255, 255).
Focus Abhishek you can do it …
255
GREEN
99
BLUE
71
Example
rgb(255, 0, 0)
rgb(0, 0, 255)
rgb(255, 165, 0)
Focus Abhishek you can do it …
Try it Yourself »
Shades of gray are often defined using equal values for all the 3 light sources:
Example
rgb(0, 0, 0)
Try it Yourself »
Focus Abhishek you can do it …
HEX Value
In HTML, a color can be specified using a hexadecimal value in the form:
#rrggbb
Where rr (red), gg (green) and bb (blue) are hexadecimal values between 00
and ff (same as decimal 0-255).
For example, #ff0000 is displayed as red, because red is set to its highest value
(ff) and the others are set to the lowest value (00).
Example
#ff0000
#0000ff
#3cb371
#ee82ee
#ffa500
Focus Abhishek you can do it …
#6a5acd
Try it Yourself »
Shades of gray are often defined using equal values for all the 3 light sources:
Example
#000000
#3c3c3c
#787878
#b4b4b4
#f0f0f0
#ffffff
Try it Yourself »
Focus Abhishek you can do it …
HSL Value
In HTML, a color can be specified using hue, saturation, and lightness (HSL) in
the form:
Example
Try it Yourself »
Saturation
Saturation can be described as the intensity of a color.
50% is 50% gray, but you can still see the color.
Example
Try it Yourself »
Lightness
The lightness of a color can be described as how much light you want to give
the color, where 0% means no light (black), 50% means 50% light (neither
dark nor light) 100% means full lightness (white).
Example
Try it Yourself »
Shades of gray are often defined by setting the hue and saturation to 0, and
adjust the lightness from 0% to 100% to get darker/lighter shades:
Example
Try it Yourself »
RGBA Value
RGBA color values are an extension of RGB color values with an alpha channel -
which specifies the opacity for a color.
Example
Try it Yourself »
HSLA Value
HSLA color values are an extension of HSL color values with an alpha channel -
which specifies the opacity for a color.
Example
Try it Yourself »