
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set Margins of an Element with JavaScript
Use the margin property in JavaScript, to set the margins. You can try to run the following code to set the margins of an element with JavaScript −
Example
<!DOCTYPE html> <html> <body> <button type="button" onclick="display()">Set all four margins</button> <p id="myID">This is demo text.</p> <script> function display() { document.getElementById("myID").style.margin = "30px 20px 40px 40px"; } </script> </body> </html>
Advertisements