Sets or retrieves a Boolean value indicating whether the list should be compacted by removing extra space between list objects.
Syntax
| HTML | <element compact="p" ... > |
|---|---|
| JavaScript | |
Property values
Type: Boolean
true (true)
-
Removes extra space between objects in list.
false (false)
-
Default. Does not remove extra space between objects in list.
Standards information
- Document Object Model (DOM) Level 1 Specification, Section 2.5.5
- HTML 4.01 Specification, Section 10.2 (Deprecated)
Remarks
There is no functionality implemented for the compact property for the ul, ol, dir and menu elements unless defined by the author.
In Microsoft Internet Explorer 6 and greater, this property applies to the menu and dir objects.
Examples
The following example shows how to use the compact property in HTML. Note that the presence of the word COMPACT sets the compact property to true
<html> <body> <dl compact> <dt>Cat</dt> <dd>A small domesticated mammal.</dd> <dt>Lizard</dt> <dd>A reptile generally found in dry areas.</dd> </dl> </body> </html>
The following example shows how to set the compact property using JScript
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/compact.htm
<html>
<body>
<script type="text/ecmascript">
//Function that toggles the compact property for the DL element below
function compactDLToggle() {
animals.compact = !animals.compact;
toggle.innerText = "Compact = " + animals.compact;
}
</script>
<p style="color:blue; font-weight:bold">Effect of setting COMPACT property for a DL element</p>
<button id="toggle" onclick="compactDLToggle()">Toggle Compact Property</button>
<dl id=animals>
<dt>Cat</dt>
<dd>A small domesticated mammal.</dd>
<dt>Lizard</dt>
<dd>A reptile generally found in dry areas.</dd>
</dl>
</body>
</html>
See also
Send comments about this topic to Microsoft
Build date: 11/28/2012