SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Questions on floating inline elements

    Hi!

    Does floating an inline element automatically converts it to a block-level element? If yes, what does this give for an inline element: float: left; display: inline; ?

    Is it bad practice to float inline elements directly? (img, span, input, and so on).

    Thanks

  2. #2
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    Toronto
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, yes by floating any element, you are converting it into a block-level element.

    To my knowledge however, to give an element float and then display:inline is a method to solve IE's double float margin bug, which unnecessarily doubled the margin of the direction in which you have floated an element to.

    Thirdly, I wouldn't consider it a bad practice, as long as you are not abusing floats. I for example floats imgs directly very often.
    In search of the clouds...and maybe some work

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A user agent should ignore display:inline for a floated box, because it doesn't make sense. Thus it's 'safe' to use as an IE hack.

    It's not bad practice to float inline elements. Sometimes it's even necessary; e.g., if you want to float an image inside a paragraph. Paragraphs cannot contain block-level children, so you must float the IMG element – which is a replaced inline element – itself.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •