In this tutorial, we’ll walk through the steps of adding and styling the top profile image as displayed in the demonstration site.
Before we get started, you may want to pick a personal profile photo for including on your site. If you don’t have a profile photo, you can use any image for demonstration purposes or create an avatar through a site like Getavataaars.com. Otherwise, you can use the image from our demonstration site by downloading the image here. (For a refresher on how to add images to webpages using HTML, please visit our tutorial HTML Images from earlier in this tutorial series.)
Once you’ve selected an image, save it as
small-profile.jpg in your
Paste the following
<img> element in between the opening and closing
<div> tags you created in the last tutorial like so:
... <div style="background-image: url('ImageLocation'); background-size: cover; height:540px;"> <img src="ImageFilePath" style="height:150px;"> </div> ...
Make sure to switch out the highlighted
src address with the file path of your profile image. Note that we are also using the style attribute to specify the height of the image to 150 pixels. The
<img> element does not require a closing tag.
Save and reload the page in the browser to check your results. You should receive the following:
Next, let’s add properties to our
style attribute that will give our image a circular shape, a yellow border, and a top margin that push our image 80 pixels down from the top of the page.
Add the highlighted properties to your
<img src="ImageFilePath" style="height:150px; border-radius: 50%; border: 10px solid #FEDE00; margin-top:80px;">
Make sure you still have the correct file path of your image listed as the
src address. Save the file and reload it in the browser. You should receive something like this:
Before moving on, let’s briefly pause to study the code modifications we just made. Setting the
border-radius value to 50% gives the image a circular shape. Setting the border value to
10px solid #FEDE00 gives the image a solid border that is 10 pixels wide and has the hexadecimal color value
margin-top property sets the top margin to 80 pixels.
You should now know how to add and style a profile image to your website with HTML. We are now ready to add a title and subtitle to the webpage in the next tutorial.