I'm quite new to CSS and HTML and came across a situation where I have a class example
and a class credits
. I want some elements inside example
to have a specific design, but credits
is general and should apply to the whole document. So I wrote:
.example p {
text-align: justify;
}
.credits {
text-align: right;
}
<div class="example">
<h1>Main Title</h1>
<p class="credits">by Author</p>
<p class="intro">some info...</p>
<h2>Title</h2>
<p>Lots of text...</p>
</div>
My problem is: .credits
style is not applied to <p class="credits">
element inside the <div>
and I don't understand why. Can someone explain me the reason?