JavaScript – Change the Padding of HTML Element
To change the padding of a HTML Element using JavaScript, get reference to this HTML Element, and assign required padding value to the element.style.padding
property.
In the following example, we will change the padding of HTML Element with id "myElement"
to "20px"
, in JavaScript, using element.style.padding
property.
example.html
ADVERTISEMENT
Conclusion
In this JavaScript Tutorial, we learned how to change the padding of a HTML Element using JavaScript.