How can the code be optimized to avoid the issue of displaying link1 on the left and link3 on a new line?

The issue of displaying link1 on the left and link3 on a new line can be solved by using CSS to style the links as inline-block elements. By setting the display property of the links to inline-block, they will be displayed next to each other horizontally, preventing link3 from moving to a new line.

<style>
    .link {
        display: inline-block;
    }
</style>

<?php
echo '<a href="#" class="link">link1</a>';
echo '<a href="#" class="link">link2</a>';
echo '<a href="#" class="link">link3</a>';
?>