A easy way for you to do this is to use display: flex on the parent element.
I have created a little example for you:
.link-container {
display: flex;
justify-content: center;
gap: 2rem;
}
<div class="link-container">
<a href="#">Link1</a>
<a href="#">Link2</a>
<a href="#">Link3</a>
<a href="#">Link4</a>
<a href="#">Link5</a>
</div>
Learning about flexbox will be very usefull. You will probably use it very often because it allows us to arrange items in rows or columns, to center them, to space them, ...
Here is some information about it: Flexbox
Some information about my example
- i gave you container a
link-container class. This class name could be any thing you want. i prefer targeting elements in css by using classes, rather then using the div tag
- i gave the parent element ("
link-container") a display: flex`. This turns it into a flexbox element and will allow us to position the elements
- i gave the
link-container element a justify-content: center. This aligns the element inside a flexbox to the center (you could also try to use align-items: center to center the items vertically. Other useful options for the justify-content are flex-start, flex-end, space-between and space-around. More info here
- I have added a
gap to give a little space between each of the links. You can read more about gap here