Note on the above post: while you can write HTML like that (the <body class="body">), don’t actually do that. It’s not good practice for 3 reasons:
-
You should try to avoid putting styles on the BODY element, unless you know what you’re doing (there are special uses for styling the BODY element), because the BODY element isn’t directly visible. In general, put styles on visible elements, not invisible elements.
-
Using a class name of “body” on the body element makes no sense. Usually you should use class names that add some sort of semantic meaning to the element that you’re putting them on. This is a better example of how to use class names in general:
<p class="blue">Some blue text.</p> -
The body element is a special-purpose case where if you do want to style it via CSS, you should apply it directly to the body element, and not to a class on the body element. For example:
/* CSS reset */
body {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* Or base page styles */
body {
background-color: #222;
color: #FFF;
font-family: Arial, Helvetica, sans-serif;
}
/* There really aren't very many other reasons to be styling the body element... */
For more info on HTML elements, classes, and IDs, this link may be helpful: https://www.w3schools.com/css/css_syntax.asp
Avoid putting classes on the body element in your HTML.
<body> <!-- don't add a class here! Use CSS to select the 'body' element instead -->
<!-- your page content here -->
</body>