How to solve this (seemingly simple) formatting problem in CSS?

Tags: html,css,css-float

Problem :

Using CSS, what is the cleanest, easiest way to format a box that has an icon on the left and text on the right:

  [Icon]   Text text text
  [____]   and more text
           and some more text

So far, I’ve used <div class=icon”> and div.icon { float: left; } to place the icon left of the text, but “and some more text” flows left (underneath the icon) instead of staying in a nice, solid column.

P.S.: I don’t want to use tables.

Solution :

why don't you use the icon as a background image?


<div class="withIcon">text text text text text text</div>


.withIcon {
 background-image: url(youricon.png);
 background-position: top left;
 padding-left: 20px; /* width of your icon */

    CSS Howto..

    How to specify different Css for different Mobiles (BB, Iphone, Nexus… )

    How can I prevent a flex container from overflowing/underflowing?

    CSS how do you stretch to fit and maintain the aspect ratio?

    How to keep pure-HTML-&-CSS collapsible panels open when another one is opened?

    How to show a message box on center of screen?

    How to prevent rightmost inline element from wrapping or overflowing in CSS?

    How can I prevent my button from being mangled?

    CSS how to target 2 attributes?

    How to add an image to a transparent box using css

    How can I split this image into pieces so when I write a long text, it doesn't go outside of the div?

    How to get the value of css property with jQuery

    How do I inspect CSS pseudo classes with firebug?

    How to only have margin between child and not with parent in CSS?

    how to disable drupal7 system css files?

    CSS show div background image on top of other contained elements [duplicate]

    How to Center a image with HTML CSS

    How to align div blocks to be aligned in grid?

    How to access my .png from a folder using CSS?

    How to select ids which contain special characters?

    How to use css media query to switch animations

    How to add more items to the list without going to the next row? [closed]

    How to only show certain parts with CSS for Print?

    How to attach a CSS stylesheet to FXML?

    Responsive CSS layout - how to stretch the background overlay

    how to load external div into a master.html div from a number of submenu items

    CSS: how to style to make text not wrap?

    How to make table by CSS?

    how to make textarea looks like input[text] on form invalid

    How can I vertically align a font-awesome input checkbox with its label?

    Firebug shows 404 error for claro_rtl.css, but I can't find the source that is trying to reference that file