Links
If you need to connect one webpage to the other, you can use a link (aka a hyperlink). When someone viewing a website clicks on a link, it can open a new webpage. Anchor elements <a>
can use an href
to point to a link! Why don’t you click on THIS link!
<!doctype html>
<body>
<h1>The internet is a series of links!</h1>
<hr />
<div>
Sometimes you'll want to link to a new site, or a new page! <a href='https://bdpastl.github.io'>I am a link! Please click me</a>. By including links in your site, you can create a create a very dynamic experience!
</div>
</body>
</html>
You can also link to other portions of the webpage you are currently on using the anchor tag with an ID <a href='#anchorID'></a>
. Our webpages aren’t big enough yet for this to be suer useful, but it will be nice to know once we start writing much larger webpages:
<!doctype html>
<html>
<body>
<h1>The internet is a series of links!</h1>
<hr />
<div>
Suppose I wanted to make sure somebody could navigate right to a spot on my page! I could then write an anchor with the attribute <a id='comeToMe'> to come directly to this spot</a>.
</div>
<div>
On a completely different spot on the same page, we can create a navigation href by saying <a href='#comeToMe'>click here to go to the other spot!</a>
</div>
</body>
</html>
Images
When you want to include an image on your website, you’ll need the <img />
tag. Just like the anchor tag, the image tag will need an href
attribute that points to the image you want to display. Take note, the image tag is a self closing tag, as there is no need to render text inside of the image tag. There are multiple ways to upload an image to your site, but for now, let’s just grab a link. We need to place the link as a value for the source attribute, like below! See the code in action!
<!doctype html>
<html>
<body>
<h1>Check out this dank meme</h1>
<hr />
<div>
<img src='https://i.imgflip.com/536zfj.jpg' />
</div>
</body>
</html>
Not all images are the same size. If you need to resize your image, you can scale it yourself! Check it out:
<!doctype html>
<html>
<body>
<h1>Check out this (tiny) dank meme</h1>
<hr />
<div>
<img src='https://i.imgflip.com/536zfj.jpg' style='width:100px; height:140px' />
</div>
</body>
</html>