Html


πŸ•ΈοΈ The History of HTML – From 1991 to the Living Web

HTML (HyperText Markup Language) is the backbone of the web. Here’s a timeline of how it evolved from a simple document structure to a powerful tool for building rich internet applications.

πŸ“œ 1991 – Birth of HTML

Tim Berners-Lee publishes the first HTML specification with just 18 basic tags.

πŸ“˜ 1995 – HTML 2.0

The first standardized version by IETF. Introduced forms, basic tables, and structure.

🧩 1997 – HTML 3.2

Published by W3C. Added tables, applets, scripting support, and improved styles.

πŸ“š 1999 – HTML 4.01

Introduced frames, better forms, and international language support.

πŸ”§ 2000 – XHTML 1.0

A stricter, XML-based version of HTML. More rules, cleaner code.

πŸ› οΈ 2004 – The Rise of WHATWG

A new group (WHATWG) begins working on a modern, application-friendly HTMLβ€”HTML5.

πŸš€ 2014 – HTML5 Standard Released

Introduces <video>, <audio>, <canvas>, semantic tags like <article>, <section>, and more.

πŸ”„ Today – HTML Living Standard

HTML is now continuously updated by WHATWG. No more versionsβ€”just ongoing improvements.


βœ… Why It Matters for Web Developers

Modern HTML allows:

  • Semantic SEO-friendly markup
  • Native support for multimedia
  • Better accessibility
  • Offline and interactive web apps

πŸ“˜ Introduction to HTML

HTML (HyperText Markup Language) is the foundation of all web pages. It provides the structure and layout for content on the internet. Every websiteβ€”from simple blogs to complex web appsβ€”starts with HTML.

βœ… What You’ll Learn:

  • What HTML is and why it matters
  • Basic HTML tags and structure
  • How to write your first HTML page


πŸ“˜ Introduction to HTML

HTML (HyperText Markup Language) is the foundation of all web pages. It provides the structure and layout for content on the internet. Every websiteβ€”from simple blogs to complex web appsβ€”starts with HTML.

βœ… What You’ll Learn:

  • What HTML is and why it matters
  • Basic HTML tags and structure
  • How to write your first HTML page

πŸ“„ Example:

<!DOCTYPE html>
<html>
  <head>
    <title>My First HTML Page</title>
  </head>
  <body>
    <h1>Welcome to HTML!</h1>
    <p>This is a simple webpage structure.</p>
  </body>
</html>

πŸ”— Tip: Use proper tags like <h1> to <h6> for headings, <p> for paragraphs, and <a> for links to keep your content structured and SEO-friendly.



πŸ”Ή What are HTML Elements?

An HTML element is everything from the opening tag to the closing tag, including the content in between. Elements are the building blocks of an HTML page.

πŸ“Œ Syntax:

<tagname>Content goes here</tagname>


🧩 Common HTML Elements

ElementDescription
<h1> to <h6>Headings (h1 = largest, h6 = smallest)
<p>Paragraph
<a>Anchor (link)
<img>Image
<div>Division/Container
<span>Inline container
<ul>, <ol>, <li>Lists (unordered, ordered, list items)
<table>Table structure
<form>Form for user input
<input>, <button>Input fields and buttons

βœ… Example:

<h2>My Favorite Tools</h2>
<ul>
  <li>Visual Studio Code</li>
  <li>Google Chrome</li>
  <li>GitHub</li>
</ul>

πŸ“ Tip: Keep your HTML semantic and clean for better accessibility and SEO.



🎯 What are HTML Attributes?

HTML attributes provide extra information about HTML elements. They are always added to the start tag and usually come in name=”value” pairs.


πŸ”‘ Common HTML Attributes

AttributeDescriptionExample
idUnique identifier<p id="intro">
classGrouping for styling<div class="card">
srcSource for images/media<img src="image.jpg">
hrefURL for links<a href="https://example.com">
altImage description<img alt="Logo">
titleTooltip text<p title="Hello!">
styleInline CSS styling<h1 style="color:blue;">

