Solution #2, set box-sizing: border-box;
Setting the input element to use box-sizing of border box will line up the elements.
Rationale: browser default styling for almost every element is content-box. The defaut box-sizing on button elements is "border-box".
Understanding the box model and "box-sizing" is critical measuring values and controlling layout.
By setting the text input's box-sizing model to "border-box", we are instructing the "width" property to ignore any padding.
When writing your CSS, it's a good idea to start with the following in your CSS. The difference between content and border box is easy to forget, and it's *very* nice to have two elements with width of 50% add up to 100% and not 100% plus border plus padding...
* {
box-sizing: border-box;
}
View the CSS changes inside the "style" tag for solution2.html to see the CSS code for this fix.