Home > DeveloperSection > Forums > what is the best practice to align a text right next to a html div element
Chintoo Semi

Total Post:135

Points:947
Posted on    June-15-2013 1:24 AM

 CSS-CSS3 CSS-CSS3 
Ratings:


 1 Reply(s)
 566  View(s)
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. 



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-15-2013 3:56 AM

Hi,

Try this,

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

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

Don't want to miss updates? Please click the below button!

Follow MindStick