Skip to content Skip to sidebar Skip to footer

Which Is The Correct Method, Inline-block Or Float?

I am designing a layout for a site and am confused about when to use inline-block or float. Which is the best way: inline-block or float? Using inline-block means it doesn't spport

Solution 1:

Please refer to the article Should You Use Inline-Blocks As A Substitute For Floats. It will help you a lot.

Solution 2:

For a layout, you should use neither.

According to http://www.w3schools.com/cssref/pr_class_display.asp#gsc.tab=0, all inline attributes are supported by Internet Explorer 8+, so it should be OK if you're not developing a commercial website.

I recommend using <div> and HTML5 elements such as <header> and <article>. For example,

<body><header><divid="logo"><imgsrc="myLogo.png"alt="logo"/></div><nav></nav></header><divid="pageContainer"><article><section>
        ...
      </section></article></div></body>

Then for individual elements in each <div>, you can define inline or float (like a picture or a table).

<div>: basically, a section of a webpage.

List of sweet HTML5 elements!: http://www.w3schools.com/html/html5_new_elements.asp#gsc.tab=0

Example: http://jsfiddle.net/JYZhz/

Post a Comment for "Which Is The Correct Method, Inline-block Or Float?"