Articles on Trending Technologies

Technical articles with clear explanations and examples

Facing Problem in retrieving HTML5 video duration

Chandu yadav
Chandu yadav
Updated on 12-Mar-2026 503 Views

A common problem when working with HTML5 video is that the duration property returns NaN (Not a Number) when you try to access it before the browser has finished loading the video's metadata. This happens because the video file's metadata (which contains the duration, dimensions, etc.) is not available immediately after the page loads. Why Does video.duration Return NaN? The HTML5 element has a readyState attribute that indicates how much data the browser has loaded. It has values from 0 to 4 − 0 (HAVE_NOTHING) − No data available yet. 1 (HAVE_METADATA) − Metadata (duration, dimensions) is loaded. ...

Read More

What is the usage of the cross-origin attribute in HTML5?

Arjun Thakur
Arjun Thakur
Updated on 12-Mar-2026 362 Views

The crossorigin attribute in HTML5 is a CORS (Cross-Origin Resource Sharing) settings attribute. It controls how the browser handles cross-origin requests when loading resources like images, scripts, and stylesheets from third-party domains.As the official specification states − The crossorigin attribute is a CORS settings attribute. Its purpose is to allow images from third-party sites that allow cross-origin access to be used with canvas. Why Is the crossorigin Attribute Needed?By default, when you load an image from a foreign origin and draw it onto an HTML5 , the canvas becomes tainted. A tainted canvas cannot be read back using methods like ...

Read More

Remember and Repopulate File Input in HTML5

Nancy Den
Nancy Den
Updated on 12-Mar-2026 387 Views

Browsers do not allow you to programmatically set the value of a file for security reasons. This means you cannot "remember" a previously selected file and repopulate the input on page reload using JavaScript alone. However, HTML5 introduced the Drag and Drop API along with the DataTransfer object, which provides a workaround − users can drag files onto a drop zone, and your code can process those files just like a file input would. How Drag and Drop Works with Files When a user drops a file onto a designated area, the browser fires a drop event. The dropped ...

Read More

Are new HTML5 elements like <section> and <article> useless?

Chandu yadav
Chandu yadav
Updated on 12-Mar-2026 186 Views

No, HTML5 semantic elements like and are not useless. They are extremely useful for screen readers and assistive technologies, helping visually impaired users navigate and understand the structure of your web page. They are also beneficial for eBook readers, search engines, and any tool that parses HTML for meaning. While you could use generic tags for everything, semantic elements convey the purpose of the content to both browsers and developers, making your code more readable and accessible. The Element The element represents a thematic grouping of content, typically with a heading. Use it to divide ...

Read More

HTML5 Canvas to PNG File

Daniol Thomas
Daniol Thomas
Updated on 12-Mar-2026 940 Views

To convert an HTML5 Canvas to a PNG file, you use the canvas.toDataURL() method. This method generates a base64-encoded data URL representing the canvas content as a PNG image. You can then use this data URL to display the image or trigger a file download. How canvas.toDataURL() Works The toDataURL() method returns a string containing the canvas image in the specified format. For PNG, the returned string looks like this − data:image/png;base64, iVBORw0KGgoAAAANSUhEUg.... You can assign this data URL to an tag's src attribute to display the canvas content as a regular image − ...

Read More

C++ Program to Find GCD

Samual Sam
Samual Sam
Updated on 12-Mar-2026 15K+ Views

The Greatest Common Divisor (GCD) of two numbers is the largest number that divides both of them without leaving a remainder. For example, let's say we have two numbers 45 and 27 − 45 = 5 * 3 * 3 27 = 3 * 3 * 3 The common factors are 3 and 3, so the GCD of 45 and 27 is 9. Using Euclidean Algorithm (Modulo Method) The Euclidean algorithm finds the GCD by repeatedly replacing the larger number with the remainder of dividing the two numbers, until the remainder becomes 0. At that point, the other ...

Read More

Python program to count the elements in a list until an element is a Tuple?

AmitDiwan
AmitDiwan
Updated on 12-Mar-2026 673 Views

In this article, we will count the elements in a list until an element is a Tuple. A Python list can contain items of different types, including tuples. The goal is to iterate through the list and count how many elements appear before the first tuple is encountered. For example, given the following list − mylist = [25, 50, 75, 100, 125, (20, 175, 100, 87), 500] There are 5 elements (25, 50, 75, 100, 125) before the first tuple (20, 175, 100, 87), so the count is 5. Using isinstance() The isinstance() function checks whether an object ...

Read More

C++ Program to Find All Roots of a Quadratic Equation

karthikeya Boyini
karthikeya Boyini
Updated on 12-Mar-2026 9K+ Views

A quadratic equation is in the form ax2 + bx + c = 0. The roots of the quadratic equation are given by the following formula − x = −b ± √ b² − 4ac 2a The value b2 − 4ac is called the discriminant. It determines the nature of the roots. There are three cases − b2 > 4ac − The roots are real and different. b2 = 4ac − The roots are real and both roots are the same. b2 ...

Read More

Python program to find the number occurring odd number of times using Lambda expression and reduce function

AmitDiwan
AmitDiwan
Updated on 12-Mar-2026 4 Views

We can find the number occurring an odd number of times in a list using a Lambda expression and the reduce() function from the functools module. The approach uses the XOR (^) bitwise operator − XORing a number with itself cancels it out (returns 0), so after XORing all elements, only the number that appears an odd number of times remains. For example, given the following input − ele = [10, 20, 20, 30, 40, 20, 30, 10, 40] The output is 20, because 20 occurs three times (an odd count), while all other integers appear an even ...

Read More

Create a tabbed navigation menu with Bootstrap

AmitDiwan
AmitDiwan
Updated on 12-Mar-2026 370 Views

To create a tabbed navigation menu, start with a basic unordered list with the base class of .nav and add class .nav-tabs. The navigation tab looks like the following on a web page − Create a Navigation tab Create a navigation tab with nav and nav-tabs − Home About Products Contact Us Set the Current Page Above, we have set the Home as active, since we wanted it to be the current page − Home Create a Tabbed Navigation Menu with ...

Read More
Showing 1–10 of 61,258 articles
« Prev 1 2 3 4 5 6126 Next »
Advertisements