βœ… Example:

<a href="https://codewithhari.dev" target="_blank" title="Visit my blog">
  Visit Code With Hari
</a>

πŸ“ Tip: Use alt for images to improve accessibility and SEO.



🧩 What Are HTML Headings?

HTML headings are used to define the structure and hierarchy of your content. They range from <h1> (most important) to <h6> (least important).


πŸ”’ Types of HTML Headings

<h1>This is an H1 Heading</h1>
<h2>This is an H2 Heading</h2>
<h3>This is an H3 Heading</h3>
<h4>This is an H4 Heading</h4>
<h5>This is an H5 Heading</h5>
<h6>This is an H6 Heading</h6>





✍️ HTML Paragraphs – Structure Your Content Clearly

In HTML, the <p> tag defines a paragraph. It automatically adds spacing above and below your text.


πŸ§ͺ Example:

<p>This is a paragraph of text in HTML. It is wrapped inside &lt;p&gt; tags.</p>




❌ Avoid This:

<p>This is a paragraph
without closing tag or proper spacing</p>

Instead, use multiple <p> tags for clarity.


πŸ–‹οΈ HTML Text Formatting – Style Your Words with Meaning

HTML provides several tags to format and emphasize text. These tags help with styling, semantics, and accessibility.


πŸ”€ Common Formatting Tags

TagPurposeExample
<b>Bold (no meaning)<b>Bold</b> β†’ Bold
<strong>Bold (important)<strong>Important</strong> β†’ Important
<i>Italic (no meaning)<i>Italic</i> β†’ Italic
<em>Emphasized (semantic italic)<em>Emphasis</em> β†’ Emphasis
<u>Underline<u>Underline</u> β†’ Underline
<mark>Highlight text<mark>Highlight</mark> β†’ Highlight
<small>Smaller text<small>Note</small> β†’ Note
<del>Deleted text (strikethrough)<del>Old</del> β†’ Old
<ins>Inserted text (underlined)<ins>New</ins> β†’ New
<sub>SubscriptH<sub>2</sub>O β†’ H2O
<sup>Superscriptx<sup>2</sup> β†’ x2


πŸ“Œ SEO Note:

Semantic tags like <strong> and <em> help search engines understand what content is important or emphasized.



πŸ“ HTML Quotation & Citation Tags – Give Credit Where It’s Due

HTML provides specific tags to handle quotes, citations, and referencesβ€”great for blogs, articles, and academic content.


🧾 Quotation & Citation Tags

TagPurposeExample Output
<blockquote>Long/paragraph quote (with indent)
<blockquote cite="https://example.com">
  The future belongs to those who prepare for it today.
</blockquote>

β†’

The future belongs to those who prepare for it today.

| <q> | Short inline quote |

She said, <q>Hello World</q>.

β†’
She said, β€œHello World”.

| <cite> | Citation for a creative work |

<cite>The Great Gatsby</cite>  

β†’ The Great Gatsby (usually italic)

| <abbr> | Abbreviation with tooltip meaning |

<abbr title="World Health Organization">WHO</abbr>  

β†’ WHO (hover shows “World Health Organization”)

| <address> | Author/contact info |

<address>Contact us at info@example.com</address>  



πŸ“Œ SEO Tip:

Tags like <cite> and <blockquote> signal credibility and authorship, which search engines value in high-quality content.



πŸ’¬ HTML Comments

HTML comments are used to leave notes inside the code. These notes are not displayed in the browser.


πŸ”§ Syntax

<!-- This is a comment -->


πŸ§ͺ Example

<p>This is visible content.</p>
<!-- <p>This paragraph is hidden and won't be rendered.</p> -->

Only the first paragraph will be shown in the browser.


βœ… Use Cases

  • To describe the structure of your HTML
  • To temporarily hide parts of code
  • To leave reminders or notes for yourself or other developers

