Front End Technology Articles

Page 3 of 652

jQuery Data vs Attr?

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

The data() method in jQuery is used to fetch values of custom data attributes from HTML elements and manages an internal cache system. The attr() method is used to get or set standard HTML attributes and directly manipulates the DOM. Understanding when to use each method is crucial for effective jQuery development. Syntax Following is the syntax for the jQuery data() method − $(selector).data(key); // Get data $(selector).data(key, value); // Set data Following is the syntax for the jQuery attr() method − ...

Read More

Is wrapping a div inside an anchor tag valid code?

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

Yes, wrapping a div inside an anchor tag is valid HTML5 code. Prior to HTML5, this was not allowed, but HTML5 specifications permit block-level elements like to be nested inside tags, making entire sections clickable. Syntax Following is the basic syntax for wrapping a div inside an anchor tag − Content This makes the entire div element clickable as a single link. Basic Example Following example demonstrates a simple div wrapped inside an anchor tag − Div ...

Read More

How to make horizontal line with words in the middle using CSS?

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

With CSS, we can create horizontal lines with content in the middle using various techniques. This design pattern is commonly used for section dividers, decorative headings, and visual separators in web layouts. We can place text, headings, or even images between horizontal lines for an elegant visual effect. Syntax The most common approach uses CSS flexbox with pseudo-elements ::before and ::after − .element { display: flex; flex-direction: row; } .element::before, .element::after { content: ""; flex: 1 1; border-bottom: 1px solid color; ...

Read More

How to create a responsive custom scrollbar using CSS?

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 650 Views

Custom scrollbars enhance the visual appeal of web pages by replacing the browser's default scrollbar with custom-styled alternatives. Using CSS webkit-scrollbar pseudo-elements, you can create responsive scrollbars that match your website's design theme and provide better user interaction feedback. Syntax The basic syntax for creating custom scrollbars uses webkit pseudo-elements − ::-webkit-scrollbar { width: 12px; } ::-webkit-scrollbar-track { background: #f1f1f1; } ::-webkit-scrollbar-thumb { background: #888; } ::-webkit-scrollbar-thumb:hover { background: #555; } Webkit Scrollbar Pseudo-Elements The following webkit pseudo-elements ...

Read More

How to center a "position: absolute" element?

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

Centering an element with position: absolute requires specific CSS techniques since absolutely positioned elements are removed from the normal document flow. There are several methods to achieve horizontal, vertical, or both types of centering for absolute elements. Understanding Absolute Positioning When an element has position: absolute, it is positioned relative to its nearest positioned ancestor (or the viewport if no positioned ancestor exists). The element's position is determined by the top, right, bottom, and left properties. Method 1: Using Negative Margins This traditional method requires knowing the exact dimensions of the element. You position the element ...

Read More

How do I keep two side-by-side div elements the same height?

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

We need to keep two side-by-side div elements the same height so that when more content is added to either div, both divs automatically match in height. This creates a consistent, professional layout that prevents uneven column appearances. There are several approaches to achieve equal height columns. We will explore the most effective methods − CSS Table Display − Using display: table-cell for automatic height matching CSS Flexbox − Modern approach with display: flex CSS Grid − Grid layout for equal height columns JavaScript − Programmatically setting heights to match Equal Height ...

Read More

How do you keep parents of floated elements from collapsing in CSS?

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 283 Views

When elements are floated using CSS, their parent container loses awareness of their dimensions, causing the parent to collapse and appear as if it has no content. This happens because floated elements are removed from the normal document flow, making the parent container unable to calculate its height based on the floated children. This article demonstrates the problem and provides several effective solutions to prevent parent collapse when containing floated elements. Understanding Parent Collapse Before applying fixes, let's first observe how parent collapse occurs with floated elements. Example − Normal Flow Without Floats Here's how ...

Read More

How to disable Google Chrome autofill option?

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

Google Chrome's autofill feature can sometimes interfere with user experience by automatically populating form fields with previously entered data. To disable this functionality, you can use the autocomplete attribute with specific values that prevent Chrome from filling in form data. Syntax Following is the syntax to disable autofill on form elements − The autocomplete attribute can be applied to both the element and individual elements to control autofill behavior. Using autocomplete="off" The standard approach is to set autocomplete="off" on the form or individual input fields. However, Chrome may ...

Read More

Recommended way to embed PDF in HTML?

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

To embed a PDF in HTML, there are several methods available, each with its own advantages and use cases. The most commonly used approaches are the , , and elements. Let us explore each method with their syntax and implementation details. Methods to Embed PDF The three primary methods for embedding PDFs in HTML are − iframe element − Most widely supported and provides fallback content options. embed element − Simple self-closing tag with direct plugin integration. object element − W3C recommended standard with robust fallback support. Using the iframe Element The ...

Read More

Disable browser caching with meta HTML tags

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

To disable browser caching with meta HTML tags, you can use specific meta elements that instruct the browser and intermediate caches not to store copies of your web page. This ensures that users always receive the most current version of your content. Syntax Following are the three essential meta tags used to disable browser caching − Understanding Cache Control Meta Tags The tag is an empty HTML element that provides metadata about the document. When used with the http-equiv attribute, it can simulate HTTP response headers that control browser ...

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