HTML DOM left Property
Complete Style Object Reference
Definition and Usage
The left property sets how far the left edge of an element is to the
right/left of the left edge of the parent element.
Syntax
Object.style.left=auto|%|length
|
Possible Values
Value |
Description |
auto |
Lets the browser calculate the left position |
% |
Sets the left position in % from the left edge of the
parent element |
length |
Sets the left position in px, cm, etc. from the
left edge of the parent element. Negative values are allowed |
Tips and Notes
Note: If the "position" property has a value of "static", the "left"
property has no effect.
Example
The following example sets the left edge of an element:
<html>
<head>
<style type="text/css">
input
{
position:absolute;
}
</style>
<script type="text/javascript">
function setLeftEdge()
{
document.getElementById("b1").style.left="100px";
}
</script>
</head>
<body>
<input type="button" id="b1" onclick="setLeftEdge()"
value="Set left edge to 100 px" />
</body>
</html>
|
Try-It-Yourself Demos
left -
Set left edge of an element
Complete Style Object Reference
|
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.
The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).
|
|