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 4100182
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:32:00+00:00 2026-05-20T20:32:00+00:00

I have the following: <div> <div style="display:inline-block; ">div_1</div> <div style="display:inline-block; line-height:20px;">div_2</div> </div> Why does

  • 0

I have the following:

<div>
    <div style="display:inline-block; ">div_1</div>
    <div style="display:inline-block; line-height:20px;">div_2</div>
</div>

Why does having a line-height property set for the second div also effects the first div? And how to correct for this i only need the second div to be effected by line-height because I need to specify a different line-height for the first div. Thanks in advance.

document.getElementById('go').onclick = function(e) {
  document.getElementById('div_2').style.lineHeight = '30px';
};
<button id="go">Go</button>
<div>
  <div style="display:inline-block;" id="div_1">div_1</div>
  <div style="display:inline-block; line-height:24px;" id="div_2">div_2</div>
</div>
  • 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-20T20:32:01+00:00Added an answer on May 20, 2026 at 8:32 pm

    With the test case, it’s now crystal clear.

    Add vertical-align: top to the first div:

    <div style="display:inline-block; line-height:24px; vertical-align: top" id="div_1">div_1</div>
    

    Fixed version: http://jsfiddle.net/my6Su/5/

    Read this to understand the relationship between display: inline-block and vertical-align:
    http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/

    Also useful, for a visual demonstration:
    http://www.brunildo.org/test/inline-block.html

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

Sidebar

Related Questions

I have the following HTML snippet: Block 1: <div style="position: absolute; top: 105px; left:
I have the following html and css <div id=header> <div id=headerTopLeft> <div id=areaSelect style=display:
I have following HTML: <g:HTMLPanel styleName={style.container}> </g:HTMLPanel> I want to display another div in
I have the following HTML: <div class="selfClear" style="float: left; border: 1px solid black;"> ...floated
If I have the following in my html: <div style=height:300px; width:300px; background-color:#ffffff;></div> And this
I have following code <div class=img> <img src=image/1.jpg class=img_s style=display:none; /> <img src=image/2.jpg class=img_s
I have the following div and paragraphs: <div id=container> <p class=jsavoutput jsavscroll readonly=readonly style=width:225px;
I have the following: <div class=style-switcher id=colorChanger> <a style=background-color: #FFFFFF; data-style=arctic title=Arctic></a> <a style=background-color:
I have the following code: DIV><TABLE><TBODY><TR><TD> <DIV id=namesClass style=WIDTH: 700px> <UL style=MARGIN-LEFT: 0px! important;
I have the following encoding in the database: &lt;p&gt; Content &lt;span style=&quot;color: #ffffff&quot;&gt;&lt;span style=&quot;background-color:

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.