Home  >  Article  >  Web Front-end  >  How wide are the default margins?

How wide are the default margins?

WBOY
WBOYforward
2023-08-26 17:29:031487browse

How wide are the default margins?

The default

margin in HTML is 8px. It is defined in pixels by the user agent stylesheet provided by the browser. Some browsers allow you to create and use your own user-agent stylesheet, but if you are developing a website, leave it as is.

Default margins in HTML

Example

Let's look at 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 default margins in HTML

Example

Now, let’s change the default margins -

<!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 the two examples above and spot the margin differences.

The above is the detailed content of How wide are the default margins?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete