HTML img tag
Hey there everyone!
This is Vamsi here and today, I'm gonna share something that I've learnt from the HTML class going on and that is the image tag or img tag.
So, ever wondered on how to include an image while writing html code? Here are the steps:
- we need to include img tag in the code editor.
- There are different attributes which we need to add in the img tag. Some of them are src, width, height, alt, etc.
So what are all these attributes? Let's discuss them now!
Attributes are the ones which basically provide additional information and added properties for a specific tag. In our case, let's discuss the attributes for img tag.
src : this is called a source attribute. This basically takes the location of the image that might be a link or the name of the image that have been saved with in the local computer.
alt : This is called as alternative attribute. This basically provides a text in place of the image in case for some reason, the image doesn't load in the UI. This will be helpful for the user to know that there should be a text in that place which didn't load up correctly, for some reason.
width and height : These are pretty much self explanatory. These attributes are used to put a specific height and width to an image. Though, it's a practice that we generally provide these stylings in CSS but just in case we need to add them up, these are the attributes.
Well, that's pretty much about on how to load an image in the HTML document.
Thank you for reading, stay safe!