⊗mkPmLtPrm 250 of 250 menu

Practice on HTML and CSS layouts

Let's practice creating layouts, filling them with content. Let's, for example, make a layout like this:

First, let's create the basic structure of the layout:

<div class="wrapper"> <header> ... </header> <div class="container"> <aside class="left"> left </aside> <main> ... </main> <aside class="right"> right </aside> </div> <footer> site.com </footer> </div>

Now let's deal with the header. As you can see in the example, the header will contain the site name and menu. At the same time, these blocks are at the same distance from the left edge. It is logical in this case to unite them with a common parent, moving these blocks as a single whole:

<div class="wrapper"> <header> <div class="block"> <div class="sitename"></div> <nav></nav> </div> </header> </div>

Let's add the contents of the header blocks:

<div class="wrapper"> <header> <div class="block"> <div class="sitename">site.com</div> <nav> <a href="#">home</a> <a href="#" class="active">blog</a> <a href="#">photos</a> <a href="#">about us</a> <a href="#">contacts</a> </nav> </div> </header> </div>

Now let's write the header block styles. We won't set the header height - let it expand with its content:

header { border: 1px solid black; } .block { margin: 20px 0 50px 220px; } .sitename { margin-bottom: 10px; font: 20px Arial; } nav { display: flex; width: 600px; border: 1px solid black; }

Let's write code that creates three columns in a container. We won't set the height of the content - let it be formed by its contents:

.container { display: flex; } main { width: 660px; padding: 20px; border: 1px solid black; } .left { width: 200px; margin-right: 20px; padding: 20px; border: 1px solid black; } .right { width: 200px; margin-left: 20px; padding: 20px; border: 1px solid black; }

Let's now write the remaining styles of our layout and get a solution to our problem:

<div class="wrapper"> <header> <div class="block"> <div class="sitename">site.com</div> <nav> <a href="#">home</a> <a href="#" class="active">blog</a> <a href="#">photos</a> <a href="#">about us</a> <a href="#">contacts</a> </nav> </div> </header> <div class="container"> <aside class="left"> left </aside> <main> <h1>Our blog</h1> <p> ... </p> <p> ... </p> <p> ... </p> <p> ... </p> <p> ... </p> </main> <aside class="right"> right </aside> </div> <footer> site.com </footer> </div> * { box-sizing: border-box; } .wrapper { width: 1100px; margin: 30px auto; border: 1px solid black; } header { border: 1px solid black; } .container { display: flex; } main { width: 660px; padding: 20px; border: 1px solid black; } .left { width: 200px; margin-right: 20px; padding: 20px; border: 1px solid black; } .right { width: 200px; margin-left: 20px; padding: 20px; border: 1px solid black; } footer { padding: 30px 0; border: 1px solid black; text-align: center; } .block { margin: 20px 0 50px 220px; } .sitename { margin-bottom: 10px; font: 20px Arial; } nav { display: flex; width: 600px; border: 1px solid black; } nav a { padding: 10px; color: blue; text-decoration: none; font: 15px Arial; } nav a:hover, nav a.active { color: red; text-decoration: underline; } main h1 { font: 20px "Times New Roman"; } main p { margin: 10px 0; text-align: justify; font: 15px Arial; }

Practical tasks

Download the layout from the following link 1.zip. Open it in your browser and repeat the page according to this example.

Download the layout from the following link 2.zip. Open it in your browser and repeat the page according to this example.

byenru