I’m trying to create a menu in my site, and I want to put the "quit" to the right, while the other links are in the left, however I simply can’t make it work
I’m trying to use class for the tag, inside a div, already tried creating a second div, however it makes the link go to the next line, and i don’t want that
the html file:
<div class="meio">
<p class="paragraf">
<a href="/php_01/">menu</a>
<a class="right" href="/PHP2024_01/">quit</a>
</p>
</div>
inside the css file:
.right {
text-align:right;
}
I have no idea what I did wrong, and I’ve spent almost 2 hours trying to solve it
2
Answers
Parent elements take precedence over child elements, hence text-align doesn’t work on the a-element. You’d have to put the link in a separate paragraph and apply the text-align on the paragraph. However, you could use float:
This could mess up other parts of your code however, so use with ‘caution’.
This is where
display: flex
comes in handy. Here’s a simple way to use it for this purpose: