Source (http://www.w3schools.com/html/)
HTML File Paths
Learn about the best way to implement different html layouts in HTML Layouts
Learn about how to make the web pager resposive in HTML Responsive Web Design
Know how to insert code elements in html and also insert sample outputs, keyboard input and variables here.
Also checkout HTML Charset , HTML URL Encode and XHTML .
HTML is the skeleton of every single web page. It is the raw element of a web page.
Simple HTML code
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>We can see that basic HTML documents consists of the following basic elements,
- The
<!DOCTYPE html>declaration defines this document is HTML5. It defines which version of HTML this doc is written in. - The
<html>element is the root element of an HTML page *The<head>element is contains meta information ( Metadata and meta tags refer to the title and description of a web page that are encoded into the page but not actually displayed on the screen with the page. ) about the document - The
<title>element specifies a title for the document - The
<body>element contains the visible page content
Inside the body there are HTML Tags. HTML tags are element names surrounded by angle brackets:
<tagname> content goes here...<\tagname>- HTML tags normally come in pairs like
<p>and</p> - The first tag in a pair is the start tag, the second tag is the end tag
- The end tag is written like the start tag, but with a forward slash inserted before the tag name 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. Only the content inside the <body> section is displayed in a browser.
HTML heading are defined with the <h1> to <h6> tags. <h1> defines the most important heading and <h6> defines the least important heading.
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3><h1>headers are parsed by the search engines. It should be used only onece for every page.
HTML paragraphs are defined with the <p> tag.
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>This is a paragraph.
This is another paragraph.
HTML links are defined with <a> tag
<a href="https://github.com"> This is a link</a>This is a link The link destination is specified by the href attribute. Attribures are used to provide additional information about HTML elements.
HTML images are defined with the <img> tag. The source file (src), alternative text (alt), width, and height are provided as attributes.
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">HTML buttons are defined with <button> tags.
<button>Click me</button>Click me
HTML lists are defined with the <ul> (unordered/bullet list) or the <ol> (ordered/numbered list) tag, followed by <li> tags (list items).
<ul>
<li>C++</li>
<li>Java</li>
<li>Python</li>
</ul>- C++
- Java
- Python
An HTML element is everything from the start tag to the end tag.
| Start tag | Element Content | End tag |
|---|---|---|
<h1> |
My First Heading | </h1> |
<p> |
My First Paragraph | </p> |
###Nested HTML Elements HTML elements can be nested. All HTML documents consists of nested HTML elements.
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>The <h1> and <p> elements are nested inside <body> element and it is inturn nested inside <html> element.
- 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".
There are many types of attributes:
hrefis used with<a>tags and used for specifying addresses.srcis used with<img>tags and used for specifying the image source.widthandheightattributes are used for specifying width and height of the image.altattribute specifies the text to be used when the iamge can not be displayed.- The
styleattribute is used to specify the styling of an element, like color, font, size etc. langattribute declares the language of the document and is declared inside<html>tag. eg.<html lang = "en-US">. Declaring a language is important for accessibility applications (screen readers) and search engines.titleattribute is added to the<p>element. The value of thetitleattribute will be displayed as a tooltip when you mouse over the paragraph.
A list of all HTML attributes is given here.
Search engines use the heading to index the structure and content of an web page. Example of different headings:
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>Browser automatically adds some white space (a margin) before and after a heading.
Each HTML Heading has it's own default size. However we can make in bigger using style attribute. Eg:
<h1 style = "font-size:50px;">Heading 1</h1>The <hr> tag is used to separate content in an HTML page. It displayes a horizontal line. Example:
<h1>This is heading 1</h1>
<p>This is some text.</p>
<hr>
<h2>This is heading 2</h2>
<p>This is some other text.</p>
<hr>The line is very much similer to what is seen through out the document (line just below this text).
The <head> element is a container for metadata. HTML metadata is data about the HTML document. Metadata is not displayed. It is placed between the <html> tag and the <body> tag:
<!DOCTYPE html>
<html>
<head>
<title>My first HTML</title>
<meta charset = "UTF-8">
</head>
<body>
.
.
.
</body>
</html>Metadata typically defines the document title, charset, styles, links, scripts and other meta information.
| Tag | Description |
|---|---|
| <html> | Defines the root of an HTML document |
| <body> | Defines the document's body |
| <head> | A container for all the head elements (title, scripts, styles, meta information, and more) |
| <h1> to <h6> | Defines HTML headings |
| <hr> | Defines a thematic change in the content |
The HTML <p> defines a paragraph. Browsers automatically add some white space (a margin) before and after a paragraph.
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>This is a paragraph.
This is another paragraph.
The output of the HTML code can not be changed by adding extra spaces or extra lines. The browser removes extra spaces and lines. This is known as the Poem problem. To solve this problem we need **The HTML <pre> element.
Most browsers will display HTML correctly even if we forget the end tag but it is recomended to remember adding it at the end.
The HTML <br> element defines a line break. It is used if we want to break a line without starting a new paragraph.
<p>This is<br>a paragraph<br>with line breaks.</p>This is
a paragraph
with line breaks.
The <br> tag is an empty tag, which means that it has no end tag.
The HTML <pre> element defines preformatted text. The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks:
<pre>
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. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me.
| Tag | Description |
|---|---|
| <p> | Defines a paragraph |
| <br> | Inserts a single line break |
| <pre> | Defines pre-formatted text |
The style attribute sets the style of the HTML elements. It has the following syntax:
<tagname style = "property:value;">The Property is a CSS property and the *Value is a CSS value. Basically we can write a CSS code inside the style tag. Some examples of different style elements is given below:
- Use
background-colorfor changing the element's background color. Eg:
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>- Use
colorfor text colors.
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>- Use
font-familyfor text fonts.
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>- Use
font-sizefor text sizes.
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>- Use
text-alignfor text alignment.
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>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. Formatting elements were designed to display special types of text.
Example template:
<p>This is <formatting_tag> formatted </formatting_tag> text</p>The following table shows all the formatting commands and their outputs:
| Tag | Description | Output |
|---|---|---|
| <b> | Defines bold text | This text is bold |
| <em> | Defines emphasized text | This text is emphasized |
| <i> | Defines italic text | This text is italic |
| <small> | Defines smaller text | This text is Small |
| <strong> | Defines important text | This text is strong |
| <sub> | Defines subscripted text | This is subscripted text |
| <sup> | Defines superscripted text | This is superscripted text |
| <ins> | Defines inserted text | This is inserted text |
| <del> | Defines deleted text | This is |
| <mark> | Defines marked/highlighted text | This is marked text |
The HTML quotation and citation provides a way to insert quoted texts and citations inside paragraphs. Example template:
<p>This is <quotation_tag> Quoted or Cited </quotation_tag> text</p>The following table shows all the quotation and citation commands and their outputs:
| Tag | Description | Output |
|---|---|---|
| <abbr title=" "> | Defines an abbreviation or acronym | The WHO was founded in 1948. |
| <address> | Defines contact information for the author/owner of a document |
Written by John Doe. Visit us at: Example.com Box 564, Disneyland USA |
| <bdo dir="rtl"> | Defines the text direction (Bi-Directional Override). It writes text in reverse order | This text will be written from right to left |
| <blockquote cite=" "> | Defines a section that is quoted from another source | Here is a quote from WWF's website: 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. |
| <cite> | Defines the title of a work | The Scream by Edvard Munch. Painted in 1893. |
| <q> | Defines a short inline quotation | WWF's goal is to: |
Comment tags are used to insert comments in the HTML source code. We can add comments to our HTML source code by using the following syntax:
<! Comment here,.. -->With comments we can place notifications and reminders in our HTML:
<!-- This is a comment -->
<p>This is a paragraph.</p>
<!-- Remember to add more information here -->Comments are also great for debugging HTML, because we can comment out HTML lines of code, one at a time, to search for errors:
<!-- Do not display this at the moment
<img border="0" src="pic_trulli.jpg" alt="Trulli">
-->HTML colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values. HTML Supports 140 standard color names.
We can change color of three HTML elements:
<h4 style = "backgorund-color:DodgerBlue;">Hello World</h4>
<p style="background-color:Tomato;">Lorem ipsum...</p><h4 style="color:Tomato;">Hello World</h4>
<p style="color:DodgerBlue;">Lorem ipsum...</p>
<p style="color:MediumSeaGreen;">Ut wisi enim...</p><h3 style="border:2px solid Tomato;">Hello World</h3>
<h3 style="border:2px solid DodgerBlue;">Hello World</h3>We can define color values in the following formats:
- RGB Value:
rgb(red, green, blue) - HEX Value:
#rrggbb - HSL Value:
hsl(hue, saturation%, lightness%) - RGBA Value:
rgb(red, green, blue, opacity(0-1)) - HSLA Value:
hsl(hue, saturation%, lightness%, ,opacity(0~1))
CSS stands for Cascading Style Sheets. CSS describes how HTML elements are to be displayed on screen, paper, or in other media. CSS saves a lot of work. It can control the layout of multiple web pages all at once.
CSS can be added to HTML elements in 3 ways:
An Inline CSS is used to apply unique style to a single HTML element.
<h1 style="color:blue;">This is a blue heading</h1>An internal CSS is used to define a style for a single HTML page. It is defined inside the <head> section.
<!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>An external CSS style sheet is used to define style for many HTML Pages. With an external style sheet, we can change the look of an entire web site, by changing one file! To use it, we need the add the link to the style sheet in the <head> section.
<!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>An external style sheet can be written in any text editor. The file must not contain any HTML code, and must be saved with a .css extension. Example of how "styles.css" looks:
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p {
color: red;
}Links allow users to click their way from one page to another. HTML links are hyperlinks.
On the practical side, another difference is that a hyperlink control navigates directly to a target URL when a user clicks on it, instead of posting the form on the server. So if there is no work to be done in the server side, we can use hyperlink.A HTML link does not have to be text. It can be an image or any other HTML element. HTML links are defined withUsing a link posts that form right to the server first, before going to the URL. Therefore, a link is the better choice for those who need to complete some server-side processing before heading to the final URL destination.
So for hyperlink, we will be directly hitting the URL
For link, the job is done in the server side first.
<a> tag:
<a href="url">link text</a>Example:
<a href="https://www.w3schools.com/html/">Visit our HTML tutorial</a>The example above used an absolute URL (a full web address).
A local link (link to the same web site) is specified with a relative URL (without https://www....). Example:
<a href="html_images.asp">HTML Images</a>By default a link is colored in the following way in all browsers:
- An unvisited link is underlined and blue
- A visited link is underlined and purple
- An active link is underlined and red The style can be changed by CSS:
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;
}The target attribute specifies where to open the linked document. Template:
<a href="url" target="value">Visit Document!</a>The target attribute can have one of the following values:
_blank- Opens the linked document in a new window or tab_self- Opens the linked document in the same window/tab as it was clicked (this is default)_parent- Opens the linked document in the parent frame_top- Opens the linked document in the full body of the windowframename- Opens the linked document in a named frame If our webpage is locked in a frame, we can use_topto break out the frame.
HTML bookmarks are used to allow readers to jump to specific parts of a Web page. Bookmarks can be useful if the webpage is very long.
To make a bookmark, first create the bookmark, and then add a link to it.
When the link is clicked, the page will scroll to the location with the bookmark. Example: First create bookmark with id attribute:
<h2 id = "c4">Chapter 4</h2>Then add a link to the bookmark (jump to Chapter 4), from within the same page:
<a href="#c4">Jump to Chapter 4</a>Or, add a link to the bookmark from another page:
<a href="html_demo.html#C4">Jump to Chapter 4</a>External pages can be referenced with a full URL or with a path relative to the current web page. Example:
<a href="https://www.w3schools.com/html/default.asp">HTML tutorial</a>
<a href="/html/default.asp">HTML tutorial</a>
<a href="default.asp">HTML tutorial</a>Read more about file paths in HTML File Paths
HTML images are defined by the <img> tag. It is an empty tag which consists of only attributes and no closing tags.
- The
srcattribute specified the URL web address of the image. - The
altattribute specifies what to show if the image is not available. - The
styleattribute can be used to specify the width and height of the image or we can directly usewidthandheightattribute. Using the style attribute is suggested. - We can load image from another server eg:
<img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="W3Schools.com">or we can load image from another folder eg:<img src="/images/html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;">. - We can also use animated images in our web pages.
To use images as links we have to use <a> tag followed by an img tag. Example:
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;border:0;">
</a>here, we have to assign image border with value 0, because some internet browsers show image image borders when the link is active.
We can use CSS float property to let the image float to the right or to the left of a text. Example
<p><img src="smiley.gif" alt="Smiley face" style="float:right;width:42px;height:42px;">
The image will float to the right of the text.</p>
<p><img src="smiley.gif" alt="Smiley face" style="float:left;width:42px;height:42px;">
The image will float to the left of the text.</p>By using the <map> tag, we can map clickable areas on am image. Example:
<img src="workplace.jpg" alt="Workplace" usemap="#workmap">
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
<area shape="circle" coords="337,300,44" alt="Coffee" href="coffee.htm">
</map>HTML5 introduced the <picture> element to add more flexibility when specifying image resources. It contains a number of <source> elements, each referring to different image sources. This way the browser can choose the image that best fits the current view and/or device.
Each <source> element have attributes describing when their image is the most suitable. The browser will use the first <source> element with matching attribute values, and ignore any following <source> elements.
<picture>
<source media="(min-width: 650px)" srcset="img_pink_flowers.jpg">
<source media="(min-width: 465px)" srcset="img_white_flower.jpg">
<img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;">
</picture>
Note: Always specify an <img> element as the last child element of the <picture> element. The <img> element is used by browsers that do not support the <picture> element, or if none of the <source> tags matched.
An HTML table is defined with the <table> tag. Rows are define with the <tr> tag and headers are defined with <th> tag. A cell is defined with <td> tag.
Example:
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>| Firstname | Lastname | Age |
|---|---|---|
| Jill | Smith | 50 |
| Eve | Jackson | 94 |
- We can use CSS
borderproperty to customize table borders
table, th, td {
border: 1px solid black;
}We should remember to define borders for both the table and table cells.
- If we want to collapse the multiple borders (borders of the table and cells) into one border we should use
border-collabpseborders.
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}- We can modify the space between the cells using
border-spacingproperty:
table {
border-spacing: 5px;
}- We can make a cell span more than one collumn using the
colspanattribute.
<table style="width:100%">
<tr>
<th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>55577854</td>
<td>55577855</td>
</tr>
</table>| Name | Telephone | |
|---|---|---|
| Bill Gates | 55577854 | 55577855 |
- Similerly we can span a cell into multiple rows by using
rowspanattrubute:
<table style="width:100%">
<tr>
<th>Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan="2">Telephone:</th>
<td>55577854</td>
</tr>
<tr>
<td>55577855</td>
</tr>
</table>| Name: | Bill Gates |
|---|---|
| Telephone: | 55577854 |
| 55577855 |
- We can add a table caption using
<caption>tag. The<caption>tag must be inserted immediately after the<table>tag.
- We can use
cellpaddingattribute to controll to spacing inside the cell and we can usecellspacingto control the spacing outside the cell.
| Tag | Description |
|---|---|
| <table> | Defines a table |
| <th> | Defines a header cell in a table |
| <tr> | Defines a row in a table |
| <td> | Defines a cell in a table |
| <caption> | Defines a table caption |
| <colgroup> | Specifies a group of one or more columns in a table for formatting |
| <col> | Specifies column properties for each column within a <colgroup> element |
| <thead> | Groups the header content in a table |
| <tbody> | Groups the body content in a table |
| <tfoot> | Groups the footer content in a table |
There are mainly two types of lists.
- Unordered list
- Ordered list
They are marked with <ul> tag. Each list item is defined by <li> tag. Items are marked with bullets by default.
Example:
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>- Coffee
- Tea
- Milk
The CSS list-style-type property can by used to define markers of the items. It can take the following values:
| Value | Description |
|---|---|
| disc | Sets the list item marker to a bullet (default) |
| circle | Sets the list item marker to a circle |
| square | Sets the list item marker to a square |
| none | The list items will not be marked |
Example:
<ul style="list-style-type:square">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. The list items will be marked with numbers by default:
Exaple:
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>- Coffee
- Tea
- Milk
The type attributes of the <ol> tag, defines the type of the list item marker:
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>| Type | Description |
|---|---|
| type="1" | The list items will be numbered with numbers (default) |
| type="A" | The list items will be numbered with uppercase letters |
| type="a" | The list items will be numbered with lowercase letters |
| type="I" | The list items will be numbered with uppercase roman numbers |
| type="i" | The list items will be numbered with lowercase roman numbers |
HTML also supports description lists. A description list is a list of terms, with a description of each term. The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag describes each term:
Example:
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>- Coffee
- - black hot drink
- Milk
- - white cold drink
List can be nested (lists inside lists):
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>- Coffee
- Tea
- Black tea
- Green tea
- Milk
Note: List items can contain new list, and other HTML elements, like images and links, etc.
By default Ordered list counting starts from one. We can use the start attribute to start counting from a specific number:
<ol start="50">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>- Coffee
- Tea
- Milk
We have to use CSS to style a list horizontally. The float property of <li> can be changed to 'left` to align the list horizontally form left.
Every HTML element has a default display value depending on what type of element it is. The default display value for most elements is block or inline.
A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can). Block level elements in HTML:
An inline element does not start on a new line and only takes up as much width as necessary. List of Inline elements in HTML
| Tag | Description |
|---|---|
| <div> | Defines a section in a document (block-level) |
| <span> | Defines a section in a document (inline) |
Both the <div> and the <span> elements can be given common attributes style, class and id .
The Class and ID attributes are mainly used to isolate a single element or a group of similer elemts.
The HTML class attribute is used to define equal styles for elements with the same class name. So, all HTML elements with the same class attribute will have the same format and style.
Tip: The class attribute can be used on any HTML element.
Note: The class name is case sensitive!
- In CSS, to select elements with a specific class, write a period (.) character, followed by the name of the class:
.city {
background-color: tomato;
color: white;
padding: 10px;
} - HTML elements can have more than one class name, each class name must be separated by a space.
<h2 class="city main">London</h2>
<h2 class="city">Paris</h2>
<h2 class="city">Tokyo</h2>- Different tags, like
<h2>and<p>, can have the same class name and thereby share the same style:
<h2 class="city">Paris</h2>
<p class="city">Paris is the capital of France</p>- The class name can also be used by JavaScript to perform certain tasks for elements with the specified class name.
The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document).
The id value can be used by CSS and JavaScript to perform certain tasks for a unique element with the specified id value.
In CSS, to select an element with a specific id, write a hash (#) character, followed by the id of the element:
#myHeader {
background-color: lightblue;
color: black;
padding: 40px;
text-align: center;
} Tip: The id attribute can be used on any HTML element.
Note: The id value is case-sensitive.
Note: The id value must contain at least one character, and must not contain whitespace (spaces, tabs, etc.).
Note: An ID can not be shared.
- ID can be used for Bookmarking.
- ID can be used by JavaScript by using
getElementById()method.
An iframe is used to display a webpage within a web page. It is defined with the <iframe> tag. Syntax: <iframe src="URL"></iframe>. The src attribute specifies the web address of the inline frame page.
- The
heightandwidthattributes are used to set the height and width of the frame. - The
borderproperty ofstyleattribute can be used to remove the borders of the frame.
An iframe can be used as a target frame for a link. When the link is clicked, it will open inside the iframe.
The target attribute of the link must refer to the name attribute of the iframe:
<iframe src = "http://github.com" name="iframe_a"></iframe>
<p><a href="https://www.w3schools.com" target="iframe_a"></a>See Sample for more understanding.
The <head> element is a container for metadata (data about data) and is placed between the <html> tag and the <body> tag.
| Tag | Description |
|---|---|
| <head> | Defines information about the document |
| <title> | Defines the title of a document |
| <base> | Defines a default address or a default target for all links on a page |
| <link> | Defines the relationship between a document and an external resource. Can be used to assign icon (Favicon) to the page. |
| <meta> | Defines metadata about an HTML document |
| <script> | Defines a client-side script |
| <style> | Defines style information for a document |
<title>is useful to make the website more searchable. It is the first thing that occurs about an web page when it is shown as a result in searches. It is also used for bookmarking the page.<link>can be used to assign an icon to the page.<meta>is used to denote data about data. It denotes information about the website, such as: what related, what does it contain, author information, description, keywords etc. These meta tags are not seen by the user but are parsed by the search engines and they help the search engines to find the web page more accurately. They are also useful for Web Crawlers.
Complete List of HTML Meta Tags
Reserved characters in HTML must be replaced with character entities. Characters that are not present on our keyboard can also be replaced by entities.
| Result | Description | Entity Name | Entity Number |
|---|---|---|---|
| non-breaking space | |   | |
| < | less than | < | < |
| > | greater than | > | > |
| & | ampersand | & | & |
| " | double quotation mark | " | " |
| ' | single quotation mark (apostrophe) | ' | ' |
| ¢ | cent | ¢ | ¢ |
| £ | pound | £ | £ |
| ¥ | yen | ¥ | ¥ |
| € | euro | € | € |
| © | copyright | © | © |
| ® | registered trademark | ® | ® |
A diacritical mark is a "glyph" added to a letter. Here are some examples:
| Mark | Character | Construct | Result |
|---|---|---|---|
| ̀ | a | à | à |
| ́ | a | á | á |
| ̂ | a | â | â |
| ̃ | a | ã | ã |
| ̀ | O | Ò | Ò |
| ́ | O | Ó | Ó |
| ̂ | O | Ô | Ô |
| ̃ | O | Õ | Õ |
Many mathematical, technical, and currency symbols, are not present on a normal keyboard. To add such symbols to an HTML page, we can use an HTML entity name. If no entity name exists, we can use an entity number, a decimal, or hexadecimal reference.
| Char | Number | Entity | Description |
|---|---|---|---|
| ∀ | ∀ | ∀ | FOR ALL |
| ∂ | ∂ | ∂ | PARTIAL DIFFERENTIAL |
| ∃ | ∃ | ∃ | THERE EXISTS |
| ∅ | ∅ | ∅ | EMPTY SETS |
| ∇ | ∇ | ∇ | NABLA |
| ∈ | ∈ | ∈ | ELEMENT OF |
| ∉ | ∉ | ∉ | NOT AN ELEMENT OF |
| ∋ | ∋ | ∋ | CONTAINS AS MEMBER |
| ∏ | ∏ | ∏ | N-ARY PRODUCT |
| ∑ | ∑ | ∑ | N-ARY SUMMATION |
| Char | Number | Entity | Description |
|---|---|---|---|
| Α | Α | Α | GREEK CAPITAL LETTER ALPHA |
| Β | Β | Β | GREEK CAPITAL LETTER BETA |
| Γ | Γ | Γ | GREEK CAPITAL LETTER GAMMA |
| Δ | Δ | Δ | GREEK CAPITAL LETTER DELTA |
| Ε | Ε | Ε | GREEK CAPITAL LETTER EPSILON |
| Ζ | Ζ | Ζ | GREEK CAPITAL LETTER ZETA |
| Char | Number | Entity | Description |
|---|---|---|---|
| © | © | © | COPYRIGHT SIGN |
| ® | ® | ® | REGISTERED SIGN |
| € | € | € | EURO SIGN |
| ™ | ™ | ™ | TRADEMARK |
| ← | ← | ← | LEFTWARDS ARROW |
| ↑ | ↑ | ↑ | UPWARDS ARROW |
| → | → | → | RIGHTWARDS ARROW |
| ↓ | ↓ | ↓ | DOWNWARDS ARROW |
| ♠ | ♠ | ♠ | BLACK SPADE SUIT |
| ♣ | ♣ | ♣ | BLACK CLUB SUIT |
| ♥ | ♥ | ♥ | BLACK HEART SUIT |
| ♦ | ♦ | ♦ | BLACK DIAMOND SUIT |
Very usefull for traversing through the document (the web page). Used heavily in JavaScript. The DOM defines:
- HTML elements as objects
- The properties of HTML elements (attributes)
- The events(
onclick,onsubmit) for all of the elements (JavaScript) - Methods (
queryselector,getelementbyid,getelementbyclass) of access of every element. The DOM and JS work closely together, but the DOM is made of HTML. DOM is provided by browser which provides functions to travers through the HTML documents and provide methods for accessing elements and their properties.
<form> element defines a form that is used to collect user input:
<form>
.
form elements
.
</form>All HTML form contains:
- Different Form Elements
- Different Input Types
- Different Input Attributes
There are several HTML Form elements. They are described below:
The most important form element is the <input> element. It can be of several types based on type attribute. If the type attribute is omitted, then the input field gets the default type: "text".
<input name="firstname" type="text">There can be many other input types such as: email, password, submit, reset, color, date, file etc. Ream more about HTML Input Types.
These Input Element can have different attributes such value, readonly, disabled etc. Read more about HTML Input Attributes
The <select> element defines a drop-down list:
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>The <options> element defines an option that can be selected. By default the first option is selected. To define a pre-selected option, add the selected attrubute to the option:
<option value="fiat" selected>Fiat</option>The size attrubute specifies the number of visible values:
<select name="cars" size="3">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>We can use multiple attribute to allow user to select multiple values:
<select name="cars" size="4" multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>The <textarea> element defines a multi-line input field:
<textarea name="message" rows="10" cols="30">
The cat was playing in the garden.
</textarea>The rows attribute specifies the visible number of lines in the text area. The cols attribute specifies the visible width of the text area.
The width and height can also be defined using CSS.
The <button> element defines a clickable button:
<button type="button" onclick="alert('hello world!')">Click Me!</button>Always specify the type attribute for the button element. Different browsers may use different default types for the button element.
The <datalist> element specifies a list of predefined options for an <input> element. Users will see a drop-down list of the pre-defined options as they input data.
The list attribute of the <input> element, must refer to the id attribute of the <datalist> element.
<form action = "action_page.php">
<input list = "browsers">
<datalist id = "browsers">
<option value = "Internet Explorer">
<option value = "Chrome">
<option value = "Mozilla Firefox">
</dataset>
</form>
