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

How wide are the default margins?

WBOY
Release: 2023-08-26 17:29:03
forward
1544 people have browsed it

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> 
Copy after login

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>
Copy after login

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!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template