CSS Width

CSS width property is used to set width of the content area of an element.

  • The width of an element does not include padding, borders, margins.
  • It sets the width of the area inside the padding, border, and margin of the element.
  • The min-width and max-width properties override width.

Width Syntax

width: value;

CSS Width: Parameters

  • length: Defines the width value in pixels, em, cm, etc.
  • percentage: Defines the width value in percentage.
  • auto: The browser will calculate the width for the element, by default.
  • inherit: Element will inherit the width from its parent element.

Example of width:50%

.div_1 {
     background-color: green;
     width: 50%;
     padding: 10px;
  }

Output

Width: 50%

Hello! This is a paragraph inside the div; The width of div is 50%, and padding of this div is 10px with green background-color property.

Example with Height & Width

.div_1 {
     background-color: 1d6792;
     width: 50%;
     height: 150px;
     color: #fff;
     padding: 10px;
  }

Output

The width: 50% | height: 200px

Hello! This is a paragraph inside a div; The width of div is 50% & height 200px, padding 10px, and color value is #fff with background-color:#1d6792.

Related Topics

Ruchi Kalra Net Worth 2024, Business, Salary, Income Source, Car, House

Mohit Saxena Net Worth 2024, Business, Salary, Income Source, Car, House

Vatsal Rustagi Net Worth 2024, Business, Salary, Income Source, Car, House

Bhupinder Singh Net Worth 2024, Business, Salary, Income Source, Car, House

Swapnil Jain Net Worth 2024, Business, Salary, Income Source, Car, House

Naga Bharath Daka Net Worth 2024, Business, Salary, Income Source, Car, House

Upasana Taku Net Worth 2024, Business, Salary, Income Source, Car, House

Arun Lodhi Net Worth 2024, Business, Salary, Income Source, Car, House

Anshuman Kumar Net Worth 2024, Business, Salary, Income Source, Car, House

Akhil Gupta Net Worth 2024, Business, Salary, Income Source, Car, House

Nita Ambani Net Worth 2024, Business, Salary, Income Source, Car, House

What does the economy do to peoples?

Saurabh Arora Net Worth 2024, Business, Salary, Income Source, Car, House

Average salary in Hong Kong

How does GDP reflect the economic position of a Country?

Angad Kikla Net Worth 2024, Business, Salary, Income Source, Car, House

When Dholera project was started?

Average salary in Somalia

What are the types of Digital Marketing?

How many Languages does Bill Gates can speak?

Bernard Arnault Net Worth 2024, Business, Salary, Income Source, Car, House

Top 100 Business Women in India 2024

What is the GDP of Haryana?

Aprameya Radhakrishna Net Worth 2024, Business, Salary, Income Source, Car, House

What is a Digital Marketing Company?

How many Languages does Larry Ellison can speak?

Shloka Mehta Net Worth 2024, Business, Salary, Income Source, Car, House

What is the GDP of Germany?

What are accounting methods?

Sachin Gupta Net Worth 2024, Business, Salary, Income Source, Car, House

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

© 2023 GDATAMART.COM (All Rights Reserved)