⚠️ Important

  • Comments are visible in page source, so avoid placing sensitive information in them.
  • Browsers completely ignore comment content during rendering.

Here’s a concise explanation of HTML Images for your blog post:


πŸ–ΌοΈ HTML Images – Displaying Pictures on Web Pages

To display images in HTML, use the <img> tag. It is a self-closing tag and requires the src and alt attributes.


πŸ”§ Syntax

<img src="path-to-image.jpg" alt="Description of image">


βœ… Attributes

  • src: The path or URL to the image file
  • alt: Alternative text shown if the image fails to load or for screen readers

πŸ§ͺ Example

<img src="sunset.jpg" alt="A beautiful sunset over the hills">


πŸ“ Optional Attributes

  • width and height: To set image size <img src="logo.png" alt="Site Logo" width="150" height="150">
  • title: Tooltip text on hover <img src="icon.png" alt="Icon" title="Hover text">

⚠️ Best Practices

  • Always use alt for accessibility.
  • Use optimized image formats like .webp or .jpeg for better performance.
  • Avoid stretching by keeping the aspect ratio consistent.

Here’s a clean explanation of how to add a favicon in HTML for your blog post:


🌟 How to Add a Favicon in HTML

A favicon is the small icon that appears in the browser tab next to your page title.


πŸ”§ Syntax (Place in <head> section)

<link rel="icon" type="image/png" href="favicon.png">


βœ… Common Favicon Formats

  • .ico (classic format): <link rel="icon" href="favicon.ico">
  • .png (modern, preferred): <link rel="icon" type="image/png" href="favicon.png">
  • .svg (for scalable icons): <link rel="icon" type="image/svg+xml" href="favicon.svg">

πŸ“ Where to Place the File

  • Put the favicon file in your root folder (same as index.html)
  • Or specify the correct relative path in the href

Here’s a concise explanation of the HTML <head> element for your blog post:


🧠 HTML – The <head> Element

The <head> element is a container for metadata (data about data). It sits above the <body> and doesn’t display content directly on the webpage.


πŸ”§ Syntax

<head>
  <title>My Website</title>
  <meta charset="UTF-8">
  <meta name="description" content="Learn HTML basics">
  <link rel="stylesheet" href="styles.css">
  http://script.js
</head>


🧩 Common Elements Inside <head>

TagPurpose
<title>Sets the page title (shown in browser tab)
<meta>Describes page encoding, author, viewport, SEO
<link>Links to external CSS or icons (e.g., favicon)
<style>Internal CSS styles
<script>JavaScript files or inline scripts

πŸ“Œ Why It Matters

  • Improves SEO, page loading, and browser compatibility
  • Required for proper rendering and functionality


🧠 The HTML <head> Element – Explained with Examples

The <head> element is a container for metadataβ€”data about your HTML document. It is placed between <html> and <body>.

Metadata is not displayed on the page itself, but is used by browsers, search engines, and web services.


πŸ“¦ Elements Inside <head>

The <head> can contain:

  • <title> – Document title (shown in tab)
  • <style> – Internal CSS
  • <meta> – Metadata like description, keywords, charset
  • <link> – Link to external files (like CSS)
  • <script> – JavaScript files or inline code
  • <base> – Base URL for all relative URLs

🏷️ The <title> Element

Defines the page title.

<title>My Awesome Web Page</title>

βœ… Shown in browser tab
βœ… Required in all HTML docs
βœ… Critical for SEO – Used in search engine result titles


🎨 The <style> Element

Used to write internal CSS directly inside HTML:

<style>
  body { background-color: powderblue; }
  h1 { color: red; }
  p { color: blue; }
</style>


πŸ”— The <link> Element

Used to link external stylesheets or other resources:

<link rel="stylesheet" href="styles.css">

Common rel values:

  • stylesheet
  • icon (for favicon)
  • preload

