www.webdeveloper.com
Results 1 to 4 of 4

Thread: Would like to center this text vertically with respect to image

  1. #1
    Join Date
    May 2009
    Posts
    14

    Would like to center this text vertically with respect to image

    Please let me know how I can center the following text to the image that is beside it.

    HTML Code:
    <div style="float:left">
    <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Square-symbol.svg/50px-Square-symbol.svg.png"/> &nbsp;&nbsp;
    </div> 
    Text 
    <br/>
    Text
    (can be tested with http://www.w3schools.com/html/tryit....=tryhtml_intro)

  2. #2
    Join Date
    Oct 2009
    Location
    Lawrence, KS
    Posts
    52
    I'm entirely sure what you are asking, but if you want the image and text to be center left-and-right on the page, then all you need to do is remove float: left; from your div style and add margin: 0 auto; instead.

  3. #3
    Join Date
    Oct 2009
    Location
    Lawrence, KS
    Posts
    52
    Sorry, after rereading I realized what you were asking.

    Put this in your style

    div {
    line-height:8em;
    }
    img {
    vertical-align:middle;
    }

    Modify line-height until you are satisfied.

  4. #4
    Join Date
    May 2009
    Posts
    14
    Thanks for the help.
    Sorry for the late reply, I ended up using what you suggested in my solution, but forgot to reply...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles