Css text and image | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Css text and image

Hi all is width and height necessary for a div element which contains an image. Because when I type the code in, it seems that there is no difference when I input in width and height for a div which contains image. It seems like padding is the one affecting the div area of an image only

11th Mar 2019, 4:49 AM
Tan Fu Yu
Tan Fu Yu - avatar
1 Answer
0
It is only necessary to make the image small, bigger or stretch to type the properties for the specific image. For example, if you have a img with the id "trees" and you want it to be 300px width, and 400px height, you only need to specify to the css with the id selector. The markups would be like this: #trees{ height: 400px; width: 300px; } If you put the markups for the div, you are telling the html not the properties of the image, but the properties of the div.
14th Aug 2022, 1:49 AM
Philipe Lacourt
Philipe Lacourt - avatar