🧬 The <meta> Element

Defines metadata. Here are common examples:

<meta charset="UTF-8">
<meta name="description" content="Learn HTML step-by-step">
<meta name="keywords" content="HTML, CSS, Web">
<meta name="author" content="Hari Mohan">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

πŸ“Œ viewport makes your site mobile-friendly
πŸ“Œ description improves search engine previews


πŸ§ͺ Full Example of a <head> Section

<!DOCTYPE html>
<html>
<head>
  <title>A Meaningful Page Title</title>
  <meta charset="UTF-8">
  <meta name="description" content="Learn HTML easily">
  <meta name="keywords" content="HTML, CSS, Tutorial">
  <meta name="author" content="Hari Mohan">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="styles.css">
  <style>
    h1 { color: darkblue; }
  </style>
  http://script.js
</head>
<body>
  <h1>Hello HTML!</h1>
</body>
</html>



🧱 HTML Layout Elements and Techniques – Building Page Structure

HTML provides semantic layout elements and several techniques to design structured and responsive web pages.


🧩 Semantic Layout Elements

These tags describe the structure of a page clearly for both developers and search engines:

ElementPurpose
<header>Defines a page or section header
<nav>Contains navigation links
<main>The main content of the document
<section>A thematic grouping of content
<article>Independent content (e.g., blog post)
<aside>Sidebar or tangential content
<footer>Footer for a section or page

πŸ§ͺ Example Layout:

<body>
  <header>
    <h1>My Website</h1>
  </header>

  <nav>
    <a href="#">Home</a>
    <a href="#">About</a>
  </nav>

  <main>
    <section>
      <h2>Welcome</h2>
      <p>This is the homepage content.</p>
    </section>

    <aside>
      <h3>News</h3>
      <p>Latest updates here.</p>
    </aside>
  </main>

  <footer>
    <p>&copy; 2025 My Website</p>
  </footer>
</body>


πŸ› οΈ Layout Techniques

TechniqueDescription
CSS FlexboxOne-dimensional layout (row or column)
CSS GridTwo-dimensional layout (rows + columns)
Media QueriesResponsive design for various screen sizes
Float & ClearOlder method; less common today
PositioningAbsolute, relative, fixed, and sticky layouts

πŸ“Œ Tips

  • Prefer semantic elements for clarity and accessibility.
  • Use CSS Grid for complex layouts and Flexbox for simpler structures.
  • Combine layout tags with CSS for responsive, well-structured designs.


πŸ“± HTML Responsive Web Design – Make It Look Great on All Devices

Responsive Web Design (RWD) ensures your website looks good on desktops, tablets, and mobile phones by adapting to different screen sizes.


πŸ”§ Key Techniques in Responsive Design

βœ… 1. Viewport Meta Tag

Tells the browser how to control the page’s dimensions and scaling:

<meta name="viewport" content="width=device-width, initial-scale=1.0">


βœ… 2. Responsive Images

Images that scale with screen size:

<img src="image.jpg" style="max-width: 100%; height: auto;">

Or use srcset for different resolutions:

<img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 768w" alt="Responsive image">


βœ… 3. Media Queries (CSS)

Apply different styles based on screen width:

@media (max-width: 768px) {
  body {
    background-color: lightblue;
  }
}


βœ… 4. CSS Flexbox & Grid

Use flex and grid layouts to rearrange content easily:

.container {
  display: flex;
  flex-wrap: wrap;
}


πŸ“Œ Why It Matters

  • Better user experience
  • Improves SEO and performance
  • Makes your site mobile-friendly, which is crucial today


🧩 HTML Semantic Elements – Meaningful Page Structure

Semantic HTML uses tags that clearly describe their purpose and content, making your code easier to read and more accessible.


🏷️ Common Semantic Elements

