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 varun
Page 2 of 7
Rules to override Style Sheet Rule in CSS
CSS follows a specific hierarchy when multiple styles are applied to the same element. Understanding the cascade and specificity rules helps you control which styles take precedence. CSS Cascade Priority Order CSS applies styles based on the following priority order, from highest to lowest: Inline styles - Styles applied directly to HTML elements using the style attribute Internal stylesheets - Styles defined within tags in the HTML document External stylesheets - Styles defined in separate CSS files linked to the HTML document Example: Style Override Hierarchy ...
Read MoreSet the font weight with CSS
The font-weight property controls how bold or light text appears. It accepts keyword values like normal and bold, or numeric values from 100 to 900. Syntax font-weight: normal | bold | bolder | lighter | 100-900; Font Weight Values Value Description Numeric Equivalent normal Regular text weight 400 bold Bold text weight 700 bolder Bolder than parent element Relative lighter Lighter than parent element Relative Example: Different Font Weights Font Weight Example ...
Read MoreWhat is the difference between local storage vs cookies?
Local storage and cookies are two different ways to store data in web browsers, each with distinct characteristics and use cases. Understanding their differences helps you choose the right storage mechanism for your web application. Storage Capacity Local storage offers significantly more storage space than cookies: Local Storage: Typically 5-10 MB per domain Cookies: Limited to 4 KB per cookie, with a maximum of about 20 cookies per domain Server Communication The key difference lies in how they interact with servers: // Local Storage - stays on client side localStorage.setItem('username', 'john_doe'); ...
Read MoreWhat are immediate functions in JavaScript?
Immediate functions in JavaScript are functions that execute automatically as soon as they are defined. They are also known as Immediately Invoked Function Expressions (IIFEs). These functions help create private scope and avoid polluting the global namespace. Syntax (function() { // Code here executes immediately })(); // Alternative syntax (function() { // Code here executes immediately }()); Basic Example (function() { var message = "Hello from IIFE!"; console.log(message); })(); // This variable is not ...
Read MoreHow to call a JavaScript function from an onClick event?
The onClick event is the most frequently used event type, which occurs when a user clicks the left button of the mouse. You can put your validation, warning etc., against this event type. Basic Syntax Click me Example: Simple onClick Function You can try to run the following code to call a JavaScript function from an onClick event: function display() { ...
Read MoreWhy is JavaScript case sensitive but HTML isn't?
A script is in plain text and not just markup like HTML, which is case insensitive. In JavaScript, the while keyword should be "while", not "While" or "WHILE". Case sensitivity is important since it is closely related to HTML, but some methods and events are mentioned differently. JavaScript has a strict syntax to process the client-side scripts written in JavaScript. Some tags and attributes in HTML have the same name as JavaScript objects and properties. In HTML, the attribute and tag names are case-insensitive. The close association of HTML and JavaScript can lead to confusion, so case sensitivity is ...
Read MoreDo we need to use semicolons in JavaScript?
In JavaScript, semicolons are optional in many cases due to Automatic Semicolon Insertion (ASI). While JavaScript can automatically insert semicolons at line breaks, it's considered good practice to include them explicitly for better code clarity and to avoid potential issues. How Automatic Semicolon Insertion Works JavaScript automatically inserts semicolons at the end of statements when certain conditions are met, primarily at line breaks where the code would otherwise be syntactically invalid. // Without semicolons - ASI will insert them let a = 5 let b = 10 console.log(a + b) 15 ...
Read MoreWhere is JavaScript Today?
JavaScript has evolved significantly since its creation in 1995. Today, it stands as one of the most popular and versatile programming languages in the world, powering everything from simple web interactions to complex server applications and mobile apps. Current JavaScript Standard The latest JavaScript standard is ECMAScript 2023 (ES14), released in June 2023. However, ECMAScript 2017 (ES8) remains widely supported and includes major features like async/await, Object.entries(), and string padding methods. The ECMA-262 Specification continues to define the core JavaScript language standards. JavaScript's Modern Role JavaScript is no longer limited to browser-based interactions. It has expanded ...
Read MoreCSS rest Speech Media property
The CSS rest property is a shorthand property for rest-before and rest-after properties. It sets a pause before or after an element when using speech synthesis or screen readers. Syntax selector { rest: rest-before rest-after; } Where: rest-before − Sets the pause duration before the element is spoken rest-after − Sets the pause duration after the element is spoken Possible Values ValueDescription timeDuration in seconds (s) or milliseconds (ms) noneNo pause (default value) x-weakVery short pause weakShort pause mediumMedium pause strongLong pause x-strongVery long pause ...
Read MoreSet top-left corner border with CSS
The CSS border-top-left-radius property is used to set a rounded border specifically for the top-left corner of an element. This property allows you to create asymmetric rounded corners where only the top-left corner has a different radius than other corners. Syntax selector { border-top-left-radius: value; } Possible Values ValueDescription lengthDefines the radius in px, em, rem, etc. %Defines the radius as a percentage of the element's dimensions initialSets the property to its default value inheritInherits the value from the parent element Example The following example demonstrates ...
Read More