The styling for the border and background of an HTML tag

html { margin:0; padding:0; background-color:#006600; border-style:solid;  } /*Dark Green*/
body { margin:0; padding:0; background-color:#660000; border-style:dotted; } /*Dark Brown*/

<html>
    <body>
      test
    </body> 
</html>

I'm curious about why the background color of the HTML tag extends the full window, while the border style of the tag remains confined just outside the body box border.

Answer №1

By adjusting the height and width accordingly, you should be able to resolve your issue.
Try experimenting with different values for both height and width


If you're interested in learning more about the HTML versus BODY element in CSS, check out this link: Understanding the HTML versus BODY Element in CSS

The html and body elements are separate block-level entities, forming a parent/child relationship.
The height and width of the html element is determined by the browser window.

The body element is typically position:static, meaning that any positioned children are relative to the coordinate system of the html element.

In most modern browsers, the default offset from the edge of the page is achieved through a margin on the body element, not padding on the html element.

We hope this helps clarify things for you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Web browser displaying vertical scroll bars centered on the page

I'm new to HTML and have been experimenting with this CSS file to center my form. I've managed to get it working, but the issue now is that it's causing scroll bars to appear on the web browser. How can I resolve this without them? @import ...

Choosing pseudo-elements with CSS styling rules

I have been utilizing the Brave browser to block online ads. However, certain websites have found a way to insert ads into their HTML on the server-side, bypassing my ad-blocking efforts in Brave. Currently, Brave only offers the ability to block elements ...

Troubleshooting Issue: Minified CSS in Vue.js not displaying correctly when deployed on Azure static website

I have successfully deployed a static vue.js website to Azure at The development build looks great in Chrome and Safari on OS X, and the production build works fine when served from the dist directory. However, the CSS doesn't seem to be rendering c ...

Creating a grid of CSS/JavaScript circles

Trying to achieve something like this: It sounds simple, but there are specific requirements: - the width of the parent div should adjust according to the length of the text (is this feasible with CSS?) - random positioning of all circles is proving to be ...

Rearranging divs in Bootstrap according to the visibility of other divs

My goal is to adjust the position of a div based on the visibility of other divs. When the screen size is reduced, the divs stack up and hiding/showing any div automatically makes the stacked up divs show/hide without leaving any blank space, but this beha ...

Angular 8: Form Input Field Alignment Issue

In my form, I have a total of 4 fields with two fields in each row. The problem arises when the title of one field is very long, causing that particular field to shift downwards and resulting in misalignment within the form structure. For example: Very lon ...

Does the padding attribute get passed down in CSS?

Hi there! I've been working on the following code snippet: .blah { padding: 15px; background:green; } .blah div{ background:red; } <div class='blah'> <div> foo </div> & ...

The chosen color for the link button in CSS

PHP CODE : $getOID=$_GET["id"]; for($i=$getOID-($getOID-1); $i<=5;$i++){ echo '<a class="current" href="postlogin.php?id='.$i.'">'.$i.'</a>'; } CSS STYLING FOR BUTTONS : .pagging { height:20px; ...

How to Change the Appearance of Elements in an Array Using React.js

My situation involves an array receiving data from an API, and I'm looking to customize each button's appearance by giving them different background colors. In addition, my project includes Material UI... Below is the snippet of code I have - {op ...

What is the best way to center-align a child DIV (not vertically)?

After spending an entire day searching for a solution to align my child DIV from its parent, I realized that all my research led me to the same results. This is my first attempt at creating a webpage. Check out the result here. View the code on https:// ...

Guide on how to make the parent scrollable once children are dynamically added

Do you know why the .wrap-max-height is not working properly? I am expecting it to be limited by 100vh - 108px and for .ins to be scrollable if needed. Any assistance would be greatly appreciated! $('button').on('click', function() ...

Swap out HTML lists for a PHP array structure

For my assignment, I was tasked with creating an HTML list from an array and generating a drop-down menu based on another array. The requirement is that when a particular subject is selected from the drop-down menu, only that subject along with its teacher ...

Modifying an image with jQuery

Why won't this image change? Below is the relevant HTML, CSS, and jQuery code. HTML <nav id="desktop-nav"> <div class="logo"> <a href="#"></a> </div> <div> ... </div> ... CSS nav#desktop-nav . ...

On iPhones, the links display as oversized blank containers

Recently, a client who switched from an Android phone to an iPhone reached out to me with a complaint. She mentioned that the links on her website, which I built for her, appear as large empty boxes. You can view her website here. To illustrate the issue ...

One solitary table is successfully loaded

I am facing an issue with my setup where I have two HTML tables and a PHP file that loads every 1 second through AJAX to pass information to these tables. Here is the HTML structure: <div style='float: left;'> <br><br> & ...

Is the .html page cached and accessible offline if not included in the service-worker.js file?

During the development of my PWA, I encountered an unexpected behavior with caching. I included a test .html page for testing purposes that was not supposed to be cached in the sw.js folder. Additionally, I added some external links for testing. However, w ...

Guide on transitioning from a WebGL renderer to a canvas renderer in three.js

My goal is to display a scene using either a WebGL renderer or a canvas renderer in three.js (version 69). This is the code I am using: <!DOCTYPE html> <html> <head> <script src="./libs/three.js"></script> <scri ...

Troubleshooting a malfunctioning custom controller in AngularJS

<html ng-app> <head> </head> <body data-ng-controller="Myfunc"> <ol type="i"> <li data-ng-repeat="c in cust | filter:name"> {{ c.name | lowercase}} - {{c.city | lowercase}}</li> </ol> ...

The layout in Next.js production builds appears to be distinct from the layout in the

Currently, I am working on a website where I have implemented a dark theme by adding a class to the body element. Everything is functioning perfectly in the development environment, but I am encountering issues in the production build. Here is the root l ...

Need help with styling for disabled autocomplete? Check out the attached image

I'm currently working with material-ui and react to create a basic form. Everything is functioning properly except for a small UI issue that I can't seem to figure out how to resolve. When I utilize the browser's auto-complete feature, the i ...