Page Content

Posts

What is HTML5? and It’s features

HTML5 is the latest and most improved version of HTML. HTML, in general, is not a programming language but rather a markup language used for structuring and presenting content on the World Wide Web.

Evolution of HTML: HTML5 is an evolution of earlier versions of HTML and builds upon HTML4. It receives the huge majority of features from its ancestors, meaning prior knowledge of HTML is still largely applicable.

Features of HTML5

  • Backward Compatibility: A design of HTML5 is backward compatibility. It means much of HTML5 works in both old and new browsers, and new features are designed to build on existing features, allowing for alternative content for older browsers.
  • New Features: HTML5 presents a number of new elements and attributes to support in building modern websites.
  • New Semantic Elements: Elements like <header>, <footer>, <article>, <section>, <nav>, <aside>, and <figure> are introduced to describe content more meaningfully. It helps in creating a better document outline.
  • Forms 2.0: Advances to web forms with new attributes for the<input> tag and new input types like email, url, number, range, date, time, month, week, and color. New attributes like placeholder, required, autofocus, autocomplete, and pattern are also included.
  • Audio and Video: The <audio> and <video> tags allow for embedding audio and video on web pages without third-party plugins.
  • Canvas: The<canvas> element supports a two-dimensional drawing surface that can be programmed with JavaScript for creating graphics, games, and animations.
  • Geolocation: It allows web applications to access the physical location of visitors (with their permission).
  • Persistent Local Storage: Enables storing data locally within the user’s browser without needing third-party plugins.


WebSocket:

  • A next-generation bidirectional communication technology for web applications, allowing for real-time communication.
  • It creates a full-duplex connection between a web browser (client) and a server over a single Transmission Control Protocol (TCP) socket. This allows for real-time communication, where both the client and the server can send and receive data at the same time after an initial handshake.
  • Different from HTTP communication, which is displaced and involves the browser initiating requests and the server responding, WebSocket provides a persistent connection. It begins as an HTTP connection and then “upgrades” to a TCP socket after an HTTP handshake. This upgrade reduces unnecessary network traffic and latency compared to older techniques like polling and Comet, which were used to simulate real-time interactions.
  • A  JavaScript application creates a WebSocket object, providing the URL of the WebSocket server endpoint (using ws:// or wss:// for secure connections). The WebSocket object has attributes  readyState to indicate the connection state (e.g., connecting, open, closing, closed) and events such as onopen (when the connection is established), onmessage (when data is received from the server), onerror (when an error occurs), and onclose(when the connection is closed). Data is sent using the send()method and received via the onmessageevent handler.
  • WebSockets are used in live online games, stock tickers, and chat clients. The client-side API is critical for front-end developers. WebSocket also requires a server-side implementation that supports the WebSocket protocol to handle connections and exchange data. Due to evolving standards, using libraries like Socket.io is often recommended to handle variations in browser support .


Server-Sent Events (SSE):

  • Server-Sent Events (SSE) is a mechanism where a web page automatically receives updates from a server. Instead of the model where the web page has to frequently ask the server for new information, with SSE, the server can push updates to the client as they become available. This establishes a unidirectional connection, meaning the server sends data to the client, but not the other way around, through the same determined connection.
  • To use SSE, a JavaScript application creates an EventSource object, providing the URL of the server-side script that will stream the events. The client  listens for ‘message’ events on this EventSource object. The server-side script needs to respond with a specific text/event-stream content type and format the data accordingly.
  • Examples of SSE usage displaying live updates such as social media feeds, stock prices, news tickers, and sports results. This technology offers a simpler alternative to WebSockets for situations requiring only server-to-client communication.
  • Microdata: Lets developers create their own vocabularies beyond HTML5 and extend web pages with custom semantics.
  • Drag and Drop: Enables users to drag and drop items from one location to another on the same webpage.
  • Collaboration: HTML5 is a collaboration between the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG). The WHATWG was initially formed by individuals from browser vendors.
  • Focus on Web Applications: HTML5 is a platform for dynamic web applications, a markup language to include APIs for developing browser-based software.
  • New DOCTYPE: HTML5 uses a simplified <!DOCTYPE html> declaration, which is case-insensitive. This triggers browsers to extract the page in standards-compliant mode. The older, more complex DOCTYPE statements from previous HTML versions are no longer required.
  • Relationship with CSS and JavaScript: HTML5 works closely with CSS3 for styling and JavaScript for interactivity and more advanced features.
  • Simplified Syntax: HTML5 introduces some simplifications in syntax, such as making the type attribute optional for the <script> tag and allowing for a simpler way to specify character encoding using <meta charset=”UTF-8″>. HTML5 tag names are case-insensitive.
  • Accessibility: HTML5 works closely with the Web Accessibility Initiative (WAI) Accessible Rich Internet Applications (ARIA) to support users with disabilities.
  • HTML and XHTML Syntax: HTML5 is designed to be compatible with both HTML and XHTML documents in terms of syntax. It can be written using the traditional HTML syntax or a stricter, XML-like syntax often referred to as XHTML5.
  • In essence, HTML5 represents a step forward for web development, offering new tools and capabilities while maintaining compatibility with existing web technologies.