mkotla

mkotla

77 Articles Published

Articles by mkotla

Page 2 of 8

How to customize the position of an alert box using JavaScript?

mkotla
mkotla
Updated on 15-Mar-2026 3K+ Views

To customize the position of an alert box, you need to create a custom alert since the native JavaScript alert() function cannot be positioned. We can build a custom alert box using HTML, CSS, and JavaScript, then control its position using CSS properties like top and left. Creating a Custom Alert Box The native alert() box position is controlled by the browser and cannot be customized. Instead, we create a custom modal dialog that mimics an alert box behavior. Example: Custom Positioned Alert Here's how to create a custom alert box with customizable positioning: ...

Read More

Why in JavaScript, "if ('0' == false)" is equal to false whereas it gives true in "if(0)" statement?

mkotla
mkotla
Updated on 15-Mar-2026 2K+ Views

JavaScript's comparison behavior can be confusing when mixing different data types. Let's examine why '0' == false returns true while if(0) evaluates to false. Understanding '0' == false When using the loose equality operator ==, JavaScript performs type coercion following specific rules: console.log('0' == false); // true console.log(typeof '0'); // "string" console.log(typeof false); // "boolean" true string boolean The comparison follows this rule: If Type(y) is Boolean, return the result of the comparison x == ToNumber(y) Here's what happens step by step: ...

Read More

What is the difference between an acronym and abbr tags?

mkotla
mkotla
Updated on 15-Mar-2026 808 Views

In HTML, both acronym and abbreviation tags are used to mark shortened forms of words or phrases, but they have key differences in support and usage. An acronym is a word formed by taking the first letters of each word in a phrase (like "NASA" from "National Aeronautics and Space Administration"). An abbreviation is any shortened form of a word or phrase (like "Mr." for "Mister"). The Acronym Tag (Deprecated) The tag was used in older HTML versions to mark acronyms specifically. However, it is deprecated in HTML5 and should not be used in modern web ...

Read More

How to use the submit button in HTML forms?

mkotla
mkotla
Updated on 15-Mar-2026 5K+ Views

Submit button automatically submits a form on click. Using HTML forms, you can easily take user input. The tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc. Let's learn about how to use the submit button in HTML forms. It is created using HTML tag with the type attribute set to "submit". HTML Form with Submit Button ...

Read More

How to define a measurement in screen pixels with CSS?

mkotla
mkotla
Updated on 15-Mar-2026 224 Views

To define a measurement in screen pixels with CSS, use the px unit. The pixel (px) is an absolute unit that represents a single dot on the screen and provides precise control over element sizing and positioning. Syntax property: value px; Example: Using Pixels for Positioning and Sizing .pixel-example { position: relative; left: 90px; ...

Read More

How to set multiple cookies in JavaScript?

mkotla
mkotla
Updated on 15-Mar-2026 4K+ Views

In JavaScript, you can set multiple cookies by calling document.cookie multiple times. Each call adds a new cookie to the browser's cookie store. Unlike other properties, document.cookie doesn't overwrite existing cookies — it appends new ones. Basic Syntax for Multiple Cookies document.cookie = "cookie1=value1"; document.cookie = "cookie2=value2"; document.cookie = "cookie3=value3"; Example: Setting Multiple Cookies Here's a complete example showing how to add, list, and remove multiple cookies: var num = 1; ...

Read More

How to set font size using CSS Measurement Unit vmin?

mkotla
mkotla
Updated on 15-Mar-2026 249 Views

The vmin CSS unit sets font size based on the smaller dimension of the viewport (width or height). It's useful for creating responsive text that scales with screen size. What is vmin? The vmin unit represents 1% of the viewport's smaller dimension. If the viewport is 800px wide and 600px tall, 1vmin = 6px (1% of 600px). Syntax font-size: [number]vmin; Example vmin Font Size Example ...

Read More

Set the Background Image Position with CSS

mkotla
mkotla
Updated on 15-Mar-2026 619 Views

To set the background image position, use the background-position property. This CSS property controls where the background image is positioned within its container element. Syntax background-position: horizontal vertical; The property accepts various values including pixels, percentages, and keywords like left, right, center, top, and bottom. Example: Positioning with Pixels This example sets the background image position 80 pixels from the left and centers it vertically: body { ...

Read More

Underline text with CSS

mkotla
mkotla
Updated on 15-Mar-2026 1K+ Views

Use the text-decoration property to underline text with CSS. This property provides several options for decorating text, with underline being one of the most commonly used values. Syntax text-decoration: underline; Basic Example India Different Underline Styles You can customize the underline appearance using additional properties: ...

Read More

What is the difference between closure and nested functions in JavaScript?

mkotla
mkotla
Updated on 15-Mar-2026 1K+ Views

In JavaScript, closures and nested functions are related but distinct concepts. A closure occurs when an inner function retains access to variables from its outer function's scope, even after the outer function has finished executing. Nested functions are simply functions defined inside other functions. JavaScript Closures A closure is formed when a function "closes over" variables from its lexical scope. The inner function remembers the environment in which it was created, not where it's called. JavaScript Closures JavaScript Closures Example ...

Read More
Showing 11–20 of 77 articles
« Prev 1 2 3 4 5 8 Next »
Advertisements