what is the best practice to align a text right next to a html div element

Total Post:135

Points:947
 1070  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. 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.

      Modified On Mar-30-2018 03:48:37 AM

Answer