Front End Technology Articles

Found 6,519 articles

Adding an element at a given position of the array in Javascript

Lokesh Badavath
Lokesh Badavath
Updated on 18-Mar-2026 606 Views

In this article, we are going to learn how to add an element at a given position of the array in JavaScript. An array is a special variable that can hold more than one value. JavaScript provides several ways to insert an element at a specific index, including the built-in splice() method and the spread operator approach. Syntax The most common way to insert an element at a given position is using the splice() method − array.splice(index, 0, element); Here, index is the position where the element should be inserted, 0 means no elements ...

Read More

UInt16.CompareTo() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 230 Views

The UInt16.CompareTo() method in C# is used to compare the current instance to a specified object or UInt16 and returns an indication of their relative values. This method is essential for sorting operations and conditional comparisons involving unsigned 16-bit integers. Syntax The UInt16.CompareTo() method has two overloads − public int CompareTo(object val); public int CompareTo(ushort val); Parameters val − In the first overload, it is an object to compare. In the second overload, it is an unsigned 16-bit integer to compare. Return Value The method returns an ...

Read More

How to remove the space between inline/inline-block elements in HTML?

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 1K+ Views

When using inline-block elements in HTML, unwanted whitespace often appears between them due to how browsers render whitespace in the HTML markup. This space comes from line breaks, spaces, and tabs between elements in your HTML code. There are several effective methods to remove this spacing. Understanding the Problem The space between inline-block elements occurs because browsers treat whitespace characters (spaces, tabs, line breaks) in HTML as actual content. When elements are displayed as inline-block, this whitespace becomes visible as gaps between the elements. Example − Inline-block Elements with Space Let us first see how the ...

Read More

How can I vertically align elements in a div?

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 6K+ Views

Vertically aligning elements within a div is a common requirement in web development. There are several effective methods to achieve perfect vertical alignment, each suitable for different scenarios and content types. Methods for Vertical Alignment We can vertically align elements in a div using any of the following approaches − Flexbox − Modern and most flexible approach Position property − Traditional method with absolute positioning Line-height property − Best for single-line text content Padding property − Simple method using equal top and bottom padding CSS Grid − Powerful layout method for complex alignments Using ...

Read More

How to remove extra space below the image inside div?

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 5K+ Views

To remove extra space below the image inside div, we can use CSS. Images are treated as inline elements by default, which creates unwanted space below them due to text baseline alignment. The following CSS properties can be used to eliminate this space − The vertical-align property The line-height property The display property The extra space occurs because browsers reserve space for descenders (like g, j, p, q, y) in text, even when no text is present. This creates a gap between the image and the bottom of its container. Image Spacing ...

Read More

How can I center text (horizontally and vertically) inside a div block?

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 9K+ Views

Centering text inside a div block both horizontally and vertically is a common layout requirement in web development. CSS provides several methods to achieve this alignment, each with its own advantages and use cases. Horizontal Text Centering Methods Using the text-align Property The text-align property is the most straightforward method for horizontal text centering. It determines how line boxes are aligned within a block-level element. The text-align property accepts the following values − left − Aligns text to the left edge of the container. right − Aligns text to the right edge of the ...

Read More

What is a clearfix?

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 379 Views

A clearfix is a CSS technique used to fix layout issues caused by floating elements. When elements are floated, they are taken out of the normal document flow, which can cause their parent container to collapse or not properly contain them. The clearfix forces the parent container to expand and properly wrap around its floated children. The Float Collapse Problem When you float elements inside a container, the container loses awareness of the floated elements' height. This causes the container to collapse, creating layout problems where content overflows outside its intended boundaries. Example − Without Clearfix ...

Read More

How to affect other elements when one element is hovered in HTML?

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 21K+ Views

To affect other elements when one element is hovered in HTML, you need to establish a relationship between the elements using CSS pseudo-classes and CSS selectors. The hover effect can target child elements, descendant elements, or adjacent sibling elements using the appropriate CSS combinators. The most common approach uses the :hover pseudo-class combined with descendant selectors to change styles of child elements when the parent is hovered. This technique works because CSS allows you to target elements based on their relationship to the hovered element. Syntax Following is the basic syntax for affecting child elements on hover ...

Read More

How do you get the footer to stay at the bottom of a Web page in HTML?

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 936 Views

Creating a footer that stays at the bottom of a web page is a common web design requirement. There are different approaches depending on whether you want a sticky footer (always visible at bottom of viewport) or a footer that stays at the page bottom (appears after all content). Using Fixed Position for Sticky Footer The position: fixed property creates a footer that remains visible at the bottom of the browser window, even when scrolling. This approach keeps the footer constantly visible to users. Syntax #footer { position: fixed; ...

Read More

How wide is the default margin?

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

The default body margin in HTML is 8px on all sides. This margin is applied by the browser's user-agent stylesheet, creating a small space between the page content and the viewport edges. Understanding and controlling this default margin is essential for creating precise web layouts. Default Margin in HTML All modern browsers apply a default margin of 8px to the element. This prevents content from touching the browser window edges, providing better readability. The margin appears as white space around your content. Example − Default 8px Margin Following example shows how the default margin creates ...

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