Can someone tell me what I coded wrong? Everything is working, the only thing is that there is no margin at the top.
HTML:
<div id="contact_us"> <!-- BEGIN CONTACT US -->
<span class="first_title">Contact</span>
<span class="second_title">Us</span>
<p class="content">For any questions whatsoever please contact us through the following e-mail address:</p></br></br>
<p class="e-mail">info@e-mail.com</p></br></br></br></br>
<p class="read_more"><a href="underconstruction.html">Read More</a></p>
</div> <!-- END CONTACT US -->
CSS:
span.first_title {
margin-top: 20px;
margin-left: 12px;
font-weight: bold;
font-size: 24px;
color: #221461;
}
span.second_title {
margin-top: 20px;
font-weight: bold;
font-size: 24px;
color: #b8b2d4;
}
Unlike
div,p1 which are Block Level elements which can take upmarginon all sides,span2 cannot as it’s an Inline element which takes up margins horizontally only.From the specification:
Demo 1 (Vertical
marginnot applied asspanis aninlineelement)Solution? Make your
spanelement,display: inline-block;ordisplay: block;.Demo 2
Would suggest you to use
display: inline-block;as it will beinlineas well asblock. Making itblockonly will result in your element to render on another line, asblocklevel elements take100%of horizontal space on the page, unless they are madeinline-blockor they arefloatedtoleftorright.1. Block Level Elements – MDN Source
2. Inline Elements – MDN Resource