- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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.
- Related Articles
- A picture is painted on a cardboard 8 cm long and 5 cm wide such that there is a margin of 1.5 cm along each of its sides. Find the total area of the margin.
- Rahul pins on a cardboard 25 cm long and 14 cm wide such that there is a margin of 2.5 cm along each of its side. Find the total area of the margin.
- Distinguish between contribution margin and gross margin.
- How to set the bottom margin of an element?
- What is the Default Gateway?
- How to set the CSS margin properties in one declaration?
- CSS Margin Properties
- The margin Shorthand Property in CSS
- How to set the left margin of an element with JavaScript?
- How to set the bottom margin of an element with JavaScript?
- How to set the top margin of an element with JavaScript?
- How to set the right margin of an element with JavaScript?
- How can we set the margin to a JButton in Java?
- Animate CSS margin property
- What is meant by Default Risk and Default Premium?

Advertisements