CSS Articles

Page 27 of 130

How to set div width to fit content using CSS?

Shabaz Alam
Shabaz Alam
Updated on 15-Mar-2026 52K+ Views

To set div width to fit content using CSS is an important task for creating responsive designs and optimal space usage. By default, div elements take the full available width, but we can make them shrink to fit their content. Syntax div { width: max-content; /* or fit-content */ } /* Alternative approach */ div { display: inline-block; } Method 1: Using max-content Width Property The max-content value sets the width to the maximum intrinsic width of the content, allowing the div to expand ...

Read More

How to set color opacity with RGBA in CSS?

Shabaz Alam
Shabaz Alam
Updated on 15-Mar-2026 1K+ Views

The CSS RGBA color model allows developers to set color opacity directly within the color value. RGBA stands for Red, Green, Blue, and Alpha, where the alpha channel controls the transparency of the element. Syntax selector { color: rgba(red, green, blue, alpha); } Where: red, green, blue − Values from 0 to 255 representing color intensity alpha − Value from 0 to 1 representing opacity (0 = transparent, 1 = opaque) What is the RGBA Color Model? RGBA is an extension of the RGB color model with ...

Read More

How to set checkbox size in HTML/CSS?

Shabaz Alam
Shabaz Alam
Updated on 15-Mar-2026 7K+ Views

To set checkbox size in HTML/CSS, we can use several CSS properties to control the dimensions and scaling of checkboxes. By default, checkboxes have a small size that may not be suitable for all designs. Syntax input[type="checkbox"] { width: value; height: value; /* OR */ transform: scale(value); /* OR */ zoom: value; } Method 1: Using Width and Height Properties The most straightforward approach is to use the width and ...

Read More

How to set blur distance in CSS?

Shabaz Alam
Shabaz Alam
Updated on 15-Mar-2026 461 Views

CSS (Cascading Style Sheets) is a powerful tool for designing visual effects on websites. The blur effect is one of the many features in CSS, which is used to blur any element using the filter property with the blur() function. To create a soft, dreamy effect or to draw attention to a specific element on a page, we can use the blur effect. Syntax selector { filter: blur(distance); } The Concept of Blur Distance in CSS Before discussing the practical aspect of setting blur distance, it is important to understand ...

Read More

How to set background-image for the body element using CSS?

Shabaz Alam
Shabaz Alam
Updated on 15-Mar-2026 490 Views

The CSS background-image property is used to set a background image for any HTML element, including the body element. Setting a background image for the body creates a full-page background that enhances the visual appeal of your website. Syntax body { background-image: url('path/to/image.jpg'); } Basic Example Here's a simple example of setting a background image for the body element − body { background-image: url('https://www.tutorialspoint.com/dip/images/einstein.jpg'); ...

Read More

How to set alternate table row color using CSS?

Shabaz Alam
Shabaz Alam
Updated on 15-Mar-2026 11K+ Views

Setting alternate table row colors using CSS, also known as zebra striping, improves table readability by making it easier to distinguish between rows. This technique is essential for creating professional−looking data tables. Syntax /* Using nth-child selector */ tr:nth-child(even) { background-color: color; } tr:nth-child(odd) { background-color: color; } Method 1: Using nth-child Selector The nth-child() selector is the most popular method for creating zebra striping. It selects elements based on their position among all sibling elements − ...

Read More

How to set all the font properties in one declaration using CSS?

Shabaz Alam
Shabaz Alam
Updated on 15-Mar-2026 2K+ Views

CSS provides a shorthand property called font that allows you to set multiple font properties in a single declaration. This property combines font-style, font-variant, font-weight, font-size, line-height, and font-family into one convenient statement. Syntax selector { font: font-style font-variant font-weight font-size/line-height font-family; } Property Values PropertyValuesRequired font-stylenormal | italic | obliqueOptional font-variantnormal | small-capsOptional font-weightnormal | bold | 100-900Optional font-sizepx | em | rem | %Required line-heightnormal | number | lengthOptional font-familyfont names or generic familiesRequired Example 1: Basic Font Shorthand The following example demonstrates setting ...

Read More

How to set align-self property to its default value in CSS?

Shabaz Alam
Shabaz Alam
Updated on 15-Mar-2026 417 Views

CSS or Cascading Style Sheets provides the align-self property to control the alignment of individual flex items within a flex container. By default, align-self is set to auto, which means the element inherits the alignment from its parent container's align-items property. Syntax selector { align-self: auto; } Possible Values ValueDescription autoDefault. Inherits the align-items value of the parent container flex-startAligns the item to the start of the cross axis flex-endAligns the item to the end of the cross axis centerCenters the item along the cross axis baselineAligns the item ...

Read More

How to create progress bar using the HTML and CSS

Aman Gupta
Aman Gupta
Updated on 15-Mar-2026 2K+ Views

The progress bar is a visual element used to show the completion status of a task, file upload, or process. You can create an animated progress bar using HTML for structure and CSS for styling and animation effects. Syntax .progress-container { /* Container styling */ } .progress-bar { /* Progress bar styling */ animation: progress-animation duration timing-function; } @keyframes progress-animation { from { width: 0%; } to { width: target-percentage%; } } Example: ...

Read More

How to create Portfolio Gallery using the HTML and CSS

Aman Gupta
Aman Gupta
Updated on 15-Mar-2026 2K+ Views

A portfolio gallery is a collection of images and videos that showcase past work or achievements. Using HTML and CSS, we can create an attractive, responsive portfolio gallery that displays multiple project cards in a grid layout. Syntax The basic structure for a portfolio gallery uses flexbox for responsive layout − .gallery { display: flex; flex-wrap: wrap; gap: spacing; justify-content: center; } .card { width: fixed-width; height: fixed-height; ...

Read More
Showing 261–270 of 1,299 articles
« Prev 1 25 26 27 28 29 130 Next »
Advertisements