Меню
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON PHP КАК СДЕЛАТЬ
     ❯   

CSS Справочники


CSS Свойства





width



Example

Set the width of three <div> elements:

div.a {
  width: auto;
  border: 1px solid black;
}

div.b {
  width: 150px;
  border: 1px solid black;
}

div.c {
  width: 50%;
  border: 1px solid black;
}
Try it Yourself »

Definition width

Подработка: Перевод страницы

The width property sets the width of an element.

The width of an element does not include padding, borders, or margins!

Note: The min-width and max-width properties override the width property.

Show demo ❯

Default value: auto
Inherited: no
Animatable: yes. Read about animatable Try it
Version: CSS1
JavaScript syntax: object.style.width="500px" Try it

Browser Support width

The numbers in the table specify the first browser version that fully supports the property.

Property
width 1.0 4.0 1.0 1.0 3.5


CSS Syntax width

width: auto|value|initial|inherit;

Property Values width

Value Description Demo
auto Default value. The browser calculates the width Demo ❯
length Defines the width in px, cm, etc. Read about length units Demo ❯
% Defines the width in percent of the containing block Demo ❯
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

More Examples width

Example

Set the width of an <img> element using a percent value:

img {
  width: 50%;
}
Try it Yourself »
Example

Set the width of an <input type="text"> element to 100px. However, when it gets focus, make it 250px wide:

input[type=text] {
  width: 100px;
}

input[type=text]:focus {
  width: 250px;
}
Try it Yourself »

Related Pages width

CSS tutorial: CSS Height and Width

CSS tutorial: CSS Box model

CSS reference: height property

HTML DOM reference: width property



×

Связаться с отделом продаж

Если вы хотите использовать услуги schoolsw3 как образовательное учреждение, команда или предприятие, отправьте нам электронное письмо:
sales@schoolsw3.com

Сообщить об ошибке

Если вы хотите сообщить об ошибке или внести предложение, отправьте нам электронное письмо:
help@schoolsw3.com

Schoolsw3 оптимизирован для обучения и подготовки. Примеры могут быть упрощены для улучшения чтения и обучения. Учебники, ссылки и примеры постоянно проверяются, чтобы избежать ошибок, но мы не можем гарантировать полную правильность всего контента.
При использовании Schoolsw3 вы соглашаетесь прочитать и принять наши условия использования,
политику использования файлов cookie и конфиденциальности.

Авторское право 1999- © Copyright. Все права защищены. Schoolsw3 работает на SW3.CSS.