किसी एलिमेंट का पैडिंग सेट करने के लिए जावास्क्रिप्ट में padding प्रॉपर्टी का उपयोग करें। जावास्क्रिप्ट के साथ किसी एलिमेंट का पैडिंग जोड़ना सीखने के लिए निम्न कोड चलाकर देखें:
उदाहरण
<!DOCTYPE html> <html> <head> <style> #box { border: 2px solid #FF0000; width: 150px; height: 70px; } </style> </head> <body> <div id = "box">यह डेमो टेक्स्ट है।</div> <br><br> <button type = "button" onclick = "display()">पैडिंग जोड़ें</button> <script> function display() { document.getElementById("box").style.padding = "20px 30px 10px 50px"; } </script> </body> </html>