Свойство paddingLeft
- Предыдущая страница paddingBottom
- Следующая страница paddingRight
- Вернуться на один уровень вверх Объект Style HTML DOM
定义和用法
paddingLeft
Definition and usage
paddingLeft Sets or returns the left inner padding of the element. padding-left attribute margin property
and
All insert space around the element. However, the difference is that margin inserts space around the border, while padding inserts space inside the element's border.Внутренний отступ CSS
See also:CSS Tutorial:
CSS Reference Manual:padding-left attribute
HTML DOM Reference Manual:
Padding property
Instance
Example 1
Set the left inner padding of the <div> element:
Example 2
Change the left inner padding of the <div> element back to "normal":
Example 3
Returns the left inner padding of the <div> element:
alert(document.getElementById("myDiv").style.paddingLeft);
Example 4
Difference between marginLeft and paddingLeft:
function changeMargin() { document.getElementById("myDiv").style.marginLeft = "100px"; } function changePadding() { document.getElementById("myDiv2").style.paddingLeft = "100px"; }
Syntax
Return the paddingLeft property:
object.style.paddingLeft
Set the paddingLeft property:
object.style.paddingLeft = "%|length|initial|inherit"
Attribute value
Value | Description |
---|---|
% | Defined by the percentage of the parent element width to define the left inner padding. |
length | Defined by length units to define the left inner padding. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical details
Default value: | 0 |
---|---|
Return value: | A string that represents the left inner padding of an element. |
CSS version: | CSS1 |
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Поддержка | Поддержка | Поддержка | Поддержка | Поддержка |
- Предыдущая страница paddingBottom
- Следующая страница paddingRight
- Вернуться на один уровень вверх Объект Style HTML DOM