<body topmargin="">
Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
- Attribute of
- HTML Body Tag: Master The Most Important HTML Element Now
- What does
<body topmargin="">
do? - Was used to set a margin above the body of a document. Deprecated. Use CSS.
Use CSS instead
All of the styling and display attributes of the <body>
(and all other elements) have been deprecated in HTML5. You can control the margins on the body using CSS.
body { margins: 1em; }
The CSS property for just the margin on the top of an element is margin-top
(not topmargin
).
body { margin-top: 1em; }
However, it is usually a better idea to use padding
on the <body>
, rather than margin. This is because any background
properties you set (background-color
, background-image
) will be displayed within the bounds of the padding
, but not within the margin
. Since the usual desired behavior is for the background to fill the entire viewport (browser window), padding
is usually the best choice.
body { padding: 1em; }