TagPurpose
<header>Defines a page or section header
<nav>Navigation links
<main>Main content of the document
<section>Thematic grouping of content
<article>Self-contained content (e.g., blog post)
<aside>Sidebar or additional info
<footer>Footer for a page or section
<figure>Used with <figcaption> for images/media

πŸ§ͺ Example:

<body>
  <header>
    <h1>My Blog</h1>
  </header>

  <nav>
    <a href="#">Home</a>
    <a href="#">Articles</a>
  </nav>

  <main>
    <article>
      <h2>Semantic HTML</h2>
      <p>This article explains semantic elements.</p>
    </article>

    <aside>
      <p>Related topics: Accessibility, SEO</p>
    </aside>
  </main>

  <footer>
    <p>&copy; 2025 My Blog</p>
  </footer>
</body>


βœ… Benefits of Semantic HTML

  • Improves SEO and screen reader support
  • Makes your code easier to maintain
  • Enhances browser and developer tool compatibility


πŸ“Š HTML Tables – Organize Data in Rows and Columns

HTML tables are used to display structured data like schedules, pricing, or comparisons.


πŸ”§ Basic Table Syntax

<table>
  <tr>
    <th>Language</th>
    <th>Type</th>
  </tr>
  <tr>
    <td>HTML</td>
    <td>Markup</td>
  </tr>
  <tr>
    <td>JavaScript</td>
    <td>Programming</td>
  </tr>
</table>


🧩 Tag Breakdown

TagPurpose
<table>Wraps the entire table
<tr>Defines a row
<th>Header cell (bold + centered text)
<td>Standard cell for data

✨ Optional Tags

  • <caption> – Title for the table
  • <thead> – Group header rows
  • <tbody> – Group body rows
  • <tfoot> – Group footer rows

🎨 Example with Styling

<table border="1">
  <caption>Web Technologies</caption>
  <thead>
    <tr><th>Name</th><th>Type</th></tr>
  </thead>
  <tbody>
    <tr><td>HTML</td><td>Markup</td></tr>
    <tr><td>CSS</td><td>Style Sheet</td></tr>
  </tbody>
</table>



πŸ“ HTML Table Borders – Make Your Tables Visible

By default, HTML tables have no borders. You can add borders using either the border attribute or CSS.


βœ… 1. Using the border Attribute (Old Method)

<table border="1">
  <tr>
    <th>Name</th>
    <th>Role</th>
  </tr>
  <tr>
    <td>Hari</td>
    <td>Frontend Dev</td>
  </tr>
</table>

  • Quick and easy
  • Not recommended for modern HTML (use CSS instead)

βœ… 2. Using CSS (Modern Method)

<style>
  table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
  }
</style>

<table>
  <tr>
    <th>Name</th>
    <th>Role</th>
  </tr>
  <tr>
    <td>Hari</td>
    <td>Frontend Dev</td>
  </tr>
</table>

  • border-collapse: collapse; removes double borders
  • More flexible and modern approach

✨ You Can Also Style:

  • Border color: border: 1px solid blue;
  • Rounded corners: border-radius: 5px;
  • Cell padding: padding: 10px;


πŸ“ HTML Table Sizes – Control Width and Height

You can control the size of tables using the width and height attributes (deprecated) or preferably with CSS.


βœ… 1. Using HTML Attributes (Not recommended)

<table width="400" height="200">
  <tr>
    <td>Fixed size table</td>
  </tr>
</table>

  • Uses pixels
  • Not responsive
  • Deprecated in modern HTML

βœ… 2. Using CSS (Modern Method)

<style>
  table {
    width: 100%;
    height: auto;
  }
  td {
    width: 50%;
    height: 100px;
  }
</style>

<table>
  <tr>
    <td>Left Cell</td>
    <td>Right Cell</td>
  </tr>
</table>

  • width: 100% makes the table responsive
  • Control individual cell sizes with td styles

πŸ” Responsive Tip

Use % for widths and avoid fixed pixel values for mobile-friendly design.

