HTML
HTML
-> HTML is the standard markup language for creating web pages.
-> HTML invented by Tim Berners-Lee.
-> HTML stands for Hyper Text Markup Language.
-> HTML describes the structure of a web page.
-> HTML is not case sensitive.
<!DOCTYPE html>
<html>
<head>
<title> Page Title </title>
</head>
<body>
<h1> My First Heading</h1>
<p> My First Paragraph </p>
</body>
</html>
HTML Element:
An HTML element is defined by a start tag, some content and an end tag.
The HTML element is everything from the start tag to the end tag.
Suppose <br> is start tag but it do not have end tag so it is called empty
element.
Web Browsers:
<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
HTML Documents:
All HTML documents must start with a document type declaration: <!
DOCTYPE html>.
The HTML document itself begins with <html> and ends with </html>.
The visible part of the HTML document is between <body> and </body>.
-> <!DOCTYPE> must only appear once at the top of the page (before any
html tags).
-> HTML headings are defined with the <h1> to <h6> tags.
-> <h1> defines the most important heading, <h6> defines the least important
heading.
HTML Links:
HTML Images:
HTML Elements:
An HTML element is defined by a start tag, some content, and an end tag.
<!DOCTYPE html>
<html>
<body>
<h1> My First Heading </h1>
<p> My First Paragraph </p>
</body>
</html>
HTML Attributes:
<a> tag defines a hyper link. The href attribute specifies the url of the page
the link.
The <img> tag is used to embed an image in an HTML Page. The src attribute
specifies the path to the image to be displayed.
<img src=“img_girl.jpg”>
The <img> tag should also contain the width and height attributes, which
specify the width and height of the image (in pixels).
<img src=“img_girl.jpg” width=”500” height=”600”>
The required alt attribute for the <img> tag specifies an alternate text for an
image, if the image for some reason cannot be displayed. This can be due to
a slow connection, or an error in the src attribute, or if the user uses a screen
reader.
The style attribute is used to add styles to an element, such as color, font,
size and more.
You should always include the lang attribute inside the <html> tag, to declare
the language of the Web page. This is meant to assist search engines and
browsers.
<!DOCTYPE html>
<html lang="en">
<body>
...
</body>
</html>
The value of the title attribute will be displayed as a tooltip when you mouse
over the element
HTML Headings:
<h1> defines the most important heading. <h6> defines the least important
heading.
<!DOCTYPE html>
<html>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</body>
</html>
Bigger Headings -
HTML Paragraphs:
HTML Display:
Large or small screens, and resized windows will create different results.
With HTML, you cannot change the display by adding extra spaces or extra
lines in your HTML code.
The browser will automatically remove any extra spaces and lines when the
page is displayed.
<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>
Output -
This paragraph contains a lot of lines in the source code, but the browser
ignores it.
This paragraph contains a lot of spaces in the source code, but the browser
ignores it.
<!DOCTYPE html>
<html>
<body>
</body>
This is heading 1
This is heading 2
This is heading 2
Use <br> if you want a line break (a new line) without starting a new
paragraph
Output -
This is
a paragraph
With line
Breaks.
Example
<p>
My Bonnie lies over the ocean.
Output-
My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies
over the ocean. Oh, bring back my Bonnie to me.
<pre>
My Bonnie lies over the ocean.
Output -
HTML Styles:
The HTML style attribute is used to add styles to an element, such as color,
font, size, and more.
<!DOCTYPE html>
<html>
<body>
<p>I am normal</p>
<p style="color:red;">I am red</p>
<p style="color:blue;">I am blue</p>
<p style="font-size:50px;">I am big</p>
</body>
Output -
I am normal
I am red
I am blue
I am big
-> Html Style Attribute,
-> background-color
<!DOCTYPE html>
<html>
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
</body>
This is a heading
This is a paragraph.
<!DOCTYPE html>
<html>
<body>
</body>
<!DOCTYPE html>
<html>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
</html>
HTML Contains several elements for defining text with a special meaning.
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Output -
<blockquote> -
The HTML <blockquote> element defines a section that is quoted from
another source.
<!DOCTYPE html>
<html>
<body>
<blockquote cite="http://www.worldwildlife.org/who/index.html">
For nearly 60 years, WWF has been protecting the future of nature. The
world's leading conservation organization, WWF works in 100 countries and is
supported by more than one million members in the United States and close
to five million globally.
</blockquote>
</body>
</html>
<p>WWF's goal is to: <q>Build a future where people live in harmony with
nature.</q></p>
</body>
</html>
Output -
WWF's goal is to: “Build a future where people live in harmony with nature.”
<abbr> -
<address> -
The HTML <address> tag defines the contact information for the author/owner
of a document or an article.
The text in the <address> element usually renders in italic, and browsers will
always add a line break before and after the <address> element.
<!DOCTYPE html>
<html>
<body>
<address>
Written by John Doe.<br>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>
</body>
</html>
Output -
<cite> -
The HTML <cite> tag defines the title of a creative work (e.g. a book, a poem,
a song, a movie, a painting, a sculpture, etc.).
<bdo> -
The HTML <bdo> tag is used to override the current text direction.
<!DOCTYPE html>
<html>
<body>
<p>If your browser supports bi-directional override (bdo), the next line will be
written from right to left (rtl):</p>
</body>
</html>
Output -
If your browser supports bi-directional override (bdo), the next line will be
written from right to left (rtl):
HTML Comments:
HTML Colors:
HTML colors are specified with predefined color names, or with RGB, HEX,
HSL, RGBA, or HSLA values.
-> background-color
-> color (text color)
-> border(border color
-> Color values,
The following three <div> elements have their background color set with RGB,
HEX and HSL Values.
<!DOCTYPE html>
<html>
<body>
<p>In addition to the predefined color names, colors can be specified using
RGB, HEX, HSL, or even transparent colors using RGBA or HSLA color
values.</p>
</body>
</html>
CSS saves a lot of work. It can control the layout of multiple web pages all at
once.
CSS can be added to HTML documents in 3 ways:
The most common way to add CSS, is to keep the styles in external CSS
files. However, in this tutorial we will use inline and internal styles, because
this is easier to demonstrate, and easier for you to try it yourself.
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
=> styles.css
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p{
color: red;
}
-> color
-> font-family
-> font-size
-> border(border:2px solid powderblue;)
-> padding(padding:30px)
-> margin(margin:50px)
-> link to external css,
<link rel=”stylesheet” href=“styles.css”>
HTML Links:
When you move the mouse over a link, the mouse arrow will turn into a little
hand.
<style>
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: red;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: yellow;
background-color: transparent;
text-decoration: underline;
}
</style>
To create a bookmark - first create the bookmark, then add a link to it.
<!DOCTYPE html>
<html>
<body>
<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 5</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 6</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 7</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 8</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 9</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 11</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 12</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 13</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 14</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 15</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 16</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 17</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 18</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 19</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 20</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 21</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 22</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 23</h2>
<p>This chapter explains ba bla bla</p>
</body>
</html>
HTML Images:
<!DOCTYPE html>
<html>
<body>
<h2>HTML Image</h2>
<img src="pic_trulli.jpg" alt="Trulli" width="500" height="333">
</body>
</html>
Image as a link,
<!DOCTYPE html>
<html>
<body>
<h2>Image as a Link</h2>
<a href="default.html">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
</body>
</html>
The HTML <map> tag defines an image map. An image map is an image with
clickable areas. The areas are defined with one or more <area> tags.
<!DOCTYPE html>
<html>
<body>
<h2>Image Maps</h2>
<p>Click on the computer, the phone, or the cup of coffee to go to a new page
and read more about the topic:</p>
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer"
href="computer.html">
<area shape="rect" coords="290,172,333,250" alt="Phone"
href="phone.html">
<area shape="circle" coords="337,300,44" alt="Cup of coffee"
href="coffee.html">
</map>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>Background Image</h2>
</body>
</html>
The HTML <picture> element allows you to display different pictures for
different devices or screen sizes.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<picture>
<source media="(min-width: 650px)" srcset="img_food.jpg">
<source media="(min-width: 465px)" srcset="img_car.jpg">
<img src="img_girl.jpg" style="width:auto;">
</picture>
<p>The img element is required as the last child tag of the picture declaration
block.
The img element is used to provide backward compatibility for browsers that
do not support the picture element, or if none of the source tags matched.
</p>
</body>
</html>
HTML Favicon :
A Favicon is a small image displayed next to the page title in the browsers
tab.
<!DOCTYPE html>
<html>
<head>
<title>My Page Title</title>
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
HTML Table:
HTML tables allow web developers to arrange data into rows and columns.
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
-> Everything between <td> and </td> are the content of the table cell.