October 22, 2024
Chicago 12, Melborne City, USA
HTML

Is there a way to use css to style html elements to display full width across the page without putting text content into the elements?


I am wanting to display a page with no content that just visually displays the basic structure of a html page using semantic tags without actually putting in any text content (yet).

The effect I’m looking for is a page that looks like this:

bands of colour across the web page

Here is the html that I have written so far:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #wrapper {
            width: 500px;
            margin: 0 auto;
        }
        
        header {
            background-color: green;
            width: 100%;
        }
        
        nav {
            background-color: aqua;
            width: 100%;
        }
        
        main {
            background-color: lightblue;
            width: 100%;
        }
        
        footer {
            background-color: bisque;
            width: 100%;
        }
    </style>
</head>
<body>
    <div id="wrapper">
        <header>
        </header>
        <nav>
        </nav>
        <main>
        </main>
        <footer>
        </footer>
    </div>
</body>
</html>

My problem is that it doesn’t display anything at all, until I put some kind of text into each of the semantic tags (even if it’s a &nbsp; ).

Is there a way to style the tags, such that they will show the full box for each of the semantic elements , , and across the width of the page without having to add some text into each of them?

Thanks heaps 🙂



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video