Comprehensive Guide to HTML Basics
Comprehensive Guide to HTML Basics
What is HTML?............................................................................................................................................3
First Example of html...................................................................................................................................3
HTML Headings............................................................................................................................................3
HTML Paragraphs........................................................................................................................................4
HTML Horizontal Rules(HR Tag)...................................................................................................................4
HTML Line Breaks........................................................................................................................................4
The HTML <pre> Element............................................................................................................................5
HTML Text Formatting.................................................................................................................................5
HTML styles.................................................................................................................................................6
HTML Quotation and Citation Elements......................................................................................................8
HTML Comment Tags..................................................................................................................................9
HTML Colors..............................................................................................................................................10
Html styles css...........................................................................................................................................10
HTML Links - Hyperlinks.............................................................................................................................12
HTML Links - Different Colors....................................................................................................................14
HTML Images.............................................................................................................................................16
HTML Background Images.........................................................................................................................18
HTML Favicon............................................................................................................................................19
HTML Tables..............................................................................................................................................19
HTML Lists.................................................................................................................................................25
HTML Block and Inline Elements...............................................................................................................28
HTML class Attribute.................................................................................................................................29
HTML id Attribute......................................................................................................................................31
HTML Iframes............................................................................................................................................34
The HTML <meta> Element.......................................................................................................................35
What are Semantic Elements?...................................................................................................................36
HTML Forms..............................................................................................................................................39
HTML Form Attributes...............................................................................................................................41
The HTML <form> Elements......................................................................................................................42
Html input types........................................................................................................................................45
HTML Input Attributes...............................................................................................................................48
HTML Multimedia......................................................................................................................................50
HTML Video...............................................................................................................................................51
HTML Audio...............................................................................................................................................51
What is HTML?
HTML stands for Hyper Text Markup Language.
HTML elements label pieces of content such as "this is a heading", "this is a paragraph", "this is
a link", etc.
HTML Headings
HTML headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important heading.
Example
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
HTML Paragraphs
The HTML <p> element defines a paragraph.
A paragraph always starts on a new line, and browsers automatically add some white space (a
margin) before and after a paragraph.
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
The <hr> element is used to separate content (or define a change) in an HTML page:
Example
Use <br> if you want a line break (a new line) without starting a new paragraph:
Example
The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it
preserves both spaces and line breaks:
Example
<pre>
My Bonnie lies over the ocean.
The HTML <b> element defines bold text, without any extra importance.
The HTML <strong> element defines text with strong importance. The content inside is typically
displayed in bold.
The HTML <i> element defines a part of text in an alternate voice or mood. The content inside is
typically displayed in italic.
The HTML <em> element defines emphasized text. The content inside is typically displayed in
italic.
The HTML <mark> element defines text that should be marked or highlighted:
The HTML <del> element defines text that has been deleted from a document. Browsers will
usually strike a line through deleted text:
The HTML <ins> element defines a text that has been inserted into a document. Browsers will
usually underline inserted text:
The HTML <sub> element defines subscript text. Subscript text appears half a character below
the normal line, and is sometimes rendered in a smaller font. Subscript text can be used for
chemical formulas, like H2O:
The HTML <sup> element defines superscript text. Superscript text appears half a character
above the normal line, and is sometimes rendered in a smaller font. Superscript text can be
used for footnotes.
HTML styles
The HTML style attribute is used to add styles to an element, such as color, font, size, and more.
Setting the style of an HTML element, can be done with the style attribute.
<tagname style="pro+perty:value;">
Background Color
The CSS background-color property defines the background color for an HTML element.
Example :
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
Text Color
The CSS color property defines the text color for an HTML element:
Example
Fonts
The CSS font-family property defines the font to be used for an HTML element:
Example
Text Size
The CSS font-size property defines the text size for an HTML element:
Example
Text Alignment
The CSS text-align property defines the horizontal text alignment for an HTML element:
Example
The HTML <blockquote> element defines a section that is quoted from another source.
Browsers usually indent <blockquote> elements.
Example:
Example:
<p>WWF's goal is to: <q>Build a future where people live in harmony with nature.</q></p>
The HTML <abbr> tag defines an abbreviation or an acronym, like "HTML", "CSS", "Mr.", "Dr.",
"ASAP", "ATM". Marking abbreviations can give useful information to browsers, translation
systems and search-engines.
Example:
The HTML <address> tag defines the contact information for the author/owner of a document
or an article.
The contact information can be an email address, URL, physical address, phone number, social
media handle, etc.
The text in the <address> element usually renders in italic, and browsers will always add a line
break before and after the <address> element.
Example:
<address>
Written by John Doe.<br>
Visit us at:<br>
[Link]<br>
Box 564, Disneyland<br>
USA
</address>
The HTML <bdo> tag is used to override the current text direction:
Example
Background Color
Example:
Text Color
Example
Border Color
Example
CSS saves a lot of work. It can control the layout of multiple web pages all at once.
Using CSS
Inline CSS:-
Example
Internal CSS
An internal CSS is defined in the <head> section of an HTML page, within a <style> element.
Example
<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>
External CSS
An external style sheet is used to define the style for many HTML pages.
To use an external style sheet, add a link to it in the <head> section of each HTML page:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="[Link]">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
[Link]
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p{
color: red;
}
When you move the mouse over a link, the mouse arrow will turn into a little hand.
Syntax:
By default, the linked page will be displayed in the current browser window. To change this, you
must specify another target for the link.
_self - Default. Opens the document in the same window/tab as it was clicked
_blank - Opens the document in a new window or tab
_parent - Opens the document in the parent frame
_top - Opens the document in the full body of the window
Example:
Both examples above are using an absolute URL (a full web address) in the href attribute.
A local link (a link to a page within the same website) is specified with a relative URL (without
the "[Link] part):
Example:
<h2>Absolute URLs</h2>
<p><a href="[Link]
<p><a href="[Link]
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/[Link]">CSS Tutorial</a></p>
<a href="[Link]">
<img src="[Link]" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
Use mailto: inside the href attribute to create a link that opens the user's email program (to let them
send a new email):
Example:
Button as a Link
To use an HTML button as a link, you have to add some JavaScript code.
JavaScript allows you to specify what happens at certain events, such as a click of a button:
Example
Link Titles
The title attribute specifies extra information about an element. The information is most often shown as
a tooltip text when the mouse moves over the element.
Example
An HTML link is displayed in a different color depending on whether it has been visited, is
unvisited, or is active.
Example:
Here, an unvisited link will be green with no underline. A visited link will be pink with no underline. An
active link will be yellow and underlined. In addition, when mousing over a link (a:hover) it will become
red and underlined:
<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>
Link Buttons
<style>
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 15px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: red;
}
</style>
HTML Images
Images can improve the design and the appearance of a web page.
Example:
Images are not technically inserted into a web page; images are linked to web pages. The <img> tag
creates a holding space for the referenced image.
The <img> tag is empty, it contains attributes only, and does not have a closing tag.
You can use the style attribute to specify the width and height of an image.
Example
If you have your images in a sub-folder, you must include the folder name in the src attribute:
To point to an image on another server, you must specify an absolute (full) URL in the src attribute:
Example
Animated Images
Image as a Link
To use an image as a link, put the <img> tag inside the <a> tag:
Example
<a href="[Link]">
<img src="[Link]" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
Image Floating
Use the CSS float property to let the image float to the right or to the left of a text:
Example
<style>
body {
background-image: url('img_girl.jpg');
}
</style>
Background Repeat
<style>
body {
background-image: url('example_img_girl.jpg');
background-repeat: no-repeat;
}
</style>
Background Cover
<style>
body {
background-image: url('img_girl.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>
Background Stretch
<style>
body {
background-image: url('img_girl.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
</style>
HTML Favicon
A favicon is a small image displayed next to the page title in the browser tab.
<html>
<head>
<title>My Page Title</title>
<link rel="icon" type="image/x-icon" href="../image/[Link]">
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
HTML Tables
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>
Table Cells
Everything between <td> and </td> are the content of the table cell.
Table Rows
Each table row starts with a <tr> and ends with a </tr> tag.
Table Headers
Sometimes you want your cells to be table header cells. In those cases use the <th> tag instead of
the <td> tag:
table, th, td {
border: 1px solid black;
}
border-collapse: collapse;
If you set a background color of each cell, and give the border a white color (the same as the document
background), you get the impression of an invisible border:
table, th, td {
border: 1px solid white;
border-collapse: collapse;
}
th, td {
background-color: #96D4D4;
}
table, th, td {
border: 1px solid black;
border-radius: 10px;
}
With the border-style property, you can set the appearance of the border.
dotted
dashed
solid
double
groove
ridge
inset
outset
none
hidden
Border Color
With the border-color property, you can set the color of the border.
Style=” Border-color:red;”
Table Sizes
HTML tables can have different sizes for each column, row or the entire table.
<table style="width:100%">
<th style="width:70%">
<tr style="height:200px">
Table Headers
HTML tables can have headers for each column or row, or for many columns/rows.
Table headers are defined with th elements. Each th element represents a table cell.
Vertical table header:
<tr>
<th>Firstname</th>
<td>Jill</td>
<td>Eve</td>
</tr>
th {
text-align: left;
}
Table Caption
You can add a caption that serves as a heading for the entire table.
<table style="width:100%">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</table>
HTML tables can adjust the padding inside the cells, and also the space between the cells.
Cell Padding:- Cell padding is the space between the cell edges and the cell content.
th, td {
padding: 15px;
}
th, td {
padding-top: 10px;
padding-bottom: 20px;
padding-left: 30px;
padding-right: 40px;
}
To change the space between table cells, use the CSS border-spacing property
on the table element:
table {
border-spacing: 30px;
}
HTML tables can have cells that span over multiple rows and/or columns.
Colspan: To make a cell span over multiple columns, use the colspan attribute:
<table>
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>43</td>
</tr>
</table>
Rowspan: To make a cell span over multiple rows, use the rowspan attribute:
<table>
<tr>
<th>Name</th>
<td>Jill</td>
</tr>
<tr>
<th rowspan="2">Phone</th>
<td>555-1234</td>
</tr>
<tr>
<td>555-8745</td>
</tr>
</table>
Table Styling
If you add a background color on every other table row, you will get a nice zebra stripes effect.
To style every other table row element, use the :nth-child(even) selector like this:
tr:nth-child(even) {
background-color: #D6EEEE;
}
To make vertical zebra stripes, style every other column, instead of every other row.
td:nth-child(even), th:nth-child(even) {
background-color: #D6EEEE;
}
Hoverable Table
Table Colgroup
<table>
<colgroup>
<col span="2" style="background-color: #D6EEEE">
</colgroup>
<tr>
<th>MON</th>
<th>TUE</th>
<th>WED</th>
<th>THU</th>
The <colgroup> element should be used as a container for the column specifications.
Each group is specified with a <col> element.
The span attribute specifies how many columns that get the style.
HTML Lists
HTML lists allow web developers to group a set of related items in lists.
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The list items will be marked with bullets (small black circles) by default:
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<ul style="list-style-type:disc;">
<ul style="list-style-type:circle;">
<ul style="list-style-type:square;">
<ul style="list-style-type:none;">
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
Horizontal List with CSS
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 16px;
text-decoration: none;
}
li a:hover {
background-color: #111111;
}
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</body>
</html>
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<ol type="1">
<ol type="A">
<ol type="a">
<ol type="I">
<ol type="i">
<ol start="50">
The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag
describes each term:
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Every HTML element has a default display value, depending on what type of element it is.
Block-level Elements
A block-level element always starts on a new line, and the browsers automatically add some space (a
margin) before and after the element.
A block-level element always takes up the full width available (stretches out to the left and right as far as
it can).
<address>,<article>,<aside>,<blockquote>,<canvas>,<dd>,<div>,<dl>,<dt>,<fieldset>,
<figcaption>,<figure>,<footer>,<form>,<h1>-<h6>,<header>,<hr>,<li>,<main>,<nav>
<noscript>,<ol>,<p>,<pre>,<section>,<table>,<tfoot>,<ul>,<video>
Inline Elements
<a>,<abbr>,<acronym>,<b>,<bdo>,<big>,<br>,<button>,<cite>,<code>,<dfn>,<em>,<i>,<img>,
<input>,<kbd>,<label>,<map>,<object>,<output>,<q>,<samp>,<script>,<select>,<small>,<span>
<strong>,<sub>,<sup>,<textarea>,<time>,<tt>,<var>
HTML class Attribute
The HTML class attribute is used to specify a class for an HTML element.
The class attribute is often used to point to a class name in a style sheet. It can also be used by a
JavaScript to access and manipulate elements with the specific class name.
<!DOCTYPE html>
<html>
<head>
<style>
.city {
background-color: tomato;
color: white;
margin: 20px;
padding: 20px;
</style>
</head>
<body>
<div class="city">
<h2>London</h2>
</div>
<div class="city">
<h2>Paris</h2>
</div>
<div class="city">
<h2>Tokyo</h2>
</div>
</body>
</html>
To create a class; write a period (.) character, followed by a class name. Then, define the CSS
properties within curly braces {}:
Multiple Classes
To define multiple classes, separate the class names with a space, e.g. <div class="city main">.
The element will be styled according to all the classes specified.
In the following example, the first <h2> element belongs to both the city class and also to
the main class, and will get the CSS styles from both of the classes:
In the following example, both <h2> and <p> point to the "city" class and will share the same
style:
<h2 class="city">Paris</h2>
<p class="city">Paris is the capital of France</p>
HTML id Attribute
You cannot have more than one element with the same id in an HTML document.
The id attribute specifies a unique id for an HTML element. The value of the id attribute must be unique
within the HTML document.
The id attribute is used to point to a specific style declaration in a style sheet. It is also used by JavaScript
to access and manipulate the element with the specific id.
The syntax for id is: write a hash character (#), followed by an id name. Then, define the CSS properties
within curly braces {}.
In the following example we have an <h1> element that points to the id name "myHeader".
This <h1> element will be styled according to the #myHeader style definition in the head section:
<html>
<head>
<style>
#myHeader {
background-color: lightblue;
color: black;
padding: 40px;
text-align: center;
}
</style>
</head>
<body>
</body>
</html>
A class name can be used by multiple HTML elements, while an id name must only be used by one HTML
element within the page:
<style>
/* Style the element with the id "myHeader" */
#myHeader {
background-color: lightblue;
color: black;
padding: 40px;
text-align: center;
}
<h2 class="city">Paris</h2>
<p>Paris is the capital of France.</p>
<h2 class="city">Tokyo</h2>
<p>Tokyo is the capital of Japan.</p>
HTML bookmarks are used to allow readers to jump to specific parts of a webpage.
To use a bookmark, you must first create it, and then add a link to it.
Then, when the link is clicked, the page will scroll to the location with the bookmark.
<html>
<body>
<h2>Chapter 1</h2>
<h2>Chapter 2</h2>
<h2>Chapter 3</h2>
<h2>Chapter 5</h2>
<h2>Chapter 6</h2>
<h2>Chapter 7</h2>
<h2>Chapter 8</h2>
</body>
</html>
HTML Iframes
An HTML iframe is used to display a web page within a web page.
Use the height and width attributes to specify the size of the iframe.
Or you can add the style attribute and use the CSS height and width properties:
To remove the border, add the style attribute and use the CSS border property:
With CSS, you can also change the size, style and color of the iframe's border:
The metadata will not be displayed on the page, but is used by browsers (how to display content or
reload page), by search engines (keywords), and other web services.
<meta charset="UTF-8">
Setting the viewport to make your website look good on all devices:
Examples of non-semantic elements: <div> and <span> - Tells nothing about its content.
Examples of semantic elements: <form>, <table>, and <article> - Clearly defines its content.
Many web sites contain HTML code like: <div id="nav"> <div class="header"> <div id="footer"> to
indicate navigation, header, and footer.
In HTML there are some semantic elements that can be used to define different parts of a web page:
<article>
<aside>
<details>
<figcaption>
<figure>
<footer>
<header>
<main>
<mark>
<nav>
<section>
<summary>
<time>
According to W3C's HTML documentation: "A section is a thematic grouping of content, typically with a
heading."
Examples of where a <section> element can be used:
Chapters
Introduction
News items
Contact information
A web page could normally be split into sections for introduction, content, and contact information.
An article should make sense on its own, and it should be possible to distribute it independently from
the rest of the web site.
Forum posts
Blog posts
User comments
Product cards
Newspaper articles
The <header> element represents a container for introductory content or a set of navigational links.
logo or icon
authorship information
authorship information
copyright information
contact information
sitemap
related documents
Notice that NOT all links of a document should be inside a <nav> element. The <nav> element is
intended only for major blocks of navigation links.
Browsers, such as screen readers for disabled users, can use this element to determine whether to omit
the initial rendering of this content.
The <aside> element defines some content aside from the content it is placed in (like a sidebar).
The <figure> tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.
The <figcaption> tag defines a caption for a <figure> element. The <figcaption> element can be placed as
the first or as the last child of a <figure> element.
HTML Forms
An HTML form is used to collect user input. The user input is most often sent to a server for processing.
The HTML <form> element is used to create an HTML form for user input:
<form>
.
form elements
.
</form>
The <form> element is a container for different types of input elements, such as: text fields, checkboxes,
radio buttons, submit buttons, etc.
An <input> element can be displayed in many ways, depending on the type attribute.
Type Description
<input type="radio"> Displays a radio button (for selecting one of many choices)
<input type="checkbox"> Displays a checkbox (for selecting zero or more of many choices)
Text Fields
The <input type="text"> defines a single-line input field for text input.
Example
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
The <label> Element
The <label> element is useful for screen-reader users, because the screen-reader will read out loud the
label when the user focuses on the input element.
The <label> element also helps users who have difficulty clicking on very small regions (such as radio
buttons or checkboxes) - because when the user clicks the text within the <label> element, it toggles the
radio button/checkbox.
The for attribute of the <label> tag should be equal to the id attribute of the <input> element to bind
them together.
Radio Buttons
HTML
CSS
JavaScript
Checkboxes
Checkboxes let a user select ZERO or MORE options of a limited number of choices.
I have a bike
I have a car
I have a boat
The Submit Button
The <input type="submit"> defines a button for submitting the form data to a form-handler.
The form-handler is typically a file on the server with a script for processing input data.
Notice that each input field must have a name attribute to be submitted.
If the name attribute is omitted, the value of the input field will not be sent at all.
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" value="John"><br><br>
<input type="submit" value="Submit">
</form>
The action attribute defines the action to be performed when the form is submitted.
Usually, the form data is sent to a file on the server when the user clicks on the submit button.
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
The target attribute specifies where to display the response that is received after submitting the form.
The form-data can be sent as URL variables (with method="get") or as HTTP post transaction
(with method="post").
Notes on GET:
Notes on POST:
Appends the form data inside the body of the HTTP request (the submitted form data is
not shown in the URL)
POST has no size limitations, and can be used to send large amounts of data.
Form submissions with POST cannot be bookmarked
The autocomplete attribute specifies whether a form should have autocomplete on or off.
When autocomplete is on, the browser automatically complete values based on values that the user has
entered before.
The <input> element can be displayed in several ways, depending on the type attribute.
Visible Values:
Example
Use the multiple attribute to allow the user to select more than one value:
Example
Example
Example
Example
<form action="/action_page.php">
<fieldset>
<legend>Personalia:</legend>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
The <datalist> element specifies a list of pre-defined 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.
Example
<form action="/action_page.php">
<input list="browsers">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
</form>
The form-handler is typically a server page with a script for processing input data.
<input type="reset"> defines a reset button that will reset all form values to their default values:
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
<input type="reset">
</form>
The <input type="color"> is used for input fields that should contain a color.
The <input type="date"> is used for input fields that should contain a date.
The <input type="email"> is used for input fields that should contain an e-mail address.
The <input type="file"> defines a file-select field and a "Browse" button for file uploads.
The <input type="hidden"> defines a hidden input field (not visible to a user).
The <input type="range"> defines a control for entering a number whose exact value is not important
(like a slider control). Default range is 0 to 100. However, you can set restrictions on what numbers are
accepted with the min, max, and step attributes:
The <input type="search"> is used for search fields (a search field behaves like a regular text field).
The <input type="tel"> is used for input fields that should contain a telephone number.
The <input type="time"> allows the user to select a time (no time zone).
The <input type="url"> is used for input fields that should contain a URL address.
The <input type="week"> allows the user to select a week and year.
The input value attribute specifies an initial value for an input field:
The value of a read-only input field will be sent when submitting the form!
The input disabled attribute specifies that an input field should be disabled.
The value of a disabled input field will not be sent when submitting the form!
The input size attribute specifies the visible width, in characters, of an input field.
Note: The size attribute works with the following input types: text, search, tel, url, email, and password.
The input maxlength attribute specifies the maximum number of characters allowed in an input field.
<label for="pin">PIN:</label><br>
<input type="text" id="pin" name="pin" maxlength="4" size="4">
The input multiple attribute specifies that the user is allowed to enter more than one value in an input
field.
The multiple attribute works with the following input types: email, and file.
The pattern attribute works with the following input types: text, date, search, url, tel, email, and
password.
The input placeholder attribute specifies a short hint that describes the expected value of an input field
(a sample value or a short description of the expected format).
The short hint is displayed in the input field before the user enters a value.
The placeholder attribute works with the following input types: text, search, url, tel, email, and
password.
The input required attribute specifies that an input field must be filled out before submitting the form.
The required attribute works with the following input types: text, search, url, tel, email, password, date
pickers, number, checkbox, radio, and file.
The input step attribute specifies the legal number intervals for an input field.
Tip: This attribute can be used together with the max and min attributes to create a range of legal
values.
The step attribute works with the following input types: number, range, date, datetime-local, month,
time and week.
<label for="points">Points:</label>
<input type="number" id="points" name="points" step="3">
The input autofocus attribute specifies that an input field should automatically get focus when the page
loads.
The input autocomplete attribute specifies whether a form or an input field should have autocomplete
on or off.
Autocomplete allows the browser to predict the value. When a user starts to type in a field, the browser
should display options to fill in the field, based on earlier typed values.
The autocomplete attribute works with <form> and the following <input> types: text, search, url, tel,
email, password, datepickers, range, and color.
HTML Multimedia
Multimedia comes in many different formats. It can be almost anything you can hear or see, like
images, music, sound, videos, records, films, animations, and more.
Web pages often contain multimedia elements of different types and formats.
HTML Video
The HTML <video> element is used to show a video on a web page.
The controls attribute adds video controls, like play, pause, and volume.
It is a good idea to always include width and height attributes. If height and width are not set,
the page might flicker while the video loads.
The <source> element allows you to specify alternative video files which the browser may
choose from. The browser will use the first recognized format.
The text between the <video> and </video> tags will only be displayed in browsers that do not
support the <video> element.
HTML Audio
The HTML <audio> element is used to play an audio file on a web page.
<audio controls>
<source src="[Link]" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
The controls attribute adds audio controls, like play, pause, and volume.
The <source> element allows you to specify alternative audio files which the browser may
choose from. The browser will use the first recognized format.
The text between the <audio> and </audio> tags will only be displayed in browsers that do not
support the <audio> element.
Add muted after autoplay to let your audio file start playing automatically (but muted):
<audio controls autoplay muted>