WHAT IS THE BEST PRACTICE TO ALIGN A TEXT RIGHT NEXT TO A HTML DIV ELEMENT

Chintoo Semi

Total Post:135

Points:947
Posted by  Chintoo Semi
 815  View(s)
Ratings:
Rate this:
Hi Expert,

I was creating a underscored list and in that list I wanted to add a color pallete type window and I tried to create one the following way

<ul><li><div style="width:10px; height:10px;  background-color:#0066cc; float:left;"></div>test</li></ul>

I am attaching a fiddle link to see the output.. Is there a good way to align the div to text or should I just adjust the margin of div element, but I don't think that is the best possible solution..

Thanks in advance. 

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: what is the best practice to align a text right next to a html div element

    Hi,


    Try this,

    text-align: center;
    display: inline-block;
    float: none;

    This positions the div in much the same way that images are positioned.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!