HTML5
HTML5
md 2025-05-13
HTML5
Introduction to Web
The World Wide Web (WWW) is a system of interlinked hypertext documents and multimedia content
accessed via the Internet.
Enables users to view websites, click links, and interact with web applications.
Basic Components of the Web
Browser: Software to view web content (e.g., Chrome, Firefox, Edge)
URL (Uniform Resource Locator): Address used to access resources (e.g., https://example.com)
HTTP/HTTPS: Protocols for data transfer between client and server
Web Server: Stores and serves website content (e.g., Apache, Nginx)
Web Page: Document written in HTML, viewed in a browser
Web Application: Dynamic, interactive website with client-server architecture
Database Technologies
Web Servers
1 / 24
HTML5.md 2025-05-13
Protocols
HTML - Introduction
HTML stands for Hypertext Markup Language.
HTML is used to create and structure web content such as headings, paragraphs, links, images, tables,
etc.
HTML is composed of elements that represent content and structure on a webpage.
HTML - Need
Reason Explanation
Case Insensitivity
2 / 24
HTML5.md 2025-05-13
HTML is case-insensitive.
Example: <title> and <TITLE> are equivalent.
Item HTML XHTML
Platform-Independence
HTML is platform-independent, meaning it works on any operating system (Windows, macOS, Linux).
Web browsers interpret HTML code the same way regardless of the operating system.
Feature Platform-Dependent Platform-Independent
DOCTYPE Declaration
Purpose: The DOCTYPE declaration defines the document type and version of HTML.
Example:
<!DOCTYPE html>
Inline Elements
3 / 24
HTML5.md 2025-05-13
HTML Attributes
What are Attributes?
Common Attributes
Boolean Attributes
Rules
Values in quotes
Names case-insensitive (lowercase recommended)
Some are global, some tag-specific
4 / 24
HTML5.md 2025-05-13
Sectioning Elements
Purpose
Benefits
Improved accessibility
SEO benefits
Maintainable code
Responsive design support
Paragraph Element
Purpose: Defines a paragraph of text.
Example:
<p>This is a paragraph.</p>
Example:
<div class="container">
<h2>Title</h2>
<p>Some content here.</p>
</div>
5 / 24
HTML5.md 2025-05-13
<span>: Inline container for text. Inline element for grouping small sections of content (usually text).
Use case: Styling or manipulating small portions of inline content. Common use: Highlighting text,
applying inline styles.
Example:
<span class="highlight">Important</span>
List Element
Ordered List (<ol>): Used to create numbered lists.
Example:
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
Example:
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
Best Practices
Semantics: Use <ul> when the order of items doesn’t matter, <ol> when it does, and <dl> for
definitions.
6 / 24
HTML5.md 2025-05-13
Accessibility: Screen readers often announce lists as “list” followed by the count of items,
helping users understand the content structure.
Avoid large, unstyled lists: Apply styles to make lists more readable and visually appealing,
especially when presenting a lot of information.
Link Element
<a>: Creates a hyperlinks to external resources, other pages, or specific sections within a page.
target: Determines where the link will open (e.g., in the same tab, new tab).
title: Provides additional information about the link, often displayed on hover.
rel: Specifies the relationship between the linking document and the destination.
Example:
1. Use Descriptive Link Text: The text inside the <a> tag should describe the target resource (e.g.,
"Visit our homepage" instead of just "Click here").
2. Accessibility: Ensure that the link text is clear and provides context. Use the title attribute for
additional information.
3. External Links: Use target="_blank" for links that open external websites, so users don't lose
the current page.
4. Security: When linking to external sites, use rel="noopener noreferrer" to protect against
security vulnerabilities like reverse tabnabbing.
Character Entities
Commonly Used HTML Character Entities
7 / 24
HTML5.md 2025-05-13
4. Currency Symbols
5. Mathematical Symbols
Example:
1. Use Character Entities for Special Characters: Always use character entities for special characters that
have a reserved meaning in HTML (e.g., <, >, &).
2. Avoid Overuse: Only use character entities when necessary. If you're working with UTF-8 encoded
pages, you can directly use the characters, as modern browsers fully support this.
8 / 24
HTML5.md 2025-05-13
3. Consistency: Be consistent with your use of character entities for characters that are not easy to type or
that might not display correctly in certain fonts or encoding systems.
9 / 24
HTML5.md 2025-05-13
<button accesskey="s">Save</button>
<textarea spellcheck="true"></textarea>
Consistency
Flexibility
Accessibility
10 / 24
HTML5.md 2025-05-13
Example:
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>30</td>
</tr>
</table>
Cellpadding: The space between the content of each cell and its border is 10px.
Rowspan: The first cell in the first column (101) spans across two rows, grouping the employee ID and
name.
Example:
Example:
Input Elements - Attributes, Color and Date Pickers, Select and Datalist
Elements
Input: Used for user input.
Color Picker (<input type="color">) allows users to pick a color via a color picker dialog.
Date Picker (<input type="date">) provides an interface to select a date from a calendar.
<select name="country">
<option value="usa">USA</option>
<option value="india">India</option>
</select>
Datalist (<datalist>) offers an autocomplete feature, allowing users to either select from a list of
options or enter a custom value.
12 / 24
HTML5.md 2025-05-13
Editing Elements
Contenteditable: Makes an element editable by the user.
Example:
Media
Audio and Video: Used to embed media files.
Example:
Iframe
<iframe>: Embeds another HTML document within the current document.
Example:
<iframe src="https://www.example.com"></iframe>
Cross-Site Scripting (XSS): When embedding content from external sources, it’s important to
ensure that the content is safe and doesn’t introduce vulnerabilities like XSS.
Clickjacking Protection: You should be aware of the potential for clickjacking, where an attacker
can trick a user into clicking on hidden elements within an iframe. Using the X-Frame-Options
header or the sandbox attribute can help mitigate this risk.
Sandboxing: To prevent iframe content from executing malicious scripts, consider using the
sandbox attribute. You can specify which features are allowed, such as forms, scripts, and
navigation.
13 / 24
HTML5.md 2025-05-13
Key Reasons
Avoiding Clickjacking
14 / 24
HTML5.md 2025-05-13
HTML Injection
Clickjacking
XSS
CSRF
Best Practices
HTML Injection
What is HTML Injection?
How it Works
Consequences
15 / 24
HTML5.md 2025-05-13
Spread of Malware
Phishing Attacks
Prevention
Input Sanitization
Output Encoding
< → <
> → >
Content Security Policy (CSP)
Use Secure Frameworks (Angular, React)
Clickjacking
What is Clickjacking?
How it Works
Consequences
Unauthorized Actions
Account Hijacking
Financial Fraud
Reputation Damage
Prevention
X-Frame-Options Header
DENY, SAMEORIGIN
Content-Security-Policy
frame-ancestors 'none';
UI Confirmation for Critical Actions
Secure Web Design
16 / 24
HTML5.md 2025-05-13
Prevention:
Sanitize input.
Use addEventListener instead of inline JavaScript.
Implement Content Security Policy (CSP).
2. Clickjacking
Example:
<iframe src="https://securewebsite.com"></iframe>
Prevention:
Example:
<button onclick="window.location='http://malicious-site.com'">
Click me
</button>
Prevention:
17 / 24
HTML5.md 2025-05-13
Example:
Prevention:
5. DOM-based XSS
Example:
Prevention:
Prevention:
Prevention:
Sanitize inputs
Use Content Security Policy (CSP)
Avoid storing sensitive info in local storage
2. Lack of Encryption
localStorage.setItem("session_token", "12345abcde");
Prevention:
Prevention:
4. Persistent Data
Example:
19 / 24
HTML5.md 2025-05-13
localStorage.removeItem("session_token");
localStorage.clear();
Prevention:
Prevention:
Educate users
Use secure alternatives
6. Browser-Specific Vulnerabilities
Prevention:
20 / 24
HTML5.md 2025-05-13
Form Elements
email, tel, date, range, color, number
Canvas
Local Storage
localStorage, sessionStorage
Geolocation API
Offline Web Apps
manifest attribute
Web Workers
WebSockets
Drag and Drop API
Legacy Browsers
Internet Explorer 8 and below
Partial Support
Example: localStorage in Safari vs Chrome
Vendor Prefixes
-webkit-, -moz-, -ms-
Behavior Differences
Canvas rendering differences
Mobile Browser Support
Varies by OS and device
Can I Use
MDN Web Docs
1. Feature Detection
if (Modernizr.localstorage) {
// Supported
} else {
// Fallback
}
* Example:
21 / 24
HTML5.md 2025-05-13
```html
<video controls>
<source src="movie.mp4" type="video/mp4">
<p>Your browser does not support HTML5 video. <a href="movie.mp4">View
video</a>.</p>
</video>
3. Use Polyfills
Polyfill.io
Video.js
Responsive Design
Test on iOS/Android native browsers
CSS Prefixes
.box {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
JavaScript Workarounds
6. Best Practices
Use tags like: header, footer, main, section, article, nav, aside, figure
Avoid div and span when semantic elements are available
Example:
article with header, section, and footer
22 / 24
HTML5.md 2025-05-13
Minify HTML
Lazy load images with loading="lazy"
Use external JS/CSS
Prefer HTML5 video/audio
5. Validate HTML
23 / 24
HTML5.md 2025-05-13
Conclusion
Connect
GitHub omteja04
LinkedIn omteja
24 / 24