<table style="width: 100%;">
  <tr>
    <td style="width: 70%;">Main Content</td>
    <td style="width: 30%;">Sidebar</td>
  </tr>
</table>



🧾 HTML Table Headers – Add Meaning to Your Data

HTML table headers are created using the <th> tag and help define the titles of columns or rows in a table.


βœ… Basic Example

<table border="1">
  <tr>
    <th>Name</th>
    <th>Role</th>
  </tr>
  <tr>
    <td>Hari</td>
    <td>Frontend Developer</td>
  </tr>
</table>

  • <th> stands for table header
  • Text is bold and centered by default

🎯 Column vs. Row Headers

Column Headers (most common):

<tr>
  <th>Product</th>
  <th>Price</th>
</tr>

Row Headers (less common):

<tr>
  <th scope="row">HTML</th>
  <td>Markup Language</td>
</tr>

Use scope="col" or scope="row" for accessibility and screen readers.


🧠 Summary

TagPurposeDefault Style
<th>Table header cellBold & Centered
scopeAccessibility helpcol or row


πŸ“¦ HTML Table Padding & Spacing – Improve Table Readability

Padding and spacing control the whitespace inside and between table cells, improving how your table looks.


βœ… 1. Cell Padding (padding)

Defines space inside each cell between the content and cell border.

<style>
  td, th {
    padding: 10px;
  }
</style>


βœ… 2. Cell Spacing (border-spacing)

Defines space between table cells (outside the border).

<style>
  table {
    border-spacing: 15px;
  }
</style>

❗ Note: border-spacing only works when border-collapse: separate; is set (default).


βœ… 3. Collapse Borders & Remove Spacing

To make borders touch with no spacing:

<style>
  table {
    border-collapse: collapse;
  }
  th, td {
    border: 1px solid black;
    padding: 8px;
  }
</style>


🧠 Summary

PropertyWhat it Does
paddingSpace inside a cell
border-spacingSpace between cells
border-collapseMakes borders collapse into one


πŸ”— HTML Table colspan & rowspan – Merge Table Cells

Use colspan and rowspan attributes in HTML tables to merge cells across columns or rows, making your data display more flexible.


πŸ”Έ colspan – Merge Columns

Joins two or more columns into a single cell.

<table border="1">
  <tr>
    <th colspan="2">Full Name</th>
  </tr>
  <tr>
    <td>Hari</td>
    <td>Mohan</td>
  </tr>
</table>

βœ… Result: β€œFull Name” spans both columns above “Hari” and “Mohan”.


πŸ”Ή rowspan – Merge Rows

Joins two or more rows into a single cell.

<table border="1">
  <tr>
    <th rowspan="2">Name</th>
    <td>Frontend</td>
  </tr>
  <tr>
    <td>Developer</td>
  </tr>
</table>

βœ… Result: β€œName” spans both rows beside “Frontend” and “Developer”.


🧠 Summary

AttributePurpose
colspanMerge cells horizontally (columns)
rowspanMerge cells vertically (rows)


πŸ“¬ HTML Forms – Collect User Input Easily

HTML forms let users submit data to a web server β€” for things like login, registration, feedback, or searches.


🧩 Basic Form Structure

<form action="/submit" method="post">
  <label for="name">Name:</label>
  <input type="text" id="name" name="name">

  <br><br>

  <label for="email">Email:</label>
  <input type="email" id="email" name="email">

  <br><br>

  <input type="submit" value="Submit">
</form>


πŸ§ͺ Common Form Elements

TagDescription
<form>Container for input fields
<input>User inputs (text, email, password)
<label>Label for input
<textarea>Multi-line input
<select>Dropdown list
<option>Options inside dropdown
<button>Clickable button

πŸ“₯ Example with Dropdown & Textarea

