HTML
HTML
HTML Introductio
contains the visible page
n
content
The <h1> element defines
What is HTML?
a large heading
The <p> element defines a
HTML is the standard markup
language for creating Web paragraph
pages.
HTML stands for Hyper
HTML Tags
Text Markup Language TML tags are element names
HTML describes the
surrounded by angle brackets:
structure of Web pages <tagname>content goes
using markup here...</tagname>
HTML tags normally
HTML elements are the
building blocks of HTML come in pairs like <p>
pages and </p>
The first tag in a pair is
HTML elements are
represented by tags the start tag, the second
HTML tags label pieces of
tag is the end tag
The end tag is written like
content such as "heading",
"paragraph", "table", and the start tag, but with
so on a forward slash inserted
Browsers do not display
before the tag name
the HTML tags, but use Tip: The start tag is also called
them to render the content the opening tag, and the end
of the page tag the closing tag.
Example Explained
The <!DOCTYPE Open Notepad
html> declaration defines Open Start > Programs
this document to be HTML5 > Accessories > Notepad
The <html> element is the
root element of an HTML
HTML Headings
page HTML headings are defined with
The <head> element the <h1> to <h6> tags.
contains meta information <h1> defines the most
about the document important heading. <h6>
defines the least important
The <title> element
heading:
specifies a title for the
document
Example The title
<h1>This is heading
1</h1> Attribute
<h2>This is heading Here, a title attribute is added
2</h2> to the <p> element. The value
<h3>This is heading of the title attribute will be
3</h3> displayed as a tooltip when you
mouse over the paragraph:
HTML Example
<p title="I'm a tooltip">
Paragraphs This is a paragraph.
HTML paragraphs are defined </p>
with the <p> tag:
The href
Example
<p>This is a Attribute
paragraph.</p> HTML links are defined with
<p>This is another the <a> tag. The link address is
paragraph.</p> specified in the href attribute:
HTML Styles
<p style="font-
HTML family:courier;">This is
Background a paragraph.</p>
ents <html>
<head>
You can add comments to your <style>
HTML source by using the body {background-color: p
following syntax: owderblue;}
<!-- Write your comments h1 {color: blue;}
here --> p {color: red;}
<div class="cities">
<h2>Paris</h2>
<p>Paris is the capital HTML Iframe
and most populous city of
France.</p>
</div>
s
</body>
</html> Iframe Syntax
Using The class An HTML iframe is defined with
the <iframe> tag:
Attribute on <iframe src="URL"></
iframe>
Inline Elements Iframe - Set
<!DOCTYPE html>
<html> Height and
<head>
<style> Width
span.note {
font-size: 120%; Example
color: red; <iframe src="demo_iframe.
} htm" height="200" width="
</style> 300"></iframe>
</head> Result:-
<body>
Why XHTML?
Many pages on the internet
contain "bad" HTML.
This HTML code works fine in Text Input
most browsers (even if it does <input type="text"> defines a
not follow the HTML rules): one-line input field for text
HTML Forms
input:
Example
An HTML form contains form <form>
elements. First name:<br>
Form elements are different
<input type="text" name
types of input elements, like text
fields, checkboxes, radio ="firstname"><br>
buttons, submit buttons, and Last name:<br>
more. <input type="text" name
Example ="lastname">
<form </form>
action="action_page.php"> Result:-
First name:<br>
<input type="text"
name="firstname"
value="Mickey">
<br>
Last name:<br>
Last name:<br>
Radio Button <input type="text" name
Input ="lastname" value="Mouse"
><br><br>
<input type="radio"> defines <input type="submit" va
a radio button.
lue="Submit">
Radio buttons let a user select
</form>
ONE of a limited number of
choices:
Example
<form>
<input type="radio" nam
e="gender" value="male" c
hecked> Male<br>
Grouping Form
<input type="radio" nam Data with
e="gender" value="female"
> Female<br> <fieldset>
<input type="radio" nam The <fieldset> element is used
e="gender" value="other"> to group related data in a form.
Other The <legend> element defines
</form> a caption for the <fieldset>
Result:- element.
Example
<form action="action_page
.php">
<fieldset>
The Submit <legend>Personal
information:</legend>
Button First name:<br>
<input <input type="text" na
type="submit"> defines a me="firstname" value="Mic
button for submitting the form key"><br>
data to a form-handler. Last name:<br>
<form action="action_page <input type="text" na
.php"> me="lastname" value="Mous
First name:<br> e"><br><br>
<input type="text" name <input type="submit"
="firstname" value="Micke value="Submit">
y"><br>
</fieldset>
</form> The
<option
<textarea>
Element
The <select> The <textarea> element defines
a multi-line input field (a text
Element area):
Example
The <select> element defines
a drop-down list: <textarea name="message"
rows="10" cols="30">
Example The cat was playing in
<select name="cars"> the garden.
<option value="volvo">V </textarea>
olvo</option> value="audi">Audi</
<option value="saab">Sa option>
ab</option> </select>
<option value="fiat">Fi <br><br>
at</option> <input type="submit">
<option value="audi">Au </form>
di</option> Result:-
</select>
Result:-
selected attribute.
<form
action="action_page.php">
<select name="cars">
<option
value="volvo">Volvo</opti
on>
<option
value="saab">Saab</option
>
<option value="fiat"
selected>Fiat</option>
">
The <button> </datalist>
Element </form>
Result:-
The <button> element defines a
clickable button:
Example
<button type="button" onc HTML Input
lick="alert('Hello
World!')">Click Types
Me!</button>
Input Type Text
<input type="text"> defines
HTML5 a one-line text input field:
Example
<datalist> <form>
Element First name:<br>
<input type="text" name
The <datalist> element ="firstname"><br>
specifies a list of pre-defined Last name:<br>
options for an <input> element. <input type="text" name
Users will see a drop-down list of
="lastname">
the pre-defined options as they
input data.
</form>
Result:
Example
<form action="action_page
.php">
<input list="browsers">
<datalist id="browsers"
>
<option value="Intern
et Explorer"> Input Type
<option value="Firefox">
Password
<input
<option value="Chrome
type="password"> defines
"> a password field:
<option value="Opera">
<option value="Safari
Example
<form>
User name:<br>
<input type="text" name
="username"><br>
User password:<br>
<input type="password" Input Type
name="psw">
</form> Radio
Result:- <input type="radio"> defines
a radio button.
Radio buttons let a user select
ONLY ONE of a limited number
of choices:
HTML Input
Result:-
The disabled
Attribute The
The disabled attribute
specifies that the input field maxlength
is disabled
Example Attribute
The maxlength attribute
<form action="">
specifies the maximum
First name:<br> allowed length for the input
<input type="text" nam field:
e="firstname" value="J
ohn" disabled> Example
</form> <form action="">
Result:- First name:<br>
<input type="text" nam i">
e="firstname" maxlengt </datalist>
h="10">
</form>
Result:- The multiple
Attribute
The multiple attribute
specifies that the user is
The list allowed to enter more than
one value in the <input>
Attribute element.
The list attribute refers to a The multiple attribute works
<datalist> element that with the following input
contains pre-defined options types: email, and file.
for an <input> element. Example
Example A file upload field that
An <input> element with accepts multiple values:
pre-defined values in a Select
<datalist>: images: <input type="f
<input list="browsers" ile" name="img" multip
> le>
Result:-
<datalist id="browsers
">
<option value="Inter
net Explorer">
<option value="Firef
ox">
<option value="Chrom
e">
<option value="Opera
">
<option value="Safar
The
placeholder
Attribute
The hint is displayed
in the input field before
the user enters a value.
Example
An input field with a
placeholder text:
<input type="text" nam
e="fname" placeholder=
"First name">
Result:-
The step
Attribute
Example: if step="3",
legal numbers could be -
3, 0, 3, 6, etc.
Example
An input field with a
specified legal number
intervals:
<input type="number" n
ame="points" step="3">
Result:-