HTML Articles

Page 87 of 151

Bootstrap dropdown closing when clicked in HTML

usharani
usharani
Updated on 16-Mar-2026 2K+ Views

Bootstrap dropdowns automatically close when you click outside the dropdown area or on a dropdown item. Sometimes you may want to prevent the dropdown from closing when users click inside the dropdown content, allowing them to interact with forms, checkboxes, or other elements without the dropdown disappearing. Syntax Following is the syntax to prevent dropdown from closing using the hide.bs.dropdown event − $('#dropdownId').on('hide.bs.dropdown', function () { return false; }); Following is the syntax to prevent dropdown closing using stopPropagation() − $('#dropdownId .dropdown-menu').on('click', function(e) { ...

Read More

Change text color based on a brightness of the covered background area in HTML?

usharani
usharani
Updated on 16-Mar-2026 371 Views

Changing text color based on the brightness of the background ensures optimal readability and contrast. This technique calculates the luminance of the background color and automatically selects either black or white text for maximum visibility. How It Works The brightness calculation uses the relative luminance formula that weights RGB values according to human eye sensitivity. The formula gives more weight to green (587), moderate weight to red (299), and less weight to blue (114) since our eyes are most sensitive to green light. Syntax The luminance calculation formula is − var luminance = ((red ...

Read More

How to properly use h1 in HTML5?

varun
varun
Updated on 16-Mar-2026 316 Views

The h1 element in HTML5 defines the most important heading on a page or within a section. Unlike earlier HTML versions, HTML5 allows multiple h1 elements when used properly within sectioning elements like , , , and . The h1 element represents a heading, not a title. Each sectioning element can have its own h1 heading that describes the content of that specific section. The first h1 element in the document body typically serves as the main heading for the entire page. Syntax Following is the basic syntax for the h1 element − Heading Text ...

Read More

Drawing an image from a data URL to a HTML5 canvas

Arjun Thakur
Arjun Thakur
Updated on 16-Mar-2026 1K+ Views

When working with HTML5 Canvas, you can draw images from data URLs (base64-encoded images) directly onto the canvas. A data URL contains image data encoded as a string, eliminating the need for external image files. This technique is useful for dynamically generated images or when you need to display images stored as base64 strings. Syntax Following is the basic syntax for creating an image from a data URL − var myImg = new Image(); myImg.src = dataURL; Following is the syntax for drawing the image onto the canvas − context.drawImage(image, x, y); ...

Read More

Streaming a video file to an HTML5 video player with Node.js so that the video controls continue to work

Prabhas
Prabhas
Updated on 16-Mar-2026 338 Views

When streaming video files to an HTML5 video player with Node.js, it's essential to implement proper HTTP range request support to maintain video controls functionality. The HTML5 video element relies on partial content requests (HTTP 206) to enable seeking, scrubbing, and progressive loading. How HTTP Range Requests Work The browser sends a Range header (e.g., bytes=0-1023) to request specific portions of the video file. The server responds with a 206 Partial Content status and the requested byte range, allowing the video player to load segments on demand. Basic Video Streaming Setup Following example demonstrates the basic ...

Read More

What is the difference between SVG and HTML5 Canvas?

George John
George John
Updated on 16-Mar-2026 10K+ Views

The SVG (Scalable Vector Graphics) and HTML5 Canvas are both technologies for creating graphics on web pages, but they work in fundamentally different ways. SVG is a vector-based markup language that uses XML to define graphics, while Canvas is a bitmap-based drawing surface that uses JavaScript for creating graphics programmatically. What is SVG? SVG stands for Scalable Vector Graphics and is an XML-based markup language for describing 2D graphics. SVG graphics are composed of shapes, paths, text, and other elements defined through XML tags. The browser renders these elements as vector graphics, making them infinitely scalable without quality ...

Read More

HTML5 Geolocation without SSL connection

varma
varma
Updated on 16-Mar-2026 888 Views

HTML5 Geolocation allows web applications to access the user's location information through the browser's built-in geolocation API. While modern browsers typically require HTTPS for geolocation access, there are alternative approaches for non-SSL environments such as using IP-based location services or fallback methods. Browser Geolocation API The HTML5 Geolocation API provides access to the user's location through the navigator.geolocation object. This API requires user permission and works best over HTTPS connections. Syntax Following is the basic syntax for the geolocation API − navigator.geolocation.getCurrentPosition(successCallback, errorCallback, options); Example − Basic Geolocation ...

Read More

How to use multiple click event on HTML5 canvas?

usharani
usharani
Updated on 16-Mar-2026 502 Views

HTML5 canvas allows handling multiple click events by using Path2D objects to define different clickable regions. When a canvas contains multiple shapes or areas, each region can trigger different functions based on where the user clicks. The isPointInPath() method determines which specific path was clicked. Syntax Following is the syntax for creating Path2D objects − var path = new Path2D(); path.arc(x, y, radius, startAngle, endAngle); Following is the syntax for checking if a point is within a path − context.isPointInPath(path, x, y); How Multiple Click Events Work Multiple click ...

Read More

Applying a CSS style to an ID element when the beginning of its name stays identical and the end varies in HTML

Ankith Reddy
Ankith Reddy
Updated on 16-Mar-2026 114 Views

When you need to apply CSS styles to multiple HTML elements that have IDs with a common beginning but different endings, CSS attribute selectors provide an efficient solution. This technique is particularly useful for dynamically generated content where IDs follow a consistent naming pattern. Syntax Following is the syntax for selecting elements with IDs that begin with a specific value − element[id^="prefix"] { /* CSS properties */ } Following is the syntax for selecting elements with IDs that contain a specific substring − element[id*="substring"] { ...

Read More

What are start angle and end angle of arc in HTML5 canvas?

varun
varun
Updated on 16-Mar-2026 558 Views

The arc() method in HTML5 Canvas creates circular arcs and full circles. The startAngle and endAngle parameters define which portion of the circle to draw, measured in radians from the positive x-axis. Syntax Following is the syntax for the arc() method − arc(x, y, radius, startAngle, endAngle, anticlockwise) Parameters The arc() method accepts the following parameters − x, y − Coordinates of the circle's center point radius − The radius of the circle in pixels startAngle − Starting angle in radians, measured from the positive x-axis endAngle − Ending angle in ...

Read More
Showing 861–870 of 1,509 articles
« Prev 1 85 86 87 88 89 151 Next »
Advertisements