I’ve read somewhere that <img> element behaves like both. If correct, could someone please explain with examples?
I’ve read somewhere that <img> element behaves like both. If correct, could someone please
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
It’s true, they are both – or more precisely, they are “inline block” elements. This means that they flow inline like text, but also have a width and height like block elements.
In CSS, you can set an element to
display: inline-blockto make it replicate the behaviour of images*.Images and objects are also known as “replaced” elements, since they do not have content per se, the element is essentially replaced by binary data.
* Note that browsers technically use
display: inline(as seen in the developer tools) but they are giving special treatment to images. They still follow all traits ofinline-block.