Table of Content
- HTML
- Semantic HTML
Q1. What are Semantic Elements?
Q2. Examples of Some Semantic Elements.
Q3. Why Should We Use Semantic Tags Instead of Generic Tags?
Q4. How Semantic HTML Helps in SEO?
Q5. How Semantic HTML Helps in Accessibility? - HTML Sanitization
Q6. What is HTML Sanitization?
Q7. Types of HTML Sanitization
Q8. Name Some Libraries for Clients Side Sanitization - HTML5 Latest Tag
Q9. What is HTML5?
Q10. New Features of HTML5?
Q11. Latest Tags of HTML5?
- Semantic HTML
- CSS
- Web Accessibility
- W3C Validation
- JavaScript
- Testing
- ReactJS
- ReactJS Packages
- TypeScript
- Data Structure and Algorithm
-
A semantic element clearly describes its meaning to both the browser and the developer.
Examples of non-semantic elements:<div> and <span>
- Tells nothing about its content.
Examples of semantic elements:<form>, <table>, and <article>
- Clearly defines its content. -
<article> <aside> <details> <figcaption> <figure> <footer> <header> <main> <mark> <nav> <section> <summary> <time>
-
Semantic tags provide meaning to the content they contain, whereas generic tags do not. This meaning can be interpreted by both humans and machines, which can be helpful in a number of ways. For example, screen readers can use the semantic information in a document to provide a more meaningful experience for blind or visually impaired users. Search engines can also use semantic information to provide more relevant results for users. In general, using semantic tags makes your HTML code more understandable and easier to work with.
-
Semantic HTML refers to syntax that makes the HTML more comprehensible by better defining the different sections and layout of web pages. It makes web pages more informative and adaptable, allowing browsers and search engines to better interpret content
-
Semantic HTML gives context to screen readers, which read the contents of a page out loud. With the button example in mind: buttons have more suitable styling by default. a screen reader identifies it as a button.
-
HTML sanitization generally refers to removing potentially malicious JavaScript content from raw HTML strings.
-
There are two different HTML sanitization implementations:
i) Client-side sanitization: prevents unsafe content from the DOM level
ii) Server-side sanitization: prevents the storage of malicious HTML content in databasesWe indeed need to use both sanitization layers to prevent XSS vulnerabilities. If your database is affected by malicious XSS payloads, the client-side sanitization layer will protect all application users, but if an attacker sends malicious HTML directly from the RESTful API, server-side sanitization will protect the system.
-
Web developers tend to use the following libraries for client-side/DOM-level sanitization:
i)
DOMPurity
: HTML sanitizer library for JavaScript, that also works on server-side Node.js via thejsdom
packageii)
js-xss
: An HTML sanitizer library that works on browser, server-sideNode.js
, and as a command-line tooliii)
sanitize-html
: An htmlparser2-based sanitizer library forNode.js
and browser that’s very popular among React developers because there is a wrapper library especially for ReactThese libraries typically parse unsafe HTML using either the browser’s inbuilt DOM iterator, or a custom HTML parser that excludes unsafe HTML content before using
innerHTML
. -
HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and final major HTML version that is a World Wide Web Consortium (W3C) recommendation. The current specification is known as the HTML Living Standard.
It is maintained by the Web Hypertext Application Technology Working Group (WHATWG), a consortium of the major browser vendors (Apple, Google, Mozilla, and Microsoft). It was initially released on 22 January 2008.
-
HTML5 introduces a number of new elements and attributes that can help you in building modern websites. Here is a set of some of the most prominent features introduced in HTML5
-
New Semantic Elements
− These are like<header>
,<footer>
, and<section>
. -
Forms 2.0
− Improvements to HTML web forms where new attributes have been introduced for<input>
tag. -
Persistent Local Storage
− To achieve without resorting to third-party plugins. -
WebSocket
− A next-generation bidirectional communication technology for web applications. -
Server-Sent Events
− HTML5 introduces events which flow from web server to the web browsers and they are called Server-Sent Events (SSE). -
Canvas
− This supports a two-dimensional drawing surface that you can program with JavaScript. -
Audio & Video
− You can embed audio or video on your webpages without resorting to third-party plugins. -
Geolocation
− Now visitors can choose to share their physical location with your web application. -
Microdata
− This lets you create your own vocabularies beyond HTML5 and extend your web pages with custom semantics. -
Drag and drop
− Drag and drop the items from one location to another location on the same webpage.
-
-
The following tags (elements) have been introduced in
HTML5
:<article>
- Represents an independent piece of content of a document, such as a blog or newspaper<aside>
- Represents a piece of content that is only slightly related to the rest of the page<audio>
- Defines an audio file.<canvas>
- This is used for rendering dynamic bitmap graphics on the fly, such as graphs or games.<command>
- Represents a command the user can invoke.<datalist>
- Together with the a new list attribute for input can be used to make comboboxes.<details>
- Represents additional information or controls which the user can obtain on demand.<embed>
- Defines external interactive content or plugin.<figure>
- Represents a piece of self-contained flow content, typically referenced as a single unit from the main flow of the document.<footer>
- Represents a footer for a section and can contain information about the author, copyright information, et cetera.<header>
- Represents a group of introductory or navigational aids.<hgroup>
- Represents the header of a section.<keygen>
- Represents control for key pair generation.<mark>
- Represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context.<meter>
- Represents a measurement, such as disk usage.<nav>
- Represents a section of the document intended for navigation.<output>
- Represents some type of output, such as from a calculation done through scripting.<progress>
- Represents a completion of a task, such as downloading or when performing a series of expensive operations.<ruby>
- Together with<rt>
and<rp>
allow for marking up ruby annotations.<section>
- Represents a generic document or application section<time>
- Represents a date and/or time.<video>
- Defines a video file.<wbr>
- Represents a line break opportunity.