Search code examples
htmlcsstextalignment

Align text in one line?


I'm having issues trying to get this text displayed on one line, rather then 3 lines.

<h2 style="text-align:left">Policy</h2> 
<h2 style="text-align:center">Cart</h2> 
<h2 style="text-align:right">FAQ</h2> 

The text comes out in separate lines, so that Police is on one line, Cart is on a second line and FAQ is on another line, however they still remain aligned left, center and right.

How would I go about displaying them on the same line but still aligned?


Solution

  • //Use list
    
      <ul class="footer">
         <li>Policy</li>
         <li>Cart</li>
         <li>FAQ</li>
        </ul>
    
    //In the css
    
        .footer{
          width:100%
          float:left;
        }
        .footer li{
          display:inline;
          margin-right:20px;
        }