I have the following HTML structure:
.parent{
border: 1px solid;
width: 60%;
}
.child2{
margin: 0 auto;
}
<div class="parent">
<a href="#" class="child1">it should stay in the left side</a>
<br>
<a href="#" class="child2">this should be center</a>
</div>
I need to center a.child2
. I can do this by adding text-align: center
to div.parent
. But in that case, a.child1
will be centered too and I don't want to.
As you can see, I've also added margin: 0 auto;
to a.child2
, but it is still placed on the left side.
To sum up, how can I center a.child2
while mantaining a.child1
on the left side?