At the end of this Tutorial you will be able to:
You can view finished versions of the four sample web pages you will create in this Tutorial by clicking the links below. The finished samples will each open in a new tab of your web browser.
You will also update your website home web page to include hyperlinks to your four new sample web pages.
Where to find copyright-free images
Your four sample web pages with files
Adding the web browser reset to your stylesheet files
Working with the van Gogh sample web page
Working with the Tourism sample web page
Adding a rounded corner effect
Working with the Smoothies sample web page
Working with the Software sample web page
Updating the content of your home page
Uploading your home page to GitHub
Uploading your sample files to GitHub
In this Tutorial, you will work with the two main image formats used on web pages: the jpg and the png format. Images in these formats can be created and edited with applications such as Adobe Photoshop, Gimp, Microsoft Paint or Apple Paintbrush.
This format (pronounced jay-peg) is the best choice for displaying photographs that contain lots of colours and colour gradations. It is not recommended for images containing text, line drawings or areas of solid colour.
Image files in this format end with the filename extension .jpg or .jpeg. You can see some examples of typical JPG-format images below.
This format (pronounced pea-n-g) is typically used for images that contain areas of solid colour, for logos and icons, and for line drawings.
Below are some examples of images suited to this file format. Such files end with the extension .png.
Photographic images can also be saved in PNG-format and will display in a web page with the same quality as if they were JPGs. But the image file sizes will be larger and, as a result, the web page will take longer to load.
A feature of PNG format images is that, unlike JPG files, they can have transparent backgrounds.
A wide range of so-called stock photography websites exists from which you can download, modify and use copyright- and royalty-free images, whether for your personal, not-for-profit or commercial web projects.
In most cases, you do not need to credit the image’s creator, but it is good practice and courteous to do so.
Here are some popular sources of general-purpose stock images:
Here are some online libraries that offer less generic and more stylised photography:
For online business-themed images, check out this free gallery from e-commerce giant Shopify:
The Internet’s largest collection of free online images is the one below. It includes vintage photography and reproductions of classic works of art:
For illustrations rather than photographs, here are four open-source collections of vector images. Files can be downloaded as bitmap images in PNG-format.
Before you add any images to your web pages, you will want to change the default way in which images are displayed by web browsers. You can do this by adding a new rule to the beginning your CSS stylesheet file.
/* Browser resets */ img { display: block; width: 100%; height: auto }
This new CSS rule is an example of a so-called browser reset. You will be adding more of these in later Tutorials.
You add an image to a web page using the single, simple line of HTML code such as shown below.
<img src="dog.jpg" alt="My dog Rover, playing in the park">
Or:
<img src="cat-picture.png" alt="My cat Judy, sitting on a chair">
As you can see from the examples below, the HTML <img> tag for every image has the same format.
After the <img> are the three letters of src which set the source (location) of the image file. This is known as an attribute or property of the <img> tag.
Note that the <img> tag does not need a closing tag. It is one of the few examples of self-closing tags in HTML.
If as the result of a slow connection or other reason, an image on a web page cannot be displayed, HTML offers an attribute named alt, a short form of ‘alternative text.’
In the above example, all six inserted images each include a short alternative description.
If you omit the alternative text for any image on a web page, your web page is regarded as "invalid".
Your first step is to download the files you need for this Tutorial.
You are now ready to work with the sample files you have downloaded.
As a final step, delete the following two items from your websites folder:
Before adding any images to your web pages, you need to add a web browser reset to each of your stylesheet files.
/* Browser resets */ img { display: block; width: 100%; height: auto }
You can now close the four stylesheet files in VS Code.
In this section, you will work with the sample page-5.html web page and the sample style-5.css stylesheet.
<img src="bedroom-arles-van-gogh.jpg" alt="Bedroom in Arles, van Gogh">
To give the images on your web page a drop shadow effect, add the following at the end of your style-5.css stylesheet.
This will also add a vertical bottom margin of 42 pixels under each image.
Save your CSS file and view the effect on your page-5.html web page in your browser.
In VS Code, you can now close your page-5.html and style-5.css files
Click page-5.html to view a finished sample of this web page in a new tab of your web browser.
In this section, you will work with the sample page-6.html web page and the sample style-6.css stylesheet.
<img src="guinness-storehouse.jpg" alt="Guinness Storehouse">
To give the images on your web page a rounded corner effect, add the following at the end of your style-6.css stylesheet.
This will also add a vertical bottom margin of 32 pixels under each image.
Save your CSS file and view the effect on your page-6.html web page in your browser.
In VS Code, you can now close your page-6.html and style-6.css files
Click page-6.html to view a finished sample of this web page in a new tab of your web browser.
In this section, you will work with the sample page-7.html web page and the sample style-7.css stylesheet.
<img src="watermelon.png" alt="Watermelon Wonder">
You will see that the lemons.png image does not have a transparent background. Follow these steps to make the background of the image transparent.
Save your web page and view the result in your browser.
In VS Code, you can now close your page-7.html and style-7.css files.
Click page-7.html to view a finished sample of this web page in a new tab of your web browser.
In this section, you will work with the sample page-8.html web page and the sample style-8.css stylesheet.
<img src="visual-data.png" alt="IBAT Analytics product">
In VS Code, you can now close your page-8.html and style-8.css files.
Click page-8.html to view a finished sample of this web page in a new tab of your web browser.
Now that you have created and styled four new web pages, let’s add hyperlinks to these new pages to the ‘home page’ of your web site.
<p><a href="websites/page-1.html">A Tale of Two Cities</a></p> <p><a href="websites/page-2.html">IBAT Chocolates</a></p> <p><a href="websites/page-3.html">Prince and Purple Rain</a></p> <p><a href="websites/page-4.html">Lorem Ipsum</a></p> <p><a href="websites/page-5.html">Vincent van Gogh</a></p> <p><a href="websites/page-6.html">Irish Tourism</a></p> <p><a href="websites/page-7.html">Smoothies</a></p> <p><a href="websites/page-8.html">Software Analytics</a></p>
Save your index.html web page and view the result in your browser.
Follow these steps below to upload your updated ‘Home page‘ (your index.html file) to your website on GitHub.
Your updated Home page is published on GitHub at a web address similar to the following, where username is the username you have chosen for your GitHub account:
https://username.github.io/index.html
Or simply:
https://username.github.io
It may take a few minutes for your uploaded files to appear on GitHub.
Next, you will work with all your other files – your sample web pages, sample stylesheets and images.
Because you have so many files for these eight web pages, it’s quicker and easier to upload your entire websites folder to your GitHub account. Here are the steps.
That’s it. Your sample web pages are now published on GitHub at web addresses similar to the following, where username is the username you have chosen for your GitHub account:
https://username.github.io/websites/page-1.html
https://username.github.io/websites/page-2.html
https://username.github.io/websites/page-3.html
https://username.github.io/websites/page-4.html
https://username.github.io/websites/page-5.html
https://username.github.io/websites/page-6.html
https://username.github.io/websites/page-7.html
https://username.github.io/websites/page-8.html
It may take a few minutes for your uploaded files to appear on GitHub.
Note that, when you upload a folder to GitHub:
As a last task, you need to organise or ‘tidy up’ your folder and files structure on GitHub.
Follow the steps below.
You have now finished organising your repository on GitHub.
A quick guide to website photography
By Eric Karkovack at Speckyboy
Choosing the right website images
By Dave Meier at Hidden Depth
Seven tips for choosing website images that increase conversions
By Carol Taylor at Automation Agency
Seven tips for choosing the best image for your website
By Mara Calvello at Learning Hub
Return to Contents.