<form>
  <label for="feedback">Feedback:</label><br>
  <textarea id="feedback" name="feedback" rows="4" cols="40"></textarea><br><br>

  <label for="role">Role:</label>
  <select id="role" name="role">
    <option value="developer">Developer</option>
    <option value="designer">Designer</option>
  </select><br><br>

  <button type="submit">Send</button>
</form>


βœ… Attributes to Know

  • action – URL to submit form data
  • method – GET or POST
  • required – Makes a field mandatory
  • placeholder – Placeholder text inside input


🧩 HTML Form Elements – Build Interactive Forms

HTML form elements are used to collect different types of user input like text, selections, files, and buttons.


🧱 Common Form Elements

ElementPurpose
<input>Basic input fields (text, email, etc.)
<label>Describes input field
<textarea>Multi-line text input
<select>Drop-down menu
<option>Items inside a <select>
<button>Clickable button
<fieldset>Group related fields
<legend>Title for a <fieldset>

πŸ§ͺ Example Form with All Elements

<form>
  <fieldset>
    <legend>Contact Us</legend>

    <label for="name">Name:</label>
    <input type="text" id="name" name="name"><br><br>

    <label for="email">Email:</label>
    <input type="email" id="email" name="email"><br><br>

    <label for="message">Message:</label><br>
    <textarea id="message" name="message" rows="4" cols="40"></textarea><br><br>

    <label for="role">Role:</label>
    <select id="role" name="role">
      <option value="dev">Developer</option>
      <option value="design">Designer</option>
    </select><br><br>

    <button type="submit">Submit</button>
  </fieldset>
</form>


βœ… Tip

Combine these elements to build login forms, feedback forms, surveys, and more.



πŸŽ›οΈ HTML Input Types – Collect the Right Kind of Data

The <input> tag in HTML supports many type values that define the kind of data a user can enter.


πŸ”§ Common Input Types

TypeDescriptionExample
textSingle-line text<input type="text">
emailEmail format validation<input type="email">
passwordMasked text input<input type="password">
numberNumeric input with step/limit options<input type="number" min="1" max="100">
telPhone number<input type="tel">
urlWebsite URL<input type="url">
searchSearch field with clear button (browser)<input type="search">
checkboxToggle one or more options<input type="checkbox">
radioChoose one from a group<input type="radio" name="gender">
dateDate picker<input type="date">
timeTime picker<input type="time">
rangeSlider input<input type="range" min="0" max="10">
colorColor picker<input type="color">
fileUpload file<input type="file">
submitSubmit the form<input type="submit" value="Send">
resetReset form values<input type="reset">
hiddenInvisible data for backend processing<input type="hidden" name="userid" value="123">

πŸ§ͺ Mini Example

<form>
  <input type="text" placeholder="Your Name"><br>
  <input type="email" placeholder="Your Email"><br>
  <input type="checkbox"> Subscribe<br>
  <input type="submit" value="Submit">
</form>



βš™οΈ HTML Input Attributes – Control Behavior & Validation

HTML input attributes allow you to customize input fields, enforce rules, and improve user experience.


πŸ”§ Common Input Attributes

AttributePurposeExample
typeDefines the input typetype="text"
nameField name for form dataname="email"
valuePre-filled default valuevalue="Hari"
placeholderHint text inside the inputplaceholder="Enter name"
requiredMakes the field mandatoryrequired
readonlyField can’t be changedreadonly
disabledField is disableddisabled
maxlengthMax number of charactersmaxlength="20"
min / maxMinimum/maximum value (used with number, date)min="1" max="10"
stepIncrement step for numeric inputsstep="0.5"
autofocusField is auto-focused when the page loadsautofocus
patternRegex for input validationpattern="[A-Za-z]{3,}"
autocompleteSuggest previously entered inputautocomplete="on"
multipleAllows multiple file or email inputsmultiple

πŸ§ͺ Example with Attributes

<input type="email" name="userEmail" placeholder="Enter your email" required autofocus>



πŸ”— HTML Input form* Attributes – Connect Inputs to Forms Flexibly

