Hello and welcome back.
This is the 4th lesson in a series of HTML for beginners tutorials.
In this tutorial, we shall discuss how to add images in your website.
At this point, your my_site.html file should have the following code in it.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h2>NASA | JPL</h2>
<h1>ON A MISSION</h1>
<h4>PODCAST</h4>
<p>A new podcast from NASA</p>
<ul>
<li>Arrival</li>
<li>We Are the World</li>
<li>Worlds of Wonder</li>
</ul>
<ol>
<li>NASA is cool</li>
<li>Coding comes second, arguably.</li>
<li>What is third place?!</li>
</ol>
<table>
<tr> <th >Name</th> <th >Title</th> </tr>
<tr> <td >John Doe</td> <td >Tutor</td> </tr>
<tr> <td >Jane Doe</td> <td >Student</td> </tr>
</table>
</body>
</html>
Let's get started.
You first need to know what an 'attribute' is.
In a programming context (environment), an attribute refers to 'a certain property of a certain object' . An attribute has a name and a value.
To clarify, consider the statement 'a black box'.
Here the object 'box' has the attribute named 'color' whose value is 'black'.
Similarly, the statement 'a tall man' speaks of an object 'man' whose attribute 'height' has the value 'tall'.
'The oval office' speaks of the object 'office' whose attribute 'shape' has the value 'oval'.
'A 10 dollar tshirt' speaks of the object 'tshirt' whose attribute 'price' has the value '10 dollar'.
Got it? .... Great!
To add an image in html, we shall use the tag '<img> .
Unlike other html tags we have learned so far, the image tag (<img>), has no closing tag.
The image tag has an attribute named source.
The value of the source attribute of an image is the image's location.
The source attribute in html is written in short form as 'src'.
Let's add an image to our site and see how this all works in practice.
Now, do the following:
You can use this video to follow up, if the text details above are confusing, but hopefully you got it.
And you can leave any question/comment in the comment section below.
That is all for today, happy coding.
This is the 4th lesson in a series of HTML for beginners tutorials.
In this tutorial, we shall discuss how to add images in your website.
At this point, your my_site.html file should have the following code in it.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h2>NASA | JPL</h2>
<h1>ON A MISSION</h1>
<h4>PODCAST</h4>
<p>A new podcast from NASA</p>
<ul>
<li>Arrival</li>
<li>We Are the World</li>
<li>Worlds of Wonder</li>
</ul>
<ol>
<li>NASA is cool</li>
<li>Coding comes second, arguably.</li>
<li>What is third place?!</li>
</ol>
<table>
<tr> <th >Name</th> <th >Title</th> </tr>
<tr> <td >John Doe</td> <td >Tutor</td> </tr>
<tr> <td >Jane Doe</td> <td >Student</td> </tr>
</table>
</body>
</html>
Let's get started.
You first need to know what an 'attribute' is.
In a programming context (environment), an attribute refers to 'a certain property of a certain object' . An attribute has a name and a value.
To clarify, consider the statement 'a black box'.
Here the object 'box' has the attribute named 'color' whose value is 'black'.
Similarly, the statement 'a tall man' speaks of an object 'man' whose attribute 'height' has the value 'tall'.
'The oval office' speaks of the object 'office' whose attribute 'shape' has the value 'oval'.
'A 10 dollar tshirt' speaks of the object 'tshirt' whose attribute 'price' has the value '10 dollar'.
Got it? .... Great!
To add an image in html, we shall use the tag '<img> .
Unlike other html tags we have learned so far, the image tag (<img>), has no closing tag.
The image tag has an attribute named source.
The value of the source attribute of an image is the image's location.
The source attribute in html is written in short form as 'src'.
Let's add an image to our site and see how this all works in practice.
- Click here to get an image. When the image opens, right click on it and click 'Save Image As...' . From the window that opens up, go to the location where you have saved your my_site.html file. Under file name, type 'apollo' then click 'Save'.
- Open my_site.html in Sublime text (or whichever text editor you decided to use), and type the following code below the closing table tag (</table>). <img src="apollo.jpg">
- Save the file and open it up in your browser. The image shall now be displayed below the second table in your site.
Now, do the following:
- Go to where you have saved the file my_site.html. Create a new folder and call it 'images'.
- Move (cut & paste) the apollo image to the images folder.
- Open my_site.html in your browser. Notice that the image is no longer displayed. This is because the image's location has been changed.
- In Sublime text, change the code <img src="apollo.jpg"> to: <img src="images/apollo.jpg">
- Save the file and open it up in your browser (or refresh your browser if it is already open). The image now appears again.
You can use this video to follow up, if the text details above are confusing, but hopefully you got it.
And you can leave any question/comment in the comment section below.
That is all for today, happy coding.
Comments
Post a Comment