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

  • SEARCH
  • Home
  • 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 8427197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:43:30+00:00 2026-06-10T04:43:30+00:00

I have an <a> surrounding a <div> which also has some images, a <h2>

  • 0

I have an <a> surrounding a <div> which also has some images, a <h2> and a paragraph of text. The <a>‘s all are inline-block. Whenever the H2 extends on to two lines the next <a> is offset. Below is a screenshot.

See "nutrition" and "enzymes"

HTML:

<a href="#">
    <div>
        <div class="imgOverflow">
           <img src="/hello/there">
        </div>
        <h2>This is the title</h2>
        <p>This is a paragraph</p>
    </div>

</a>

CSS:

a {
    display:inline-block;
    font-size:16px;
    border:1px solid grey;
    width:260px;
    margin:5px;
    color:black;
    overflow: hidden;
}
div {
    display:block;  
    padding:5px;
    width:250px;
    height:300px;
}   
p {
    font-size:12px;
    text-align:justify;
 }
h2 {
    margin:5px 0 10px 0;
    font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
}
.imgOverflow {
    margin:-5px 0 0 -5px;
    width:260px;
    padding:0;
    overflow:hidden;
    height:130px;
    display:block;
}       

If anybody knows some sort of CSS property to avoid this that would be extremely helpful. Thank you.

  • 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-06-10T04:43:31+00:00Added an answer on June 10, 2026 at 4:43 am

    I guess that’s because your a element is vertically aligned to bottom and your some of your h2 elements are spanning across two lines while the last ones are only one line. Try this:

    a { 
    display:inline-block;
    font-size:16px;
    border:1px solid grey;
    width:260px;
    margin:5px;
    color:black;
    overflow: hidden;
    vertical-align: top; /* Notice this line */
    }
    

    A working example

    EDIT

    This edit comes after imray’s question.

    I’ve tested the code once again in Ubuntu 12.04 LTS – Chrome 33.0.1750.152 after almost 2 years this question has been replied, and found out that – now – when you remove vertical-align property the code tends to work as well. However, together with that if you remove the overflow property then you will see that display breaks.

    Now, imagine the following case:

    This is our container:
    ------------------------------------------------
    |                     Element 2:               |
    |    Element 1:       --------------------     |
    |    -------------    | Lorem ipsum dolor|     |
    |    | Lorem ips |    | sit amet         |     |
    |    -------------    --------------------     |
    ------------------------------------------------
    

    When default values are on element 1 and element 2 will be aligned to the baseline of their container and this baseline changes – obviously – according to the height of the container, which at the end gets determined by the height of their children – if otherwise not specified.

    Apparently, by the time of writing – as css implementation of browsers tend to change by time, removing vertical-align: bottom and leaving the overflow: hidden seems to make the code work – not tested in other browsers -, but then again simply aligning them to top, should resolve the problem completely because when you align to the top, the elements in the next lines will be aligned to the top of the line.

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

Sidebar

Related Questions

I have a page where I am displaying some text in a div and
<div class=bgdiv></div> <div class=fgdiv></div> <a href=# class=mainlink>LINKA</A> The bgdiv has no styles at all
I currently have problems aligning inline SVG correctly inside a bounding DIV, like in
I have a master page called MasterPage.master which has a <fieldset> with a <legend>
Lets say I have this kind of set of images: <div class=image><img src=image1.jpg alt=
I have an image that has some white on the edges, and I want
I have an HTML form which has a field with an ID of 'soln_c_links'
I would like to replace images on click but also have the replaced image
i have the following divs: <div id=hidethis> <!-- here i have some more divs,
Within a surrounding div I want to center an image. This image should have

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.