Will the width and height properties work for span?
Folks, I created span and defined the 196px value to the width and height properties. So how do you think 196px is applied to the span element or no? 🤔
<div class="parent">
<span class="child">Some content</span>
</div>
.child {
width: 196px;
height: 196px;
}
No, it isn't applied, because the width and height properties of an inline element are calculated depending on the amount of content. Therefore if you inspect the element via devTools you will see the auto value for the width and height properties in the Computed tab ☝️
If that answer is surprised you can read about this and another behavior on my live cheatsheet 😊
P.S.
✉️ I make unlimited Q&A sessions about HTML/CSS via email with expect responses in 2 days.
😎 I make HTML/CSS reviews of your non-commercial projects and recommendations for improvement.
Please, use my email for communication 👉 melnik909@ya.ru
💪 Discover more free things from me