Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Different span and input padding

I would like to know why the span and input have different padding even if I set it the same. It behaves the same in Firefox and Chrome. Which CSS rule affects this?

span, input {
  font-family: sans-serif;
  font-size: 11pt;
  font-weight: 400;
  line-height: 16pt;
  padding: 15px;
  border: 1px solid black;
}
<span>Some text</span>
<input type="text">

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

line-height doesn’t affect span because it is "inline" by default and input is inline-block by default. So if you set for span display: inline-block it should work

span, input {
  font-family: sans-serif;
  font-size: 11pt;
  font-weight: 400;
  line-height: 16pt;
  padding: 15px;
  border: 1px solid black;
  display: inline-block; /* << here */
}
<span>Some text</span>
<input type="text">
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading