HTML Notes
HTML Notes
HTML code.
<head> — This is where all the metadata for the page goes — stuff
not actually an element or HTML tag. It lets the browser know how
<!DOCTYPE html>
HTML Element
Block-level vs inline HTML
elements
By default, an element can be either block-level or an inline element.
Block-level elements are the elements that always start on a new line
and take up the full width available.
Inline elements are the elements that do not start on a new line and it
only take up as much width as necessary.
Block-level element:
These are the elements, which structure main part of web page, by
dividing a page into coherent blocks.
A block-level element always start with new line and takes the full
width of web page, from left to right.
These elements can contain block-level as well as inline elements.
Following are the block-level elements in HTML.
Inline elements are those elements, which differentiate the part of a given
requirement.
The Inline elements are mostly used with other elements.
The HTML <head> element is used as a container for metadata (data about
the browser on page loading. It just contains metadata about the HTML
Important Points
• The title tag is used to give the title to the webpage and it should be the text only.
• You can NOT have more than one <title> element in an HTML document.
• A page’s title, essential for Search Engine Optimization (SEO), impacts how search
engines rank pages in search results.
• Keep titles concise within 50-60 characters for optimal search engine display and
user readability.
• Avoid using just a list of keywords in titles to prevent negative SEO consequences.
<head>
<title>Welcome to my blog</title>
</head>
<body>
<h1>Blog Homepage</h1>
<p>This is my homepage of my bolg</p>
</body>
</html>
HTML <style> Element
<!DOCTYPE html>
The HTML <style> <html>
<head>
element is used to style the
<title>This is Page Title</
HTML page. The <style> title>
<style>
element can have CSS body {background-
color: pink;}
properties for that HTML
h1 {color: red;}
page only. If we want to p {color: blue;}
</style>
apply CSS for multiple </head>
<body>
pages then we should use
<h1>This is a Heading</
separate CSS file. h1>
<p>This is a paragraph.</
p>
</body>
HTML <link> Element
The HTML <meta> element is used to specify the character set, page
description, keywords, authors and other metadata on the webpage.
Metadata is mainly used by browsers, search engines, and other web services
to rank your webpage better.
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML, CSS, XML, JavaScript"
>
<meta name="author" content="Ashwin">
<meta http-equiv="refresh" content="30">
<meta http-equiv="refresh" content="10; url=https://
HTML <base> Element
The HTML <base> element is used to specify the base URL
and base target for all relative URLs in a page.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<base href="https://www.infosyst.net/images" target="_blank">
</head>
<body>
<img src="banner.png">
</body>
</html>
HTML <script> element
HTML <script> 1.<!DOCTYPE html>
2.<html>
element is used to apply 3.<head>
client side JavaScript for 4. <script>
the same page or to add 5. function fun() {
an external JavaScript 6. document.getElementById("p").style.color="green";
7. }
file to current page. 8. </script>
9.</head>
10.<body>
11.<h2>Script within Head element</h2>
12.<p id="p">This will change the color</p>
13.<button type="button" onclick="fun()">Click me</button>
14.</body>
15.</html>
Heading Tag <h1>…
<h6>
The heading tag to prepare heading in different level, the biggest
heading is <h1> and least heading is <h6>.
Attribute
Align
The align attribute to make alignment of paragraph such as left,
right, center and justify.
By default is left alignment.
<p> text…..</p>
<p align=“justify”>text……</p>
HTML Formatting
HTML Formatting is a process of formatting text for better look and feel.
HTML provides us ability to format text without using CSS. There are many
formatting tags in HTML. These tags are used to make text bold, italicized, or
underlined. There are almost 14 options available that how text appears in
• Physical tag: These tags are used to provide the visual appearance to
the text.
• Logical tag: These tags are used to add some logical or semantic
HTML <p> tag defines the paragraph and is used to give structure
to text content within a webpage. It is a block-level element & used
to add the space or margins after and before the element this is
done by browsers by default.
If you want to mark or highlight a text, you should write the content
within <mark>.........</mark>.
If you want that each letter has the same width then you should
write the content within <tt>.............</tt> element.
If you want to put your font size larger than the rest of the
text then put the content within <big>.........</big>. It
increase one font size larger than the previous one.
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.
Value Description
When you use the <dfn> and </dfn> tags, it allow to specify the
keyword of the content. Following is the example to show how to
definition element.
Example
<p><dfn>HTML </dfn> is a markup language. </p>
Quoting text:
The HTML <blockquote> element shows that the enclosed content is
quoted from another source. The Source URL can be given using the cite
attribute, and text representation of source can display using
<blockquote cite="https://www.keepinspiring.me/famous-quotes/"><p>?
The first step toward success is taken when you refuse to be a captive of the e
nvironment in which you first find yourself.?</p></blockquote>
<cite>-Mark Caine</cite>
Short Quotations:
An HTML <q> ....... </q> element defines a short quotation. If you will put
any content between <q> ....... </q>, then it will enclose the text in
<p>Steve Jobs said: <q>If You Are Working On Something That You Really C
are About, You Don?t Have To Be Pushed. The Vision Pulls You.</q></p>
Code tags
The HTML <code> </code> element is used to display the part of
computer code. It will display the content in monospaced font.
In HTML the keyboard tag, <kbd>, indicates that a section of content is a user input from
keyboard.
An HTML <address> tag defines the contact information about the author of
the content. The content written between <address> and </address> tag,
then it will be displayed in italic font.
4) height
It is the height of the image. The HTML height attribute also supports iframe, image and
object elements. It is not recommended now. You should apply CSS in place of height
attribute.
5) Border
It is an optional attribute which is used to show the border around the image
Use of height and width Example:
attribute with img tag
<img src="animal.jpg" height="180" width="300"
You have learnt about how alt="animal image">
to insert an image in your <!DOCTYPE html>
web page, now if we want <html>
to give some height and
width to display image <head>
<title>Using Image in Webpage</title>
according to our </head>
requirement, then we can
set it with height and width <body>
attributes of image. <p>Simple Image Insert</p>
<img src = "/html/images/test.png" alt = "Test
Image" />
</body>
</html>
Set Image Border
By default, image will have a border around it, you can specify border
thickness in terms of pixels using border attribute. A thickness of 0
means, no border around the picture.
Example
<!DOCTYPE html>
<html>
<head>
<title>Set Image Border</title>
</head>
<body>
<p>Setting image Border</p>
<img src = "/html/images/test.png" alt = "Test Image" border = "3"/>
</body>
</html>
HTML Table
Tag Description
<table> It defines a table.
<tr> It defines a row in a table.
<th> It defines a header cell in a table.
<td> It defines a cell in a table.
<caption> It defines the table caption.
It specifies a group of one or more columns in a table
<colgroup>
for formatting.
It is used with <colgroup> element to specify
<col>
column properties for each column.
<tbody> It is used to group the body content in a table.
<body>
<table border = "1">
<tr>
<th>Team</th> Team Ranking
<th>Ranking</th>
</tr> India 1
<tr>
<td>India</td>
South Africa 2
<td>1</td>
</tr> Australia 3
<tr>
<td>South Africa</td>
<td>2</td>
</tr>
<tr>
<td>Australia</td>
<td>3</td>
</tr>
</table>
</body>
</html>
Table Caption
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Tag Usage</title>
</head>
<body>
<table border = "1">
<caption>This is Table Caption</caption>
<tr>
<th>Name</th>
<th>Country</th>
</tr>
<tr>
<td>Dhoni</td>
<td>India</td>
</tr>
<tr>
<td>David Miller</td>
<td>South Africa</td>
</tr>
<tr>
<td>Joe Root</td>
<td>England</td>
</tr>
</table>
</body>
Table Cell Spacing
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Tag Usage</title>
</head>
<body>
<table border = "1" cellspacing = "5">
<tr>
<th>Name</th>
<th>Country</th>
</tr>
<tr>
<td>Dhoni</td>
<td>India</td>
</tr>
<tr>
<td>David Miller</td>
<td>South Africa</td>
</tr>
<tr>
<td>Joe Root</td>
<td>England</td>
</tr>
</table>
</body>
Table Cell Padding
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Tag Usage</title>
</head>
<body>
<table border = "1" cellpadding = "5">
<tr>
<th>Name</th>
<th>Country</th>
</tr>
<tr>
<td>Dhoni</td>
<td>India</td>
</tr>
<tr>
<td>David Miller</td>
<td>South Africa</td>
</tr>
<tr>
<td>Joe Root</td>
<td>England</td>
</tr>
</table>
</body>
Column and Row Span
Attributes
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Tag Usage</title>
</head>
<body>
<table border = "1">
<tr>
<th>Column One</th>
<th>Column Two</th>
<th>Column Three</th>
</tr>
<tr>
<td rowspan = "2">Row One</td>
<td>Row Two</td>
<td>Row Three</td>
</tr>
<tr>
<td>Row Four</td>
<td>Row Five</td>
</tr>
<tr>
<td colspan = "3">Row Six</td>
</tr>
</table>
Background for Table
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Tag Usage</title>
</head>
<body>
<table border = "1" bordercolor = "red" bgcolor = "lightblue">
<tr>
<th>Name</th>
<th>Country</th>
</tr>
<tr>
<td>Dhoni</td>
<td>India</td>
</tr>
<tr>
<td>David Miller</td>
<td>South Africa</td>
</tr>
<tr>
<td>Joe Root</td>
<td>England</td>
</tr>
</table>
</body>
Height and Width of the
Table
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Tag Usage</title>
</head>
<body>
<table border = "1" width = "500" height = "250" bgcolor = "lightblue">
<tr>
<th>Name</th>
<th>Country</th>
</tr>
<tr>
<td>Dhoni</td>
<td>India</td>
</tr>
<tr>
<td>David Miller</td>
<td>South Africa</td>
</tr>
<tr>
<td>Joe Root</td>
<td>England</td>
</tr>
</table>
</body>
Table Header, Body, and
Footer
<table>
<thead>
<tr>
<th colspan="2">October</th>
<th colspan="2">November</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sales</td>
<td>Profit</td>
<td>Sales</td>
<td>Profit</td>
</tr>
<tr>
<td>$200,00</td>
<td>$50,00</td>
<td>$300,000</td>
<td>$70,000</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan= "4">November was more produstive</th>
</tr>
</tfoot>
</table>
Frame Attributes
<!DOCTYPE html> <table frame="vsides">
<html> <tr>
<th>NAME</th>
<head> <th>AGE</th>
<title> <th>BRANCH</th>
HTML table frame Attribute </tr>
</title> <tr>
</head> <td>BITTU</td>
<td>22</td>
<body> <td>CSE</td>
<h1>Table Example</h1> </tr>
</table>
<h2>HTML table frame Attribute</h2> <br>
<table frame="hsides">
<table frame="box"> <tr>
<tr> <th>NAME</th>
<th>NAME</th> <th>AGE</th>
<th>AGE</th> <th>BRANCH</th>
<th>BRANCH</th> </tr>
</tr> <tr>
<tr> <td>BITTU</td>
<td>BITTU</td> <td>22</td>
<td>22</td> <td>CSE</td>
<td>CSE</td> </tr>
</tr> </table>
</table> </body>
<br>
</html>
Frame Attributes
<!DOCTYPE HTML >
<html>
<head>
<title> Example of HTML frame attribute with table
</title>
</head>
<body>
<table frame="border">
<tr>
<th>Employee code </th>
<th>Salary</th>
</tr>
<tr>
<td>EM001</td>
<td>Rs. 50000</td>
</tr>
<tr>
<td>EM002</td>
<td>Rs. 75000</td>
</tr>
</table>
</body>
</html>
Frame Attributes
<table border="10" frame="ABOVE" rules="NONE">
<table border="10" frame="BELOW" rules="NONE">
<table border="1" frame="BOX" rules="NONE">
<table border="8" frame="HSIDES" rules="NONE">
<table border="8" frame="LHS" rules="NONE">
<table border="8" frame="RHS" rules="NONE">
<TABLE BORDER="2" FRAME="VOID" RULES="ALL">
<TABLE BORDER="8" FRAME="VSIDES" RULES="NONE">
HTML summary attribute
<!DOCTYPE HTML >
<html>
<head>
<title>Example of HTML summary attribute with table element</title>
</head>
<body>
<table border="1" summary="This is table of country and their capitals. First
column describes country and the second column describe capital." >
<tr>
<td>India</td>
<td>New Delhi</td>
</tr>
<tr>
<td>UK</td>
<td>London</td>
</tr>
</table>
</body>
</html>
HTML - Lists
<ul> − An unordered list. This will list items using plain bullets.
<ol> − An ordered list. This will use different schemes of numbers
to list your items.
<dl> − A definition list. This arranges your items in the same way as
they are arranged in a dictionary.
HTML Unordered Lists
You can use type attribute for <ul> tag to specify the type of bullet
you like. By default, it is a disc. Following are the possible options
be used. This list is created by using <ol> tag. The numbering starts at one and is incremented by one
You can use type attribute for <ol> tag to specify the type of numbering you like. By default, it is a
HTML and XHTML supports a list style which is called definition lists
where entries are listed like in a dictionary or encyclopedia. The definition
list is the ideal way to present a glossary, list of terms, or other
name/value list.
<!DOCTYPE html>
<html>
<head>
<title>HTML Definition List</title>
</head>
<body>
<dl>
<dt><b>HTML</b></dt>
<dd>This stands for Hyper Text Markup Language</dd>
<dt><b>HTTP</b></dt>
<dd>This stands for Hyper Text Transfer Protocol</dd>
</dl>
</body>
</html>
Marquee HTML
Attribute Description
In slide marquee, all the contents to be scrolled will slide the entire length
of marquee but stops at the end to display the content permanently.
The HTML <div> tag is used to group the large section of HTML elements
together.
We know that every tag has a specific purpose e.g. p tag is used to specify
paragraph, <h1> to <h6> tag are used to specify headings but the <div> tag
is just like a container unit which is used to encapsulate other page
elements and divides the HTML documents into sections.
The div tag is generally used by web developers to group HTML elements
together and apply CSS styles to many elements at once. For example: If
you wrap a set of paragraph elements into a div element so you can take
the advantage of CSS styles and apply font style to all paragraphs at once
instead of coding the same style for each paragraph element.
div Tag example
<!DOCTYPE html>
<html>
<head>
<title>The Div Tag</title>
</head>
<body>
<h1> Div Tag </h1>
<div>
<p>We use the div tag to group two paragraphs for applying a background
to the text, and to add color to this
word we place it within spantag.</p>
<p> Pay attention, that the div tag is a block-level element, so a line break
is placed before and after
it.</p>
</div>
</body>
</html>
HTML iframes
HTML Iframe is used to display a nested webpage (a webpage within a webpage).
The HTML <iframe> tag defines an inline frame, hence it is also called as an Inline
frame.
An HTML iframe embeds another document within the current HTML document in
the rectangular region.
The webpage content and iframe contents can interact with each other using
JavaScript.
Attributes
src
height
width
name
Attributes of <iframe>
Attribute
Value Description
name
allowfullscre
If true then that frame can be opened in full screen.
en
It defines the height of the embedded iframe, and the
height Pixels
default height is 150 px.
It gives the name to the iframe. The name attribute is
name text
important if you want to create a link in one frame.
It defines whether iframe should have a border or not.
frameborder 1 or 0
(Not supported in HTML5).
It defines the width of embedded frame, and default
Width Pixels
width is 300 px.
The src attribute is used to give the path name or file
src URL
name which content to be loaded into iframe.
</body>
</html>
HTML Layouts
HTML layouts provide a way to arrange web
pages in well-mannered, well-structured, and
in responsive form or we can say that HTML
layout specifies a way in which the web pages
can be arranged. Web-page layout works with
arrangement of visual elements of an HTML
document.
Web page layout is the most important part to
keep in mind while creating a website so that
our website can appear professional with the
great look. You can also use CSS and
JAVASCRIPT based frameworks for creating
layouts for responsive and dynamic website
designing.
HTML Layout
Tag Description
<datalis It specifies a list of pre-defined
t> options for input control.
<keygen It defines a key-pair generator
> field for forms.
<output It defines the result of a
> calculation.
HTML Form Input Types
In HTML <input type=" "> is an important element of HTML form.
The "type" attribute of input element can be various types, which
defines information field. Such as <input type="text" name="name">
gives a text box.
type=" " Description
text Defines a one-line text input field
password Defines a one-line password input field
datetime-local Defines an input field for entering a date without time zone.
month Defines a control with month and year, without time zone.
search Defines a single line text field for entering a search string.
<form>
<label>Select file to upload:</label>
<input type="file" name="newfile">
<input type="submit" value="submit">
</form>
</body>
</html>
Example –Date
<!DOCTYPE html>
<html>
<body>
<h3>Input "date" type</h3>
<form>
Select Start and End Date: <br><br>
<input type="date" name="Startdate"> Start date:<br><br>
<input type="date" name="Enddate"> End date:<br><br>
<input type="submit">
</form>
</body>
</html>
Example –Email
<!DOCTYPE html>
<html>
<body>
<h3>Input "email" type</h3>
<form>
<label><b>Enter your Email-address</b></label>
<input type="email" name="email" required>
<input type="submit">
<p><strong>Note:</strong>User can also enter multiple email addresses separating by comma or
whitespace as following: </p>
<label><b>Enter multiple Email-addresses</b></label>
<input type="email" name="email" multiple>
<input type="submit">
</form>
</body>
</html>
Example –Color input
<!DOCTYPE html>
<html>
<body>
<h3>Input "color" types:</h3>
<form>
Pick your Favorite color: <br><br>
<input type="color" name="upclick" value="#a52a2a"> Up-
click<br><br>
<input type="color" name="downclick" value="#f5f5dc"> Down-click
</form>
<p><strong>Note:</strong>The default value of "color" type is
#000000 (black). It only supports color value in hexadecimal
format.</p>
</body>
</html>
Example - email
<!DOCTYPE html>
<html>
<body>
<h3>Input "email" type</h3>
<form>
<label><b>Enter your Email-address</b></label>
<input type="email" name="email" required>
<input type="submit">
<p><strong>Note:</strong>User can also enter multiple email addresses
separating by comma or whitespace as following: </p>
<label><b>Enter multiple Email-addresses</b></label>
<input type="email" name="email" multiple>
<input type="submit">
</form>
</body>
</html>
Example - Month
<!DOCTYPE html>
<html>
<body>
<h3>Input "month" type:</h3>
<form>
<label>Enter your Birth Month-year: </label>
<input type="month" name="newMonth">
<input type="submit">
</form>
</body>
</html>
Example - Number
<!DOCTYPE html>
<html>
<body>
<h3>Input "number" type</h3>
<form>
<label>Enter your age: </label>
<input type="number" name="num" min="50" max="80">
<input type="submit">
</form>
<p><strong>Note:</strong>It will allow to enter number in range of 50-
80. If you want to enter number other than range, it will show an
error.</p>
</body>
</html>
Input Type Hidden
<form action="/action_page.php">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<input type="hidden" id="custId" name="custId" value="3487">
<input type="submit" value="Submit">
</form>
<p><strong>Note:</strong> The hidden field is not shown to the user, but the data is
sent when the form is submitted.</p>
</body>
</html>
HTML <input type="range">
<!DOCTYPE html>
<html>
<body>
<h1>Display a Range Field</h1>
<form >
<label for="vol">Volume (between 0 and 100):</label>
<input type="range" id="vol" name="vol" min="0" max="100" step="5">
<input type="submit">
</form>
</body>
</html>
A range control with hash
marks
This range control is using a list attribute specifying the ID of a <
datalist> which defines a series of hash marks on the control. There
are eleven of them, so that there's one at 0% as well as at each
10% mark. Each point is represented using an <option> element
with its value set to the range's value at which a mark should be
drawn.
Example
<html>
<head><title> Tick Marks </title>
</head>
<body>
<h1> Example of Tick Marks Range </h1>
<br>
<br>
<input type="range" list="tickmarks">
<datalist id="tickmarks">
<option value="0"></option>
<option value="10"></option>
<option value="20"></option>
<option value="30"></option>
<option value="40"></option>
<option value="50"></option>
<option value="60"></option>
<option value="70"></option>
<option value="80"></option>
<option value="90"></option>
<option value="100"></option>
</datalist>
</body>
The <select> Element
<!DOCTYPE html>
<html>
The <select> element defines a
<body>
drop-down list: <h2>The select Element</h2>
<p>The select element defines a
The <option> elements defines drop-down list:</p>
<form action="/action_page.php">
an option that can be selected.
<label for="cars">Choose a
By default, the first item in the car:</label>
<select id="cars" name="cars">
drop-down list is selected. <option
value="volvo">Volvo</option>
To define a pre-selected option,
<option
add the selected attribute to the value="saab">Saab</option>
<option value="fiat"
option: selected>Fiat</option>
<option
value="audi">Audi</option>
</select>
<!DOCTYPE html>
<html>
<body>
<h2>Visible Option Values</h2>
<p>Use the size attribute to specify the number of visible values.</p>
<form action="/action_page.php">
<label for="cars">Choose a car:</label>
<select id="cars" 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><br><br>
<input type="submit">
</form>
</body>
</html>
Allow Multiple Selections:
<!DOCTYPE html>
<html>
<body>
<h2>Allow Multiple Selections</h2>
<p>Use the multiple attribute to allow the user to select more than one value.</p>
<form action="/action_page.php">
<label for="cars">Choose a car:</label>
<select id="cars" 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><br><br>
<input type="submit">
</form>
<p>Hold down the Ctrl (windows) / Command (Mac) button to select multiple
options.</p>
</body>
</html>
The <textarea> Element
<!DOCTYPE html>
The <textarea> <html>
<body>
element defines a
<h2>Textarea</h2>
multi-line input field (a <p>The textarea element defines
text area): a multi-line input field.</p>
The rows attribute <form
specifies the visible action="/action_page.php">
number of lines in a <textarea name="message"
text area. rows="10" cols="30">The cat
The cols attribute was playing in the
specifies the visible garden.</textarea>
<br><br>
width of a text area.
<input type="submit">
</form>
</body>
</html>
The <fieldset> and
<legend> Elements
The <fieldset> element is used to group related data in a form.
The <legend> element defines a caption for the <fieldset> element.
<html>
<body>
<h2>Grouping Form Data with Fieldset</h2>
<p>The fieldset element is used to group related
data in a form, and the legend element defines a
caption for the fieldset element.</p>
<form action="/action_page.php">
<fieldset>
<legend>Enter Your Name:</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></body></html>
The <datalist> Element
The <datalist> element specifies a list <html>
of pre-defined options for an <input> <body>
element. <h2>The datalist Element</h2>
Users will see a drop-down list of the <p>The datalist element specifies a
pre-defined options as they input data. list of pre-defined options for an input
The list attribute of the <input> element.</p>
element, must refer to the id attribute of <form action="/action_page.php">
the <datalist> element. <input list=“browserlist"
name="browser">
<datalist id="browserlist">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
<input type="submit">
</form>
</body>
HTML <optgroup> Tag
The <optgroup> tag is used to group related options in a <select> element (drop-down list).
If you have a long list of options, groups of related options are easier to handle for a user.
<html>
<body>
<h1>The optgroup element</h1>
<form >
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
<input type="submit" value="Submit">
</form> </body> </html>
HTML Entities
auto
Specifies if and how the author thinks the audio should
preload metadata
be loaded when the page loads
none
</body>
</html>
HTML YouTube Videos
</body>
</html>
YouTube Autoplay + Mute
You can let your video start playing automatically when a user visits
the page, by adding autoplay=1 to the YouTube URL. However,
automatically starting a video is annoying for your visitors!
Add mute=1 after autoplay=1 to let your video start playing
automatically (but muted).
YouTube - Loop
<iframe width="420" height="315"
src="https://www.youtube.com/embed/tgbNymZ7vqY?
playlist=tgbNymZ7vqY&loop=1">
</iframe>
YouTube Controls
graphics.
Canvas has several methods for drawing paths, boxes, circles, text, and adding images.
Canvas Examples
A canvas is a rectangular area on an HTML page. By default, a canvas has no border and no content.
The markup looks like this:
<canvas id="myCanvas" width="200" height="100"></canvas>
Note: Always specify an id attribute (to be referred to in a script), and a width and height attribute to
define the size of the canvas. To add a border, use the style attribute.
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="200" height="100" style="border:1px
solid #000000;">
Your browser does not support the HTML canvas tag.
</canvas>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(95,50,40,0,2*Math.PI);
ctx.stroke();
</script>
</body>
</html>
HTML SVG Graphics
</body>
</html>
Example
<svg width="400" height="100">
<rect width="400" height="100" style="fill:rgb(0,0,255);stroke-
width:10;stroke:rgb(0,0,0)" /> </svg>
</body>
</html>
Differences Between SVG
and Canvas
SVG is a language for describing 2D graphics in XML.
Canvas draws 2D graphics, on the fly (with a JavaScript).
SVG is XML based, which means that every element is available within the
SVG DOM. You can attach JavaScript event handlers for an element.
In SVG, each drawn shape is remembered as an object. If attributes of an
SVG object are changed, the browser can automatically re-render the
shape.
Canvas is rendered pixel by pixel. In canvas, once the graphic is drawn, it
is forgotten by the browser. If its position should be changed, the entire
scene needs to be redrawn, including any objects that might have been
covered by the graphic.
Comparison of Canvas and
SVG
Canvas SVG