usharani

usharani

57 Articles Published

Articles by usharani

57 articles

C# Equivalent to Java's Double Brace Initialization?

usharani
usharani
Updated on 17-Mar-2026 372 Views

Java's Double Brace Initialization is a technique that allows creating and initializing collections in a single expression using an anonymous inner class. C# provides equivalent functionality through Collection Initializers and Object Initializers, which offer cleaner and more efficient syntax. Java Double Brace Initialization In Java, double brace initialization uses nested braces where the outer braces create an anonymous class and the inner braces contain an instance initializer − List list = new List() {{ add("One"); add("Two"); add("Three"); add("Four"); }} ...

Read More

Execute a script when a mouse pointer moves over an element in HTML?

usharani
usharani
Updated on 16-Mar-2026 421 Views

The onmouseover attribute in HTML triggers when a mouse pointer moves over an element. This event is commonly used to create interactive effects such as changing colors, displaying tooltips, or showing additional content when users hover over elements. Syntax Following is the syntax for the onmouseover attribute − Content The script parameter contains JavaScript code that executes when the mouse pointer enters the element's area. Basic Onmouseover Example Following example demonstrates how to change text color when hovering over a heading − Onmouseover Example ...

Read More

Execute a script when an element's scrollbar is being scrolled in HTML?

usharani
usharani
Updated on 16-Mar-2026 241 Views

When an element's scrollbar is being scrolled, the onscroll event attribute triggers and executes a specified JavaScript function. This event fires when the user scrolls within an element that has scrollable content, making it useful for creating interactive scroll-based behaviors. Syntax Following is the syntax for the onscroll event attribute − Content Alternatively, you can add the scroll event listener using JavaScript − element.addEventListener('scroll', functionName); How It Works The onscroll event fires whenever the scrollTop or scrollLeft property of an element changes due to user interaction. This includes scrolling ...

Read More

How to programmatically empty browser cache with HTML?

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

Browser caching improves website performance by storing files locally, but during development or when deploying updates, you may need to prevent caching to ensure users see the latest content. While HTML cannot directly empty the browser cache, it can control caching behavior through meta tags and cache-busting techniques. Understanding Browser Cache Control HTML provides meta tags that send HTTP headers to instruct browsers on how to handle caching. These directives tell the browser whether to cache the page, for how long, and when to revalidate the cached content. Syntax Following are the meta tags used to ...

Read More

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 378 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 indicate a potential word break point within a section in HTML?

usharani
usharani
Updated on 16-Mar-2026 192 Views

The HTML tag defines a potential line break point within text where the browser may choose to break a line if needed. The acronym stands for Word Break Opportunity. This element is particularly useful for long words, URLs, or code snippets that might otherwise cause horizontal scrolling or overflow issues. Syntax The tag is a self-closing empty element with the following syntax − In XHTML, it should be written as with a closing slash. How It Works The tag suggests to the browser where it can ...

Read More

How to use multiple click event on HTML5 canvas?

usharani
usharani
Updated on 16-Mar-2026 508 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

How to specify citation in HTML?

usharani
usharani
Updated on 16-Mar-2026 274 Views

The tag in HTML is used to specify citations or references to creative works such as books, articles, movies, songs, or research papers. The content within the tag typically appears in italics by default in most browsers, indicating that it represents the title of a referenced work. Syntax Following is the syntax for the tag − Title of the work The tag is an inline element that should contain only the title of the work being referenced, not the author's name or additional descriptive text. Basic Citation Example ...

Read More

What is the difference between void, eval, and the Function constructor in JavaScript?

usharani
usharani
Updated on 15-Mar-2026 451 Views

JavaScript provides three distinct features for executing and manipulating code: void, eval(), and the Function constructor. Each serves different purposes and has unique characteristics. The void Operator The void operator evaluates an expression and always returns undefined. It's commonly used to prevent unwanted return values or create undefined values explicitly. Syntax void expression void(expression) Example // Basic void usage console.log(void 0); ...

Read More
Showing 1–10 of 57 articles
« Prev 1 2 3 4 5 6 Next »
Advertisements