HTML NOTE.
HTML NOTE.
2
What is HTML?
• Hyper Text Markup Language
• HTML is the code that is used to structure a web page and its
content.
• HTML element tell the browser how to display the content.
• An HTML document is a text document saved with the .html or
.htm extension, containing text and specific tags enclosed in < >
• Created by Tim Berners-Lee in 1991 to structure content on the
World Wide Web.
HTML Tags
The component used to design the structure of websites are called
HTML tags.
Basically, It is a container for some content or other HTML tags. Most
of html elements have opening & closing tags.
An HTML element is a complete set that consists of a start tag (or
opening tag), content, and an end tag (or closing tag).
content
Element
3
Basic HTML Page
❖ <!Doctype>
4
❖ Head
5
❖ Meta
• Defines metadata about an HTML document. Metadata is
data(information) about data.
• Always placed inside the <head> tag.
• Not displayed on the page, but machine-parsable.
• Used by browsers, search engines, and other services.
Common Uses:
▪ <html lang=”en”>
6
❖ Title
1. The <title> tag defines the webpage's title, shown in the
browser tab and bookmarks.
2. It is placed within the <head> section of the HTML
document.
3. Essential for SEO, influencing search engine rankings and
click-through rates.
4. It appears in the browser tab, bookmarks, and search
engine results.
5. Improves accessibility by helping users understand the
page's purpose.
6. Only one <title> tag is allowed per HTML document.
❖ Body
1. The <body> tag defines the main content of an HTML
document displayed in the browser.
2. It contains all visible elements like text, images, videos,
and interactive features.
3. Placed directly after the <head> and before the closing
<html> tag.
4. Only one <body> tag is allowed per HTML document.
5. Attributes like class, id, and style can be used to apply
styles and scripts.
6. JavaScript can manipulate the <body> content for
dynamic updates.
7
First HTML File name [ index.html ]
It is the default name for a website's homepage.
❖ Comment
▪ Syntax: <!-- Comment -->
▪ Not displayed on the webpage.
▪ Explains code, disables code, or adds notes.
8
❖ Tags in HTML
9
10
Document Structure
• <html>
• <head>
• <title>
• <body>
• <a href="URL" target="_blank"> (for linking to another
page or resource)
11
Text Content
Lists
Tables
• <table>
• <thead>
• <tfoot>
• <tr> (table row)
• <th> (table header)
• <td> (table cell)
Forms
• <form>
• <select>
• <input type="text">
• <input type="password">
• <input type="email">
• <input type="radio">
• <input type="checkbox">
• <textarea>
• <button>
12
• <option>
• <fieldset>
• <legend>
Semantic Elements
Meta Tags
• <meta charset="UTF-8">
• <meta name="viewport" content="width=device-width,
initial-scale=1.0">
• <meta name="description" content="Description here">
• <meta name="keywords" content="keyword1,
keyword2">
Attributes
• id="value"
• class="value"
• placeholder="value"
• title="value"
• disabled
• alt="value"
• checked
13
• required
• readonly
• href="URL"
• type="type"
Media
• <audio>
• <video>
• <source>
• defer (for deferring the execution of a script)
• async (for asynchronous script loading)
❖ Attributes
Attributes defines the properties or characteristics of a html
element.
▪ Attributes modify the behavior, functionality, or
appearance of an element by providing additional
information.
▪ They allow you to customize the behavior of HTML
elements.
Example: <html lang="en">
14
❖ Heading tags
• Its defines heading
• Displayed in larger and bolder font
❖ <br>
Used to insert black line in the document. Self closing tag.
Syntax: <br>
❖ Horizontal ruler
Used to draw horizontal line across the web page.
Syntax: <hr>
❖ Bold tags
Defines bold text.
Syntax: <b>Sabika</b>
❖ Italic tag
Defines italic text .
Syntax: <i> Afrin</i>
15
❖ Big tag
Defines big text.
Syntax: <big></big>
❖ Small tag
Defines small text.
Syntax: <big></big>
❖ Sup tag
Defines superscripted text.
Syntax: <sup>hello</sup>
❖ Sub tag
❖ Anchor Tag
Used to add links to your page
Syntax: <a href="https://google.com"> Google </a>
<a href="https://example.com" target="_blank">Visit
Example</a>
16
_top: Opens in the full body of the window.
_framename: Opens in a named frame or iframe.
❖ Image Tag
Used to add images to your page
Syntax: <img src="/image.png" alt="Random Image">
scr means source & alt means alternative text.
❖Video Tag
<video src="myVid.mp4"> My Video </video>
Attributes
- controls
- height
- width
- loop
- autoplay
❖Pre Tag
Used to display text as it is (without ignoring spaces & next line)
Syntax: <pre> This
is a sample
text.
</pre>
17
❖Div Tag
o Div is a container used for other HTML elements
o Block Element (takes full width)
o Used for grouping and organizing content.
o Primarily for styling and layout with CSS.
❖Span Tag
o Span is also a container used for other HTML elements
o Inline Element (takes width as per size)
o used for styling or grouping small pieces of content within a line.
Example:
<body>
<div>
<h1> Welcome to my website </h1>
</div>
<div>
<p>This is a simple example using div </p>
</div>
</body>
18
List : Div Tags
<address> <fieldset>
<article> <figcaption>
<aside> <figure>
<canvas> <footer>
<dd> <form>
<div> <h1>-<h6>
<dl> <header>
<dt> <hr>
<main <li>
❖List in HTML
Lists are used to represent real life list data.
▪ Unordered list
<ul>
<li> Apple </li>
<li> Mango </li>
</ul>
19
▪ Ordered list
<ol>
<li> Apple </li>
<li> Mango </li>
</ol>
❖Table
• <table> defines a table structure
• <tr> is used for table rows.
• <td> defines table data (cells).
• <th> defines table headers.
Example:
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>afrin</td>
<td>21</td>
</tr>
<tr>
<td>sabika</td>
<td>23</td>
</tr>
</table>
Output:
20
1. <caption>: Provides a title or
description for the table.
<table>
<caption>EmployeeInformation</caption>
</table>
21
❖ Form in HTML
Forms are used to collect data from the
user.
1. <form>: Container for all form elements, specifies
action and method (GET/POST).
2. <input>: Defines interactive controls (text, radio,
checkbox, button).
3. <label>: Associates a label with a form element for
accessibility.
4. <textarea>: Multi-line input for text content.
5. <select> and <option>: Creates dropdown menus
for selecting values.
6. <button>: Creates clickable buttons for form
submission or actions.
7. Forms are used for collecting user input and
submitting it to a server.
8. Checkbox: A checkbox is an input element in forms that
allows users to select one or more options from a list.
22
1. USE AUTOFOCUS FOR INPUT FIELDS
Explanation: The autofocus attribute automatically focuses
on a specific input field when the page loads, improving the
user experience for login or search pages.
23
4. USE THE REQUIRED ATTRIBUTE
Explanation: The required attribute ensures users fill in a particular
field before submitting the form.
24
25
Output:
26