Suppose we have the code
<!DOCTYPE html><html><body><h2>HTML Image</h2><img src="pic_trulli.jpg" alt="Trulli" width="500" height="333"></body></html>
When we are inserting images using HTML, do we need to include the dimensions, width and height. If we don't need to, does it automatically set a default size for the image.
Best Answer
The default size for images in HTML is the actual size of the files on the filesystem. If you want to set the height and width of an image, here is how I would do it (adapting your code):
<!DOCTYPE html><html><head> <style>#imageId {height: 100px;width: 100px;}</style></head><body><h2>HTML Image</h2><img src="pic_trulli.jpg" id='imageId'></body></html>
And set the size dimensions (height, width) to whatever you want