HTML provides special form* attributes for <input> elements to link them to a form, even if they’re outside the actual <form> tag.


🧩 Key form* Attributes for <input>

AttributePurpose
formLinks input to a specific <form> by its id
formactionURL to submit form data (overrides form’s action)
formenctypeData encoding type (e.g., multipart/form-data)
formmethodSubmission method: get or post (overrides form’s method)
formtargetWhere to open response: _self, _blank, etc.
formnovalidateSkip validation when this input submits the form

πŸ§ͺ Example: Input Outside Form Using form Attribute

<form id="mainForm" action="/submit" method="post">
  <input type="text" name="username">
</form>

<!-- Input outside the form but still linked to it -->
<input type="submit" value="Submit Form" form="mainForm">


πŸ§ͺ Example with formaction and formmethod

<form id="searchForm" action="/default" method="get">
  <input type="text" name="query">
  <input type="submit" value="Search Default">
</form>

<input type="submit" value="Search Alternate" form="searchForm" formaction="/alternate" formmethod="post">


βœ… Use Cases

  • When inputs/buttons are placed outside the form
  • When you want different actions or methods for multiple submit buttons


πŸŽ₯ HTML Media – Add Rich Content to Web Pages

HTML supports embedding multimedia like video, audio, and external content to make your web pages more interactive.


🎬 HTML Video

Use the <video> tag to embed videos directly:

<video width="640" height="360" controls>
  <source src="movie.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>

βœ… controls adds play/pause buttons
βœ… Supports formats: .mp4, .webm, .ogg


🎧 HTML Audio

Use the <audio> tag to add sound or music:

<audio controls>
  <source src="audio.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

βœ… Use for music, voiceovers, podcasts
βœ… Supports formats: .mp3, .ogg, .wav


🧩 HTML Plug-ins (Object/Embed – Rarely Used Now)

Used to embed external content like PDFs or Flash (outdated):

http://file.pdf:
[youtube https://www.youtube.com/watch?v=dQw4w9WgXcQ&w=560&h=315]

βœ… Replace the src with your desired YouTube video ID
βœ… Fully responsive with custom CSS


🧠 Summary

ElementUse CaseTag
VideoPlay video content<video>
AudioPlay sound/music<audio>
PDF/embedLegacy plug-ins<embed>, <object>
YouTubeExternal video<iframe>


🎨 HTML Graphics – Drawing with <canvas> and SVG

HTML lets you create graphics using two main technologies: <canvas> and SVG. Both are powerful but serve different use cases.


πŸ–ΌοΈ HTML <canvas> Element

The <canvas> element is used to draw graphics via JavaScriptβ€”such as charts, games, or animations.

πŸ”§ Syntax

<canvas id="myCanvas" width="300" height="150"></canvas>

<script>
  const canvas = document.getElementById("myCanvas");
  const ctx = canvas.getContext("2d");
  ctx.fillStyle = "blue";
  ctx.fillRect(50, 50, 100, 50);
</script>

βœ… Features

  • Great for real-time rendering (games, charts, animations)
  • Works only with JavaScript
  • Raster-based (pixel manipulation)

🧩 HTML SVG (Scalable Vector Graphics)

SVG is an XML-based language to define vector graphics directly in HTML.

πŸ”§ Syntax

<svg width="200" height="100">
  <rect width="200" height="100" style="fill:orange;stroke:black;stroke-width:2" />
</svg>

βœ… Features

  • Resolution-independent (scales perfectly)
  • Editable with CSS and JavaScript
  • Great for icons, charts, logos, diagrams

βš–οΈ Canvas vs. SVG

Feature<canvas>SVG
TypeRaster (pixel-based)Vector (scalable)
InteractivityManual with JavaScriptBuilt-in with event support
AccessibilityNot accessible by defaultMore accessible & searchable
Use CaseGames, dynamic renderingStatic icons, logos, diagrams