In this step we’ll learn about a special kind of HTML element. The <img>
element.
Here are a few resources for you:
src
and alt
attributes doYou guessed it! You’re now going to add a picture to your web page!
Create a directory named “images” on your device. It should be in the same location as your index.html
file.
your-project-directory/
images/
index.html
Add at least one picture to your images directory. You can choose a picture from the Internet, or you can use a photo you already have. Whatever you want.
Now update your index.html
so that the picture shows up. Make use of an img
tag.
IMPORTANT Make sure you fill in the src
and alt
attributes on your img
tag.
Your img tag should look something like this:
<img src="images/YOUR_FILE_NAME" alt="YOUR ALT TEXT HERE" />
Make sure that the picture shows up when you look at your website on your own device.
Make use of an online HTML validator to make sure your HTML is not broken in any way.
Here is a validator: https://www.freeformatter.com/html-validator.html
Once you are satisfied that your picture is showing up and your HTML is valid, you’ll need to upload your latest work to Github. You can upload your index.html
file and your images
directory in the usual way.
When you look at your Github repo then you should see your new index.html
file as well as the images
directory.
Do not make a new repo for this. Just upload your files to the same place.
Your website changes will be automatically deployed to Github pages once you have uploaded your files. You wont need to reconfigure anything. Just go to your website and make sure it looks like what you were expecting.
IMPORTANT A lot of people fail this part of the project simply because they didn’t check their own work. This is critical. Open up your github page website and look at it with your own eyes. Is your image showing up?
You’ll submit the link to your github page. You’ll need to wait a little while for feedback again.
If you got this right then you would have had to level up a little bit. You now know a bit about how to reference other resources from inside an HTML page. This is a pretty big deal because the web wouldn’t be a web if it wasn’t interconnected.