Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by usharani
57 articles
C# Equivalent to Java's Double Brace Initialization?
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 MoreExecute a script when a mouse pointer moves over an element in HTML?
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 MoreExecute a script when an element's scrollbar is being scrolled in HTML?
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 MoreHow to programmatically empty browser cache with HTML?
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 MoreBootstrap dropdown closing when clicked in HTML
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 MoreChange text color based on a brightness of the covered background area in HTML?
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 MoreHow to indicate a potential word break point within a section in HTML?
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 MoreHow to use multiple click event on HTML5 canvas?
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 MoreHow to specify citation in HTML?
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 MoreWhat is the difference between void, eval, and the Function constructor in JavaScript?
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