Javascript examples for CSS Style Property:paddingLeft
The paddingLeft property sets or gets the left padding of an element.
Value | Description |
---|---|
% | Defines the left padding in percentage of the width of the parent element |
length | Defines the left padding in length units |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | 0 |
Return Value: | A String, representing the left padding of an element |
CSS Version | CSS1 |
Set the left padding of a <div> element:
<!DOCTYPE html> <html> <head> <style> #myDiv {/* ww w .j a v a 2 s . c o m*/ border: 1px solid #FF0000; } </style> </head> <body> <div id="myDiv" style="padding-left:5cm;">This is a div.</div> <br> <button type="button" onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("myDiv").style.paddingLeft = '20px'; } </script> </body> </html>