# How to set the top margin of an element with JavaScript?

JavascriptWeb DevelopmentFront End Scripts

Use the marginTop property in JavaScript, to set the top margin. Can you try to run the following code to set the top margin of an element with JavaScript?

## Example

Live Demo

<!DOCTYPE html>
<html>
<style>
#myID {
border: 2px solid #000000;
}
</style>
</html>