Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 867043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:54:37+00:00 2026-05-15T09:54:37+00:00

In order to follow correct web standards, I’ve tried to layout image and div

  • 0

In order to follow correct web standards, I’ve tried to layout image and div inline. In orde to achieve that – I’ve used display:inline property.
But then I experienced the following issue: image renders from the center line, and div doesn’t respect height parameter set to it. I’ve tried using line-height parameter, but that didn’t give any useful results.
I’ve also tried various combinations with setting margin/padding to some values or to auto, or replacing div with span, or wrapping img and div with additional divs.
I’ve managed to achieve desired result by using position:absolute, but that doesn’t help in cases where I want to use centered/relative positioning of the whole component…

Any clues or ideas or troubleshooting hints?

Please find the html example below:

<html>
<head>
    <title>Test Page</title>
</head>
<body>      
    <div style="border: solid 2px green; height:40px;width: 600px;">
        <span style="border:solid 2px green; position: absolute; height:50px; width: 50px;">
            <i m g 
          style="display:inline; margin: 3px; padding:0px; border: solid 2px lightblue;"
            height="38px"
            width="38px" 
            src="someimage . JPG"
        />
        </span>
        <span style="position:absolute; left: 100px; width:400px; height:60px; margin:3px; border: solid 2px red;">
            Some text that should be displayed in the center/middle of the div
        </span>
    </div>
    <br />
    <br />
    <br />
    <br />
    <div style="border: solid 2px green; height:80px;width: 600px;">
        <span style="border:solid 2px green; position: absolute; height:50px; width: 50px; vertical-align:bottom;">
            123
        </span>
        &nbsp;
        <span style="position:absolute; left: 100px; width:400px; height:60px; margin:3px; border: solid 2px red;">
            Some text that should be displayed in the center/middle of the div
        </span>
    </div>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:54:37+00:00Added an answer on May 15, 2026 at 9:54 am

    Thanks for trying to help out.

    First – the solution:
    I’ve added few attributes to image tag and that helped a lot:
    hspace=”0″ vspace=”0″ align=”top” border=”0″

    Second: explanation:
    Since I wanted to do “inline” (or “inline-block”) thing, I had to figure out how inline/inline-block elements are laid-out by browsers. If you read CSS2 layout spec, you will soon find out that there is an issue with image and divs. Problem is with vertical-align – where image is aligned/rendered comparing to baseline, while divs go for bottom-line (or vice versa). That caused my example not be aligned.
    Setting above mentioned params for the image tag helped.

    Remarks:
    Due to the complex history of IE5,6,7, Firefox, Gecko, WebKit, Chrome, CSS2 and BoxModel, there are some shortcomings to Layout model. Original problem comes from IE5 and 6 handling BoxModel in different way from CSS standard. That’s maybe the main reason for having quirks mode and DTD standards.
    However, this is a broad topic, if you want to find out more, I recoomend readin CSS2 spec and recommendation.
    If you want to discuss it more – feel free to contact me via PM

    Thanks again to all for helping and good luck with your Layouts

    Kind regards
    MP

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you please tell me the steps I need to follow in order to
How would one follow the proper steps in order to license a package under
The scenario is as follows. My Order model has an after_create that contacts a
I have a visual studio 2010 web project that when I publish it in
I'm trying to load an image file into a buffer in order to send
Hi Order By not working on MySql the code is as follows, select *
I'm doing a HQL query as follows, and try to order the list by
order by in query is taking to much time in MySQL. SHOW PROFILES shows
Order by descending is not working on LINQ to Entity In the following Query
Order props: Object selectedItems: Array[1] 0: SelectedItem length: 1 __proto__: Array[0] __proto__: Order I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.