Compartilhar via


padding property

Sets or retrieves the amount of space to insert between the object and its margin or, if there is a border, between the object and its border.

 

Syntax

Integer value = object.put_padding( v);Integer value = object.get_padding(* sPadding);

Property values

Type: BSTR

length (0)

Floating-point number, followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px). For more information about the supported length units, see CSS Values and Units Reference.

percentage

Integer, followed by a %. The value is a percentage of the width of the parent object.

String format

<length> | <percentage>

CSS information

Applies To All elements
Media visual
Inherited no
Initial Value (see individual properties)

Standards information

Remarks

This is a composite property that specifies up to four padding values, in the following order: top, right, bottom, left. If one width value is specified, it is used for all four sides. If two width values are specified, the first is used for the top and bottom borders, and the second is used for left and right borders. If three width values are specified, they are used for top, right/left, and bottom borders, respectively. Negative values are not allowed.

The below illustration shows the content, padding, border, and margin areas of a basic box. The red labels illustrate the edges of each of these areas.

As of Microsoft Internet Explorer 5.5, this property applies to inline elements. With earlier versions of Windows Internet Explorer, inline elements must have an absolute IHTMLCSSStyleDeclaration::position or layout to use this property. Element layout is set by providing a value for the IHTMLCSSStyleDeclaration::height property or the IHTMLCSSStyleDeclaration::width property.

Examples

In the following example, a div element contains text and specifies IHTMLCSSStyleDeclaration::width, IHTMLCSSStyleDeclaration::border, and IHTMLCSSStyleDeclaration::padding values.

<div id="padding">
   Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</div>

In the CSS below, the first IHTMLCSSStyleDeclaration::padding value sets IHTMLCSSStyleDeclaration::paddingTop to 5 pixels, the second value sets IHTMLCSSStyleDeclaration::paddingRight to 10 pixels, the third value sets IHTMLCSSStyleDeclaration::paddingBottom to 15 pixels, and the fourth value sets IHTMLCSSStyleDeclaration::paddingLeft to 20 pixels.

#padding {
   width: 200px;
   border: .5em solid #BBBBBB;
   padding: 5px 10px 15px 20px;
}

The following image shows the result.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows 2000 Server

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

CSS Enhancements in Internet Explorer 6