E-Commerce Web Application
Built with React, Node.js, and PostgreSQL.
View Source CodeHTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web.
Every website you visit uses HTML in some form. HTML provides the structure of a webpage, similar to how the skeleton provides structure to the human body.
With HTML, developers can create:
HyperText refers to text that contains links connecting one page to another.
For example, when you click a link on a website and move to another page, you are using hypertext.
A markup language uses special tags to describe the structure of content.
HTML tags tell the browser:
A basic HTML page contains several important parts.
| Tag | Purpose |
|---|---|
<!DOCTYPE html> |
Defines the document type |
<html> |
Root element of the webpage |
<head> |
Contains metadata and page information |
<body> |
Contains visible webpage content |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My First Page</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>Welcome to <strong>HTML</strong>.</p>
</body>
</html>
<h1> creates a main heading<p> creates a paragraph<strong> makes text bold and important<title> sets the browser tab titleWeb browsers like Chrome, Firefox, and Edge read HTML files and convert them into visual webpages.
The browser does not display the tags themselves. Instead, it interprets them and renders the final page for users.
HTML uses tags enclosed inside angle brackets.
Example:
<p>This is a paragraph.</p>
In this example:
<p> is the opening tag</p> is the closing tag| Element | Description |
|---|---|
<h1> to <h6> |
Headings |
<p> |
Paragraph |
<a> |
Hyperlink |
<img> |
Image |
<ul> |
Unordered list |
<ol> |
Ordered list |
<div> |
Container element |
HTML is a markup language, not a programming language.
It cannot perform calculations, create logic, or make decisions on its own.
HTML is commonly used together with:
To start writing HTML, you only need:
HTML files must be saved using the .html extension.
Example:
index.html
After saving the file, double-click it to open it in your web browser.
Create a simple HTML page with your name as the title, add a heading, and a paragraph.
Create a webpage containing:
Create an about.html page introducing yourself with:
Every HTML webpage follows a standard structure known as the HTML boilerplate.
This structure helps browsers correctly understand and display the webpage content.
A well-structured HTML document improves:
The following is the basic structure of a modern HTML5 document.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Title</title>
</head>
<body>
<!-- Content here -->
</body>
</html>
Let us break down the document structure step by step.
This declaration tells the browser that the document uses HTML5.
Without it, browsers may switch to older rendering modes that can cause layout issues.
The <html> tag is the root element of the webpage.
Everything inside the webpage must be placed between:
<html>
...
</html>
lang AttributeThe lang="en" attribute specifies the language of the webpage.
This helps:
The <head> section contains information about the webpage that is not directly visible
on the page.
Common elements inside the head section include:
This meta tag sets the character encoding to UTF-8.
UTF-8 supports most characters and symbols used worldwide.
Without proper encoding, some text may display incorrectly.
This tag helps webpages display correctly on mobile devices.
It makes responsive design possible by controlling page scaling and width.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
The <title> tag defines the title shown in the browser tab.
Example:
<title>My Portfolio</title>
This title also appears in search engine results.
The <body> section contains all visible webpage content.
Examples include:
Comments are notes written inside the code that browsers ignore.
They help developers explain sections of code.
<!-- This is a comment -->
Indentation makes HTML code easier to read and maintain.
Compare the following examples:
<body>
<h1>Title</h1>
<p>Paragraph</p>
</body>
<body>
<h1>Title</h1>
<p>Paragraph</p>
</body>
Proper formatting becomes extremely important in large projects.
Modern HTML uses semantic elements that describe the meaning of content.
| Element | Purpose |
|---|---|
<header> |
Top section of a webpage |
<nav> |
Navigation links |
<main> |
Main page content |
<section> |
Content section |
<article> |
Independent content block |
<footer> |
Bottom section of the page |
<body>
<header>
<h1>My Website</h1>
</header>
<nav>
Navigation Menu
</nav>
<main>
Main Content
</main>
<footer>
Copyright 2026
</footer>
</body>
.html extensionTyping the following in VS Code:
!
and pressing Tab automatically generates the complete HTML boilerplate.
Create a complete HTML5 boilerplate manually without copying the example.
Create a webpage with:
Create a semantic webpage using:
<header><nav><main><footer>Text is one of the most important parts of every webpage. HTML provides several elements to structure and format text properly.
Good typography improves:
HTML text elements help browsers and search engines understand the importance of content on a webpage.
HTML provides six heading levels from <h1> to <h6>.
These headings create a content hierarchy similar to chapters and subheadings in a book.
<h1>Main Page Title</h1>
<h2>Major Section</h2>
<h3>Subsection</h3>
<h4>Sub-subsection</h4>
| Heading | Purpose |
|---|---|
<h1> |
Main title of the webpage |
<h2> |
Main section heading |
<h3> |
Subsection heading |
<h4> - <h6> |
Smaller nested sections |
Headings are not only used for making text bigger. They provide semantic meaning to content.
Proper heading usage helps:
A webpage should usually contain only one primary <h1>.
The <p> tag is used to create paragraphs.
<p>HTML is the foundation of web development.</p>
<p>It helps structure content on webpages.</p>
Browsers automatically add spacing before and after paragraphs.
The <br> tag inserts a line break.
<p>
Hello<br>
Welcome to HTML
</p>
The <br> tag does not require a closing tag.
The <hr> tag creates a horizontal line used to separate content sections.
<h2>Chapter 1</h2>
<hr>
<h2>Chapter 2</h2>
HTML provides multiple ways to emphasise text.
| Tag | Purpose |
|---|---|
<b> |
Bold text without semantic importance |
<strong> |
Important text with semantic meaning |
<p>
<strong>Warning:</strong> Save your work regularly.
</p>
| Tag | Purpose |
|---|---|
<i> |
Italic text without emphasis |
<em> |
Text with emphasis |
<p>
<em>Important:</em> Complete the assignment today.
</p>
The <small> tag displays smaller-sized text.
<p>
Copyright <small>2026</small>
</p>
These tags are commonly used in mathematics and chemistry.
| Tag | Example Usage |
|---|---|
<sub> |
H₂O |
<sup> |
x² |
<p>H<sub>2</sub>O</p>
<p>x<sup>2</sup></p>
The <pre> tag preserves spaces and line breaks exactly as written.
<pre>
Line 1
Line 2
Line 3
</pre>
The <code> tag is used for displaying programming code.
<p>
Use the <code>print()</code> function in Python.
</p>
HTML provides tags for quotations and cited text.
| Tag | Purpose |
|---|---|
<blockquote> |
Long quotation |
<q> |
Short inline quotation |
<q>Knowledge is power.</q>
Some characters are reserved in HTML and must be written using entities.
| Character | Entity |
|---|---|
| < | < |
| > | > |
| & | & |
<strong> and <em>Create a webpage containing all heading levels from <h1> to
<h6>.
Create a webpage with:
Create a mini article page using:
Links are one of the most important features of the web.
They allow users to move between webpages, websites, sections, documents, and resources.
HTML uses the <a> tag, also called the anchor tag, to create
hyperlinks.
The basic syntax of a hyperlink is:
<a href="https://example.com">Visit Website</a>
The href attribute specifies the destination URL.
| Type | Description |
|---|---|
| External Link | Opens another website |
| Internal Link | Opens another page within the same website |
| Anchor Link | Jumps to a section on the same page |
| Email Link | Opens the user's email application |
| Telephone Link | Starts a phone call on supported devices |
External links connect users to other websites.
<a href="https://www.google.com">
Visit Google
</a>
The target="_blank" attribute opens the link in a new browser tab.
<a href="https://example.com"
target="_blank"
rel="noopener">
Open New Tab
</a>
rel="noopener"?The rel="noopener" attribute improves security when opening new tabs.
It prevents the new webpage from accessing the original page through JavaScript.
Internal links connect pages inside the same website.
Example folder structure:
project/
│
├── index.html
├── about.html
└── contact.html
Example internal link:
<a href="/about">
About Us
</a>
Anchor links jump to specific sections on the same webpage.
<a href="#section">Jump to Section</a>
<h2 id="section">Section</h2>
The id attribute identifies the target element.
The mailto: protocol opens the user's default email application.
<a href="mailto:[email protected]">
Send Email
</a>
The tel: protocol is mainly used on mobile devices for phone calls.
<a href="tel:+1234567890">
Call Now
</a>
The download attribute allows users to download files instead of opening them.
<a href="notes.pdf" download>
Download Notes
</a>
An image can also be wrapped inside an anchor tag.
<a href="https://example.com">
<img src="logo.png" alt="Logo">
</a>
Navigation menus help users move through a website.
HTML commonly uses the <nav> element for navigation sections.
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/contact">Contact</a>
</nav>
| Type | Example |
|---|---|
| Relative URL | about.html |
| Absolute URL | https://example.com/about.html |
Links can have different visual states:
These states are usually styled using CSS.
<a href="course.html">Click Here</a>
<a href="course.html">
View HTML Course
</a>
href attributeCreate a webpage containing:
Create a navigation menu with links for:
Create a long webpage with multiple sections and use anchor links to jump between them.
Websites become more engaging when they include images, audio, videos, and other media elements.
HTML provides built-in tags for displaying media content directly inside webpages.
In this lecture, you will learn how to:
The <img> tag is used to display images in HTML.
Unlike many HTML elements, the image tag does not have a closing tag.
<!-- Basic image -->
<img src="photo.jpg" alt="Description">
<!-- With dimensions -->
<img src="photo.jpg" alt="Description"
width="600" height="400">
<!-- Figure with caption -->
<figure>
<img src="chart.png" alt="Chart">
<figcaption>Figure 1: Sales</figcaption>
</figure>
| Attribute | Purpose |
|---|---|
src |
Specifies the image file path |
alt |
Alternative text for accessibility |
width |
Sets image width |
height |
Sets image height |
The alt attribute is extremely important for accessibility and SEO.
Screen readers use alt text to describe images to visually impaired users.
If an image fails to load, the alt text is displayed instead.
<img src="cat.jpg"
alt="A white cat sitting on a chair">
| Format | Best Used For |
|---|---|
| JPG / JPEG | Photographs and realistic images |
| PNG | Transparent backgrounds and graphics |
| SVG | Icons and vector graphics |
| GIF | Simple animations |
| WebP | Modern compressed web images |
Images can be loaded using relative or absolute paths.
<!-- Relative path -->
<img src="images/photo.jpg" alt="Photo">
<!-- Absolute URL -->
<img src="https://example.com/photo.jpg"
alt="Online Photo">
The <figure> element groups media content together.
The <figcaption> tag provides a caption for the content.
<figure>
<img src="nature.jpg" alt="Nature">
<figcaption>
Beautiful mountain landscape
</figcaption>
</figure>
Responsive images automatically adjust to different screen sizes.
<img src="photo.jpg"
alt="Responsive image"
style="max-width:100%; height:auto;">
This technique prevents images from overflowing on smaller screens.
The <audio> tag embeds sound files into webpages.
<audio controls>
<source src="music.mp3" type="audio/mpeg">
Your browser does not support audio.
</audio>
| Attribute | Purpose |
|---|---|
controls |
Displays play/pause buttons |
autoplay |
Automatically starts audio |
loop |
Repeats the audio continuously |
muted |
Starts audio muted |
The <video> tag is used for embedding videos.
<video width="640"
height="360"
controls>
<source src="movie.mp4"
type="video/mp4">
Your browser does not support video.
</video>
YouTube videos are commonly embedded using an iframe.
<iframe width="560"
height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="YouTube video"
allowfullscreen>
</iframe>
The poster attribute displays an image before the video starts.
<video controls
poster="thumbnail.jpg">
<source src="movie.mp4"
type="video/mp4">
</video>
Lazy loading delays image loading until the image becomes visible on screen.
<img src="photo.jpg"
alt="Photo"
loading="lazy">
alt attributeCreate a webpage containing:
Create a webpage with:
Create a small gallery page using multiple responsive images.
Lists and tables are essential HTML elements used to organize and display information clearly. Lists help group related items together, while tables are used to display structured data in rows and columns.
Websites use lists for menus, navigation bars, feature sections, tutorials, and instructions. Tables are commonly used for schedules, pricing charts, marksheets, reports, and data presentation.
HTML provides three main types of lists:
<!-- Unordered -->
<ul>
<li>Apples</li>
<li>Bananas</li>
</ul>
<!-- Ordered -->
<ol>
<li>Step 1</li>
<li>Step 2</li>
</ol>
<!-- Description -->
<dl>
<dt>HTML</dt>
<dd>HyperText Markup</dd>
</dl>
Unordered lists use bullet points to display items where sequence or order does not matter.
<ul>
<li>Milk</li>
<li>Bread</li>
<li>Eggs</li>
</ul>
The <ul> tag creates the unordered list, while each item is added using the
<li> tag.
Ordered lists are used when the order of items is important, such as instructions or rankings.
<ol>
<li>Open VS Code</li>
<li>Create a file</li>
<li>Save the document</li>
</ol>
Browsers automatically number items inside an ordered list.
You can change the numbering style of ordered lists using the type attribute.
<ol type="A">
<li>HTML</li>
<li>CSS</li>
</ol>
Possible values for the type attribute include:
1 → Numbers (default)A → Uppercase lettersa → Lowercase lettersI → Roman numeralsi → Lowercase Roman numeralsDescription lists are used for terms and definitions, similar to a glossary or dictionary.
<dl>
<dt>CPU</dt>
<dd>Central Processing Unit</dd>
<dt>RAM</dt>
<dd>Random Access Memory</dd>
</dl>
The <dt> tag represents the term, while <dd> provides its
description.
Lists can also contain other lists inside them. This is called nesting.
<ul>
<li>Frontend
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</li>
</ul>
Nested lists are commonly used in navigation menus and category structures.
HTML tables are used to organize data into rows and columns. Tables are useful for displaying schedules, reports, marksheets, pricing tables, and structured datasets.
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Alice</td>
<td>21</td>
</tr>
</table>
<table> → Creates the table<tr> → Creates a table row<th> → Creates a table heading cell<td> → Creates a table data cellThe border attribute adds borders around table cells.
<table border="2">
<tr>
<th>Course</th>
<th>Duration</th>
</tr>
<tr>
<td>HTML</td>
<td>4 Weeks</td>
</tr>
</table>
Modern websites usually style tables using CSS instead of the HTML border attribute.
You can merge cells horizontally using colspan and vertically using
rowspan.
<table border="1">
<tr>
<th colspan="2">Student Info</th>
</tr>
<tr>
<td>John</td>
<td>20</td>
</tr>
</table>
The colspan="2" attribute merges two columns into one.
<th> for headings instead of normal cells<li> tags<th> and <td><tr>Create an unordered list containing five of your favorite foods.
Create an ordered list showing the steps to create an HTML file and open it in a browser.
Create a table with three columns: Name, Subject, and Marks. Add at least three student records.
HTML forms allow users to send data to a website. Forms are used everywhere on the web — login pages, registration systems, search bars, contact forms, payment systems, and surveys all depend on forms.
Forms collect user input using different input elements such as text fields, buttons, checkboxes, radio buttons, dropdowns, and text areas.
The <form> tag acts as a container for all form elements.
<form action="/submit" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<button type="submit">Submit</button>
</form>
action → specifies where form data is sentmethod → defines how data is transmittedPOST → sends data securely in the request bodyGET → sends data through the URLPOST for sensitive data like passwords and user information. Use GET for
searches and filters.
The <label> tag improves accessibility and usability. Clicking the label automatically
focuses the related input field.
<label for="username">Username:</label>
<input type="text" id="username">
The value of the for attribute must match the input's id.
Text fields allow users to enter single-line text.
<input type="text" placeholder="Enter your name">
The placeholder attribute displays temporary helper text inside the field.
The email input type validates email addresses automatically.
<input type="email" required>
If the entered value is not a valid email format, the browser will display a validation error.
Password fields hide typed characters for security.
<input type="password">
Number fields only accept numeric values.
<input type="number" min="1" max="100">
The min and max attributes define the allowed range.
Checkboxes allow users to select multiple options.
<input type="checkbox" id="html">
<label for="html">HTML</label>
<input type="checkbox" id="css">
<label for="css">CSS</label>
Users can check more than one checkbox at the same time.
Radio buttons allow users to select only one option from a group.
<input type="radio" name="gender" id="male">
<label for="male">Male</label>
<input type="radio" name="gender" id="female">
<label for="female">Female</label>
Radio buttons must share the same name value to behave as a group.
The <textarea> element allows multi-line text input.
<textarea rows="5" cols="30"></textarea>
This is commonly used for comments, messages, and descriptions.
Dropdown menus provide a list of selectable options.
<select>
<option>HTML</option>
<option>CSS</option>
<option>JavaScript</option>
</select>
Buttons are used to submit form data.
<button type="submit">Send</button>
When clicked, the browser sends all form data to the location defined in the
action attribute.
Reset buttons restore all form fields to their default values.
<button type="reset">Reset</button>
The required attribute prevents users from submitting empty fields.
<input type="text" required>
Browser validation happens automatically before submission.
Placeholders provide temporary hints inside input fields.
<input type="text" placeholder="Enter username">
Placeholders disappear when the user starts typing.
File inputs allow users to upload files from their computer.
<input type="file">
This is commonly used for profile pictures, assignments, and document uploads.
HTML5 introduced specialized date and time input fields.
<input type="date">
<input type="time">
Modern browsers automatically display date and time pickers.
Organizing forms properly improves readability and accessibility.
<fieldset>
<legend>Personal Information</legend>
<label>Name:</label>
<input type="text">
</fieldset>
<fieldset> groups related fields together<legend> provides a title for the group| GET | POST |
|---|---|
| Data appears in URL | Data sent in request body |
| Less secure | More secure |
| Used for searches | Used for login/signup forms |
name attributeCreate a registration form containing name, email, password, and submit button fields.
Create a feedback form using a textarea, radio buttons, and checkboxes.
Create a student admission form with dropdown menus, date input, and file upload support.
Semantic HTML means using HTML elements according to their meaning and purpose instead of only for visual structure. Semantic elements clearly describe what their content represents to browsers, developers, search engines, and assistive technologies.
Before HTML5, developers heavily relied on generic containers like <div> and
<span>. Semantic HTML introduced meaningful tags that make webpages more organized,
accessible, and easier to maintain.
HTML5 introduced several semantic layout elements used in modern webpage structure.
<header> <!-- Site header -->
<nav> <!-- Navigation -->
<main> <!-- Primary content -->
<article> <!-- Self-contained -->
<section> <!-- Thematic group -->
<aside> <!-- Sidebar -->
<footer> <!-- Footer -->
The <header> element represents introductory content or a top section of a webpage or
article.
<header>
<h1>My Blog</h1>
<p>Learn web development</p>
</header>
Headers commonly contain logos, navigation menus, titles, or introductory text.
The <nav> element contains navigation links.
<nav>
<a href="#">Home</a>
<a href="#">Courses</a>
<a href="#">Contact</a>
</nav>
Screen readers use the navigation element to help users quickly move through site menus.
The <main> element represents the primary content of the webpage.
<main>
<h2>Welcome to our website</h2>
<p>This is the main content area.</p>
</main>
<main> element because it represents the
core content of the page.
The <section> tag groups related content together.
<section>
<h2>About Us</h2>
<p>We teach coding online.</p>
</section>
Sections are thematic groups of content and usually contain headings.
The <article> element represents self-contained content that can stand on its own.
<article>
<h2>How to Learn HTML</h2>
<p>Start with basic tags and structure.</p>
</article>
Articles are commonly used for blog posts, news stories, tutorials, or forum posts.
The <aside> tag contains related but secondary content.
<aside>
<h3>Related Courses</h3>
<p>Learn CSS and JavaScript next.</p>
</aside>
Asides are often used for sidebars, advertisements, tips, or related links.
The <footer> element represents the bottom section of a webpage or article.
<footer>
<p>© 2026 Code Tutorium</p>
</footer>
Footers usually contain copyright information, contact details, or social media links.
| Semantic | Non-Semantic |
|---|---|
| <header> | <div> |
| <article> | <span> |
| <footer> | <div> |
Non-semantic elements do not describe their meaning, while semantic elements provide context and structure.
<body>
<header>
<h1>My Website</h1>
</header>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
</nav>
<main>
<section>
<h2>Latest Tutorials</h2>
<article>
<h3>Learn HTML</h3>
<p>HTML is the foundation of web development.</p>
</article>
</section>
<aside>
Related resources here
</aside>
</main>
<footer>
<p>Copyright 2026</p>
</footer>
</body>
Semantic HTML greatly improves accessibility for users with disabilities.
Search engines use semantic structure to better understand webpage content.
Even though semantic elements are preferred, <div> is still useful when no semantic
element fits the situation.
<div class="card">
Custom content here
</div>
Use semantic elements whenever possible, and use <div> as a generic container only when
necessary.
<div> elements<section> without headings<main> elements on one page<article> and <section>Create a webpage using <header>, <nav>,
<main>, and <footer> elements.
Create a blog layout using <article> and <section> elements.
Convert a webpage made entirely with <div> tags into a semantic HTML layout.
HTML is the foundation of web development. Continue your journey with:
<details>
<summary>What is HTML?</summary>
<p>HTML is a markup language.</p>
</details>
<button aria-label="Close menu">X</button>
<nav aria-label="Main navigation">...</nav>
<meta name="description" content="Page description">
<meta name="keywords" content="html, css, javascript">
<meta name="author" content="Your Name">
<meta property="og:title" content="Page Title">
Create a complete personal portfolio website using everything learned:
Web Components are a suite of native browser technologies allowing you to create reusable, encapsulated HTML custom elements (like <user-card>) without external frameworks. They rely on three pillars: Custom Elements, Shadow DOM, and HTML Templates.
customElements.define("profile-card", ProfileCard)).<template> & <slot>): Inert markup that does not render on load, but can be stamped out repeatedly with flexible placeholders.<template> and <slot> ElementsTemplates hold markup that the browser parses but does not display until activated via JavaScript:
<!-- Template defined in HTML --> <template id="user-card-template"> <style> :host { display: block; font-family: system-ui, sans-serif; border: 1px solid #e2e8f0; border-radius: 8px; padding: 1rem; background: #ffffff; box-shadow: 0 2px 4px rgba(0,0,0,0.05); } h3 { margin-top: 0; color: #1e293b; } .role { color: #64748b; font-size: 0.9rem; } </style> <div class="card"> <h3><slot name="name">Anonymous</slot></h3> <p class="role"><slot name="role">Member</slot></p> <div class="bio"><slot>No bio provided.</slot></div> </div> </template>
Custom element names must contain a hyphen (e.g., user-card) to differentiate them from standard HTML tags:
class UserCard extends HTMLElement { constructor() { super(); // Attach an encapsulated Shadow DOM tree const shadowRoot = this.attachShadow({ mode: 'open' }); // Grab template content and clone it const template = document.getElementById('user-card-template'); shadowRoot.appendChild(template.content.cloneNode(true)); } // Observe attribute changes static get observedAttributes() { return ['status']; } attributeChangedCallback(name, oldValue, newValue) { if (name === 'status') { console.log(`Status updated from ${oldValue} to ${newValue}`); } } connectedCallback() { console.log('UserCard added to DOM'); } disconnectedCallback() { console.log('UserCard removed from DOM'); } } // Register the custom element with the browser customElements.define('user-card', UserCard);
Once registered, use it just like any native HTML tag. The content inside fills named <slot> placeholders:
<user-card status="active"> <span slot="name">Ada Lovelace</span> <span slot="role">Computing Pioneer</span> <p>First computer programmer in history.</p> </user-card> <user-card> <span slot="name">Alan Turing</span> </user-card>
Styles declared inside a shadow root do not leak outside, and global page CSS does not penetrate the shadow root (except for inheritable CSS variables like color or custom properties). This guarantees bulletproof modularity.
<usercard>). The browser will throw a DOMException: Registration failed for type ... The type must contain a hyphen.this.innerHTML = ... before super() in the constructor. Always call super() as the very first statement.this.shadowRoot.querySelector(".my-slot-content"). Slotted content remains in the light DOM; use slot.assignedNodes() instead.mode: "open" when creating a shadow root so developer tools and assistive extensions can inspect component internals.background: var(--card-bg, #fff);) to allow consumers to theme your web component easily.<modal-dialog> that opens when a button is clicked and closes on Escape.name="header" and an unnamed default slot for modal body content.Why must custom element tag names always include a hyphen (e.g., <my-button>)?
W3C reserves all single-word element names for standard HTML tags. Hyphenated names guarantee that native browser updates will never break custom elements.
Which method is called automatically when a custom element is inserted into the document?
In modern Custom Elements v1, connectedCallback() runs whenever the element is inserted into the DOM tree.
What does the <slot> element do inside a Web Component template?
Slots allow consumers to pass custom HTML markup into designated insertion points inside the component.
Web graphics fall into two categories: SVG (vector graphics defined in XML, infinitely scalable and accessible) and Canvas (pixel-based raster bitmap manipulated via a high-performance 2D/3D JavaScript rendering context).
| Feature | SVG (<svg>) | Canvas (<canvas>) |
|---|---|---|
| Model | Vector (XML DOM Nodes) | Pixel Bitmap (Immediate Mode) |
| Resolution | Infinitely scalable without blur | Resolution dependent (can blur if scaled) |
| Interactivity | Every shape can have CSS & click events | No DOM nodes; click detection via math coordinates |
| Best for | Icons, charts, illustrations, logos | Games, particle systems, video filters, high FPS |
Embed SVGs directly in HTML to style them with CSS and animate them:
<!-- Inline SVG example --> <svg width="200" height="120" viewBox="0 0 200 120" xmlns="http://www.w3.org/2000/svg"> <!-- Rectangle with rounded corners --> <rect x="10" y="10" width="180" height="100" rx="15" fill="#f8fafc" stroke="#3b82f6" stroke-width="2"/> <!-- Circle --> <circle cx="60" cy="60" r="30" fill="#6366f1"/> <!-- Line and Text --> <line x1="110" y1="35" x2="170" y2="35" stroke="#94a3b8" stroke-width="3" stroke-linecap="round"/> <text x="110" y="65" font-family="sans-serif" font-size="14" fill="#0f172a" font-weight="bold">Vector Art</text> <text x="110" y="85" font-family="sans-serif" font-size="11" fill="#64748b">Crisp on all DPIs</text> </svg>
The <canvas> element provides a blank slate rendered with JavaScript:
<canvas id="myCanvas" width="400" height="200" style="border:1px solid #e2e8f0; border-radius:8px;"></canvas>
const canvas = document.getElementById('myCanvas'); const ctx = canvas.getContext('2d'); // 1. Draw a filled rectangle ctx.fillStyle = '#10b981'; ctx.fillRect(20, 20, 120, 80); // 2. Draw a stroked circle (arc) ctx.beginPath(); ctx.arc(220, 60, 40, 0, Math.PI * 2); ctx.strokeStyle = '#6366f1'; ctx.lineWidth = 4; ctx.stroke(); // 3. Draw text ctx.font = 'bold 16px sans-serif'; ctx.fillStyle = '#0f172a'; ctx.fillText('Canvas 2D Rendering', 20, 140); // 4. Draw a path ctx.beginPath(); ctx.moveTo(20, 170); ctx.lineTo(380, 170); ctx.strokeStyle = '#cbd5e1'; ctx.lineWidth = 2; ctx.stroke();
width: 400px;) instead of HTML attributes (<canvas width="400" height="200">). CSS stretches the bitmap, causing blurry drawings.ctx.beginPath() before drawing new shapes in Canvas, causing previous paths to be redrawn repeatedly.viewBox on SVG elements, which breaks responsive scaling across different viewport widths.window.devicePixelRatio and scale the context with ctx.scale(ratio, ratio).aria-label or <title> tag inside inline SVGs for screen-reader accessibility.:hover using CSS.<canvas> that tracks your mouse cursor and draws connected particles or circles where the user clicks.What happens if you scale an SVG illustration to 10x its original size?
SVGs are mathematical vector paths rather than fixed raster pixels, so they scale infinitely without loss of quality.
Why should canvas width and height be set via HTML attributes rather than CSS?
The canvas tag attributes specify the actual pixel buffer resolution. Setting size only in CSS stretches the default 300x150 buffer like an image.
Which context is requested for standard 2D drawing on a canvas?
getContext("2d") returns the standard CanvasRenderingContext2D interface.
High-performance websites deliver superior user experiences and rank higher in search engines. Master the critical rendering path, resource hints, responsive image optimization with <picture>, lazy loading, and modern Core Web Vitals.
<picture>Modern formats like AVIF and WebP reduce file sizes by 30–60% compared to legacy JPG and PNG. Use the <picture> element for progressive fallback:
<!-- Deliver the smallest modern image format supported by the user browser --> <picture> <source srcset="hero.avif" type="image/avif"> <source srcset="hero.webp" type="image/webp"> <img src="hero.jpg" alt="Developer coding on laptop" width="1200" height="630" loading="eager" fetchpriority="high" decoding="async"> </picture>
Setting explicit width and height attributes on images allows browsers to calculate the aspect ratio before image bytes arrive, completely eliminating Cumulative Layout Shift (CLS).
Defer loading offscreen images and iframes until the user scrolls near them:
<!-- Offscreen images below the fold --> <img src="chart.png" alt="Analytics chart" width="600" height="400" loading="lazy"> <!-- Embedded YouTube video or map --> <iframe src="https://example.com/map" width="800" height="400" loading="lazy"></iframe>
preconnect, dns-prefetch & preloadWarm up DNS lookups and TLS handshakes for third-party origins like Google Fonts or CDN assets in your <head>:
<head> <!-- Preconnect to external font CDN to save roundtrips --> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <!-- Preload critical hero image (LCP element) --> <link rel="preload" as="image" href="hero.avif" type="image/avif"> <!-- Defer non-critical JavaScript --> <script src="analytics.js" defer></script> </head>
loading="lazy" on the main hero banner / LCP image. This delays discovery and severely hurts loading scores! Only lazy-load below-the-fold content.width and height attributes on images, causing the page layout to jump around while images download.<script src="..."> tags in the <head> without defer or async, freezing HTML parsing.fetchpriority="high" on your primary hero image so the browser prioritizes it above stylesheets or scripts.<picture> with AVIF, WebP, and JPEG fallback.loading="lazy" to three gallery photos.Which Core Web Vital measures page visual stability (avoiding unexpected layout jumps)?
Cumulative Layout Shift (CLS) measures visual stability. Missing image dimensions or dynamically injected ads are the primary causes of poor CLS.
Should you add loading="lazy" to the hero image at the top of your landing page?
Hero images should be loaded immediately (loading="eager" or fetchpriority="high"). Lazy loading them delays their fetch until layout is complete.
What is the main benefit of the
The picture element lets you offer multiple source formats and media queries, allowing browsers to choose the most efficient image format they support.
Synthesize everything you have learned in HTML Mastery by architecting a production-ready, fully accessible, SEO-optimized business website. You will build clean semantic structure, custom elements, accessible forms, meta data, and responsive media.
<header>, <nav>, <main>, <section>, <article>, and <footer> with proper heading hierarchy (single <h1>).for/id binding, and keyboard-navigable dialog/details.<picture> elements with explicit width/height and lazy loading below the fold.<pricing-card> or feedback element.<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Apex Cloud - High Performance Cloud Solutions</title> <meta name="description" content="Next-generation serverless cloud infrastructure built for speed, safety, and scale."> <link rel="canonical" href="https://example.com/apex-cloud"> <!-- OpenGraph / Social Meta --> <meta property="og:title" content="Apex Cloud - High Performance Cloud Solutions"> <meta property="og:description" content="Next-generation serverless cloud infrastructure built for speed, safety, and scale."> <meta property="og:image" content="https://example.com/og-image.jpg"> <meta property="og:type" content="website"> <!-- Resource Hints --> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <!-- JSON-LD Structured Data --> <script type="application/ld+json"> { "@context": "https://schema.org", "@type": "SoftwareApplication", "name": "Apex Cloud", "operatingSystem": "All", "applicationCategory": "DeveloperApplication" } </script> <style> :root { --primary: #3b82f6; --text: #0f172a; --bg: #f8fafc; } body { margin: 0; font-family: system-ui, sans-serif; color: var(--text); background: var(--bg); line-height: 1.6; } .skip-link { position: absolute; top: -40px; left: 0; background: var(--primary); color: #fff; padding: 8px; z-index: 100; } .skip-link:focus { top: 0; } header, nav, main, footer { max-width: 1100px; margin: 0 auto; padding: 1.5rem; } nav ul { list-style: none; display: flex; gap: 1.5rem; padding: 0; } .hero { text-align: center; padding: 4rem 1rem; } .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem; margin: 2rem 0; } .card { background: #fff; padding: 1.5rem; border-radius: 8px; border: 1px solid #e2e8f0; } </style> </head> <body> <!-- 1. Accessible Skip Navigation Link --> <a href="#main-content" class="skip-link">Skip to main content</a> <!-- 2. Header and Navigation --> <header> <div style="display:flex; justify-content:space-between; align-items:center;"> <a href="/" style="font-weight:bold; font-size:1.4rem; text-decoration:none; color:inherit;">ApexCloud</a> <nav aria-label="Main Navigation"> <ul> <li><a href="#features">Features</a></li> <li><a href="#pricing">Pricing</a></li> <li><a href="#contact">Contact</a></li> </ul> </nav> </div> </header> <!-- 3. Semantic Main Content --> <main id="main-content"> <!-- Hero Section --> <section class="hero"> <h1>Deploy Globally in Milliseconds</h1> <p style="font-size:1.2rem; max-width:600px; margin:0 auto 1.5rem;"> Engineered for high-concurrency workloads with zero configuration and instant failover. </p> <a href="#contact" style="display:inline-block; background:var(--primary); color:#fff; padding:0.75rem 1.5rem; border-radius:6px; text-decoration:none; font-weight:600;"> Start Free Trial </a> </section> <!-- Features Section --> <section id="features" aria-labelledby="features-heading"> <h2 id="features-heading" style="text-align:center;">Built for Modern Engineering Teams</h2> <div class="grid"> <article class="card"> <h3>⚡ Global Edge Network</h3> <p>Over 300 points of presence routing traffic with sub-10ms response latency.</p> </article> <article class="card"> <h3>🔒 Zero-Trust Security</h3> <p>Automated TLS certificates, mTLS microsegmentation, and hardware security keys.</p> </article> <article class="card"> <h3>📊 Real-Time Analytics</h3> <p>Instant streaming logs and distributed telemetry traces with zero sampling.</p> </article> </div> </section> <!-- Interactive Details Accordion --> <section id="faq" style="margin: 4rem 0;"> <h2>Frequently Asked Questions</h2> <details style="margin-bottom: 1rem; background:#fff; padding:1rem; border-radius:6px;"> <summary style="font-weight:bold; cursor:pointer;">How does pricing work?</summary> <p>You only pay for compute seconds consumed with per-millisecond billing granularity.</p> </details> <details style="background:#fff; padding:1rem; border-radius:6px;"> <summary style="font-weight:bold; cursor:pointer;">Can I migrate existing Docker containers?</summary> <p>Yes, Apex Cloud natively supports standard OCI container images.</p> </details> </section> <!-- Accessible Contact Form --> <section id="contact" style="background:#fff; padding:2rem; border-radius:8px; border:1px solid #e2e8f0;"> <h2>Request Enterprise Demo</h2> <form action="/api/contact" method="POST"> <div style="margin-bottom:1rem;"> <label for="user-name" style="display:block; font-weight:bold; margin-bottom:0.25rem;">Full Name</label> <input type="text" id="user-name" name="name" required style="width:100%; padding:0.5rem; border:1px solid #cbd5e1; border-radius:4px;"> </div> <div style="margin-bottom:1rem;"> <label for="user-email" style="display:block; font-weight:bold; margin-bottom:0.25rem;">Work Email</label> <input type="email" id="user-email" name="email" required style="width:100%; padding:0.5rem; border:1px solid #cbd5e1; border-radius:4px;"> </div> <div style="margin-bottom:1rem;"> <label for="user-notes" style="display:block; font-weight:bold; margin-bottom:0.25rem;">Project Details</label> <textarea id="user-notes" name="notes" rows="4" style="width:100%; padding:0.5rem; border:1px solid #cbd5e1; border-radius:4px;"></textarea> </div> <button type="submit" style="background:var(--primary); color:#fff; border:none; padding:0.75rem 1.5rem; border-radius:6px; cursor:pointer; font-weight:bold;"> Submit Inquiry </button> </form> </section> </main> <!-- 4. Semantic Footer --> <footer style="margin-top: 4rem; border-top:1px solid #e2e8f0; text-align:center; color:#64748b;"> <p>© 2026 Apex Cloud Technologies Inc. All rights reserved.</p> </footer> </body> </html>
Congratulations on mastering HTML5! You have acquired professional mastery over semantic markup, web accessibility guidelines, custom web components, multimedia vector graphics, and high-performance loading architectures.
Build a modern, fully accessible HTML5 single-page developer portfolio using semantic elements like
Master clean HTML structure, accessible ARIA attributes, semantic headings hierarchy (H1-H3), and embedded media elements.
Jane Doe — Senior Full Stack Developer
Hi, I'm Jane Doe
Full-Stack Web Developer specializing in React, Node.js, and Cloud Solutions.
Featured Projects
E-Commerce Web Application
Built with React, Node.js, and PostgreSQL.
View Source Code
Get In Touch
Add an embedded