Lets spice things up just a little bit. No one wants a totally boring website with only text, right? So, let's learn how to display images on our page.
I hate to keep giving you exceptions, but the image tag is also a single tag. It is set up in the same fashion as before, with the code letters of "img",
which stands for, you guessed it, "image." Inside of the image tag, we need to give the "address" (location) and name of the image file.
This is where it gets a little tricky, so pay attention. We are going to have to back-track a little bit to make sure we have everything in order, so that we can call for the image properly.
Save your .html file to your desktop. (This is the document you are working on in your text-editor). After that, create a new folder on your desktop,
name it something, like "Web," and then drag your .html file into your new folder. After that, copy the image you want to have on your webpage inside the same folder.
For more help,
click here.
Inside of your image tag, type "src" (which stands for source), then type an equal sign, and then, in quotes, type the file name of the image. In my case, I will type "img_tag.png".
Most of the time, you will want to change the size of the image. To do this, simply hit space, and then type "height" followed by an
equal sign and then a number followed by "px", inside of quotes. (Take a quick look at the image below for this to make more sense).
Px stands for
pixels, so you will have to mess around with different numbers to decide what works best in your situation.
You can also replace "height" with "width" or use both properties if you desire.
Your image tag should look something like this:
Try this out for yourself. As I instructed earlier this lesson, find a picture you want to display on your page, put it in the same folder as your .html file, and then type the necessary code.
After that, load the .html in a web browser and then see if your image loads. Mess around with the heigh and width properties as well to get a better understanding of them, and don't forget to
include "px" after the number you use.