Full screen? Down there.
What kind of site can we build with our beginner tags?
Mobile First
<div> <!-- the PARENT -->
<p>This is the first child</p>
<p>This is the second child</p>
<p>This is the third child</p>
<p>This is the fourth child</p>
<h2>This is the fifth child</p>
</div>
<div> <!-- the PARENT -->
<p>This is the first child</p>
<p>This is the second child</p>
<div> <!-- This div is the third child -->
<p>This is the first grandchild</p>
<p>This is the second grandchild</p>
</div>
</div>
<div> <!-- the PARENT -->
<div class="main-container">
<div class="left-of-screen">
<p> this is main content</p>
</div>
<div class="right-of-screen">
<p>this is sidebar content</p>
</div>
</div>
</div>
parent <div> tag
child <p> tag
child <p> tag
child <p> tag
child <p> tag
child <h2> tag
parent <div> tag
child <p> tag
child <p> tag
child <div> tag
grandchild <p> tag
grandchild <p> tag
<div>
<p>Content</p>
<div>
<p>etc</p>
</div>
</div>
The div tag acts as a container for other elements. It is often used to house groups of elements together, this way you can write styles and target them to specific content on the page.
Creating a <div> tag
margin => Area outside the element
border => Surrounds the content, outside the padding, before margin.
padding => Area within the element
<div>
<p>This is the content</p>
</div>
p{
margin:10px;
padding: 20px;
border:solid red 1px;
}
div{
border:solid 5px blue;
}
<div>
<p>Padding shorthand</p>
</div>
div p{
border:solid #3498db 1px;
padding:15px;
}
<div>
<p>Padding each side</p>
</div>
div p{
border:solid #3498db 1px;
padding-top:5px;
padding-left:20px;
padding-bottom:50px;
padding-right:0px;
}
padding:10px;
padding-top:10px;
padding-left:10px;
padding-bottom:10px;
padding-right:10px;
How to use
<div>
<p>margin shorthand</p>
</div>
body{
border:solid blue 10px;
}
div p{
border:solid #3498db 1px;
margin:80px;
}
<div>
<p>Margin each side</p>
</div>
div p{
border:solid #3498db 1px;
margin-top:20px;
margin-left:5px;
margin-bottom:200px;
margin-right:1000px;
}
margin:10px;
margin-top:10px;
margin-left:10px;
margin-bottom:10px;
margin-right:10px;
How to use
Centering a box
The Goal
Please center the box using only padding and margin
The next slide will be the last slide :)