![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How wide is the default margin?
The default <body> margin is 8px in HTML. It is defined in pixels by the user-agent-stylesheet your browser provides. Some browsers allow you to create and use your own user-agent-stylesheet, but if you are developing a website, keep it the same.
Default Margin in HTML
Example
Let us see a simple example. Here, since the default margin is 8px, we won’t try to change it −
<!DOCTYPE html> <html> <title>Example</title> <head> <style> body { background: orange; } </style> <body> <h1>Free Resources</h1> <p>We have the following resources for the users:</p> <div id="container"> <ul> <li>Video Courses</li> <li>Notes</li> <li>Interview QA</li> <li>MCQs</li> </ul> </div> </body> </html>
Change the Default Margin in HTML
Example
Now, let us change the default margin −
<!DOCTYPE html> <html> <title>Example</title> <head> <style> body { background: orange; margin: 25px; } </style> <body> <h1>Free Resources</h1> <p>We have the following resources for the users:</p> <div id="container"> <ul> <li>Video Courses</li> <li>Notes</li> <li>Interview QA</li> <li>MCQs</li> </ul> </div> </body> </html>
You can easily compare both the above examples and spot the margin difference.
Advertisements