Javascript examples for CSS Style Property:margin
Change all four margins of a <div> element to "25px":
<!DOCTYPE html> <html> <head> <style> #myDiv {// ww w.j a v a 2s . c o m border: 1px solid #FF0000; margin: 2cm 4cm 3cm 2cm; } </style> </head> <body> <div id="myDiv">This is a div.</div> <br> <button type="button" onclick="myFunction()">Change margin</button> <script> function myFunction() { document.getElementById("myDiv").style.margin = "25px"; } </script> </body> </html>