Search code examples
htmlcssalignmenthtml-liststext-align

How to put HTML elements in a line?


I've got this code...

        <div class="header">
            <div class="mainh">

                <div class="table">

                    <ul>
                        <li><a>smth</a></li>
                        <li><a>smth</a></li>
                        <li><a>smth</a></li>
                        <li><a>smth</a></li>
                        <li><a>smth</a></li>
                    </ul>
                </div>

            </div>          
        </div>

And what I want is to put the ul, li and a in a single line with the same distance between them.
How do I make it?

BTW I tried something. What I tried:

div.table ul li a {
    display: block;
}

...but it doesn't change the alignment.


Solution

  • ul li 
    {
       float: left; /* To make it in a single line */
       margin-right: 50px; /* Distance */
       margin-left: 50px; /* Distance */
    }