As already answered by @carlosrafaelgn, there are several ways to do what you intend.
I used the same technique proposed by him, and made only a few structural changes. Originally I was going by how comment in the existing answer, but it was going to be unreadable, so I ended up posting separately. Anyway, the original answer already won my +1.
The difference is basically the use of semantic tags instead of div
s, to preserve the logical structure of the page regardless of the CSS.
In case, I used the <p>
for informative text in the second line of text, but you can use <h2>
if it is a subtitle, for example. The important thing is to use the tag that best identifies the meaning of the content there.
HTML:
<div id="cab">
<h1>Título do site</h1>
<p>Outro texto</p>
</div>
CSS:
#cab { position: relative;
margin: 0;
padding: 0;
height: 200px; }
#cab h1 { position: absolute;
top: 25px;
left: 25px; }
#cab p { position: absolute;
bottom: 25px;
right: 25px; }
As we use different tags for the two lines, it was unnecessary to specify classes, and to do so just use the descending selector.
See working on Jsfiddle.
Carlosraelgn I really appreciate your help. 5 stars. Thank you very much. I only had one question: why can’t we use div id and p class? Div id is not unique?
– David
@David can use the
id
, yes, and instead ofspan
,p
. It was just an example :)– carlosrafaelgn