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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:47:53+00:00 2026-05-25T21:47:53+00:00

I have such a html code: <div id=outer> <div id=inner></div> </div> How can I

  • 0

I have such a html code:

<div id="outer">
    <div id="inner"></div>
</div>

How can I make #inner div to have width 100% of #outer but minus 10px?

Here is my css:

#outer {
    width: 100%;
    max-width: 500px;
}
  • 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-25T21:47:54+00:00Added an answer on May 25, 2026 at 9:47 pm

    NOTE

    See ThirtyDot’s answer, as it does not impact the outer element’s width:

    How to make div width almost 100%

    The below will actually make the outer element’s width total the width plus the padding left and right values, which is not what the question is asking. Sorry for the confusion. :)


    You could add a padding left and right of 5px (assuming you want the #inner to be 10px less total, not per side):

    <div id="outer">
        <div id="inner"></div>
    </div>
    
    #outer {
      width: 500px;
      height: 500px;
      background: red;
      padding: 2px 5px;
    }
    #inner {
      width: 100%;
      height: 500px;
      background: blue;
    }
    

    http://jsfiddle.net/ZtaCM/

    EDIT

    Taking into account the max-width property, see this demo:

    <div id="test">
        <div id="outer">
            <div id="inner"></div>
        </div>
    </div>
    <p>
        <input type="button" onclick="changeWidth('400px')" value="Change to 400px"/>
        <input type="button" onclick="changeWidth('500px')" value="Change to 500px"/>
        <input type="button" onclick="changeWidth('600px')" value="Change to 600px"/>
    </p>
    
    #outer {
      width: 100%;
      max-width: 500px;
      background: red;
      padding: 2px 5px;
    }
    #inner {
      width: 100%;
      height: 200px;
      background: blue;
    }
    #test {
      background: yellow;
      width: 600px;
    }
    
    function changeWidth(width) {
        document.getElementById('test').style.width = width;
    }
    

    http://jsfiddle.net/ZtaCM/1/

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

Sidebar

Related Questions

assume I have a such html order <div id=header>>Header(logo, navigation menus etc)will be here,
I have such html and css. <div class=selected> <div class=text>First</div> <div class=arrow>&nbsp;</div> </div> .selected
I have such a basic problem in Delphi,I can't solve it. My Code: Note:DataR
I'm trying to have a variable store the HTML in a div tag, but
I have the following code, but it doesn't put the scrolling div anywhere. All
I have the following HTML code: <div class=member> <input type=checkbox value=64 style=display:none; name=memberId[] />
So I here have such code I use to update CSS if browser supports
I have this code: HTML <div class=box_meteo> <div class=box_meteo_pulsanti> <a href=javascript:void(0); class=box_meteo_pulsante id=meteoButton1>Link</a> </div>
I have an html input field, such as <form method=post action=process.php enctype=multipart/form-data> <div> <h3>Files:</h3>
I have the following HTML code: <table id=userPlaylistTable cellspacing=0 cellpadding=0> <div class=numCellWrapper> <div class=listArrow

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.