Imagine a scenario where you have a container that is 500px wide. Inside this container, there is a label that takes up 30% of the width and an input box that occupies 70% of the width. Logically, everything should fit perfectly, right? But here's the catch - the input box has a border on the left and right sides, along with padding, which makes it 6px wider than intended.
One possible solution is to adjust the width from 70% to 68%, but this workaround feels a bit hacky. Is there a more elegant way to resolve this issue without resorting to a complete CSS reset?
Here is the snippet of CSS code causing the problem:
#my-container { width: 500px }
#first-name-label { display: inline-block; width: 30% }
#first-name { display: inline-block; width: 70% }
Below are some examples illustrating the issue: