Tryit Editor v1.8

Source Code:
<!DOCTYPE html> <html> <head> <style type="text/css"> div { border: 1px solid #FF0000; } </style> <script> function changeMargin() { document.getElementById("ex1").style.marginTop="100px"; } function changePadding() { document.getElementById("ex2").style.paddingTop="100px"; } </script> </head> <body> <div id="ex1">This is some text.</div> <br> <button type="button" onclick="changeMargin()">Change top margin of the div element</button> <br> <br> <div id="ex2">This is some text.</div> <br> <button type="button" onclick="changePadding()">Change top padding of the div element</button> </body> </html>
Result:
W3Schools.com - Try it yourself