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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:10:18+00:00 2026-06-06T15:10:18+00:00

When using box-sizing: border-box in CSS, I assume that the total width of an

  • 0

When using box-sizing: border-box in CSS, I assume that the total width of an element will be defined in its "width" value. So if I say that the width of a division is 20px and the right border is 10px, I will end up with a box that takes up the space of 20px and half of it is the right border. Pushing it to the point where I set the width to 10px and the right border, too, like here:

#box {
  overflow: hidden;
  width: 10px;
  box-sizing: border-box;
  height: 50px;
  background: black;
  border-right: 10px solid red;
}
<div id="box"></div>

The box will only consist of the red border. What should happen, when I set the width to 0px? I thought it would make the whole thing disappear, but no, the result is exactly the same like the one above:

#box-1 {
  overflow: hidden;
  width: 10px;
  box-sizing: border-box;
  height: 50px;
  margin-bottom: 10px;
  background: black;
  border-right: 10px solid red;
}

#box-2 {
  overflow: hidden;
  width: 0px;
  box-sizing: border-box;
  height: 50px;
  background: black;
  border-right: 10px solid red;
}
<div id="box-1"></div>
<div id="box-2"></div>

View on jsFiddle

My question is if this is the expected behavior. Seems inconsistent to me. I would like to make a box disappear only manipulating the width/height.

  • 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-06T15:10:20+00:00Added an answer on June 6, 2026 at 3:10 pm

    The content area is anything left after you subtract the width of the border.

    The content width and height are calculated by subtracting the border
    and padding widths of the respective sides from the specified ‘width’
    and ‘height’ properties.

    Specified width = 10 px
    border width = 10 px
    Content width = Specified width (10 px) – border width (10 px)
    Content width 10 – 10 = 0

    Specified width = 0 px
    border width = 10 px
    Content width = Specified width (0 px) – border width (10 px)
    Content width 0 – 10 = -10 ( which would remove the 10 px used by the border)

    But

    As the content width and height cannot be negative ([CSS21], section
    10.2), this computation is floored at 0.

    Specified width = 0 px
    border width = 10 px
    Content width = Specified width (0 px) – border width (10 px)
    Content width 0 – 10 = 0 ( which doesn’t remove the 10 px used by the border)

    If you don’t want to use display:none; or visibility:hidden;, you need to set both the width:XX; and the border-right:XX; to zero.

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

Sidebar

Related Questions

I'm creating multiple borders to element using box-shadow, but they don't show at Webkit.
previously i was using picture box and its built in utilities to draw some
I have a JQuery suggest box using a key and a value. The key
I am using javascript to add a red glow using CSS box-shadow to form
I have a fixed div setup using this: .box { position: fixed; width: 600px;
I am using display:box for a flexible width div with three boxes of equal
I am using a box element to add a transparent overlay to a column
I have a partial that renders a select box using the following method: <%=
I have a textarea with the following style applied: textarea { -webkit-box-sizing:border-box; -moz-box-sizing:border-box; }
I'm writing a small function to generate values from the Normal distribution using Box-Muller

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.