In the context of this exercise, what other things can HTML links be set to?
Answer
Links in HTML can be set to several different things.
As covered in the exercise, links are mainly used to connect a webpage with other webpages. This can be done by setting the link to go to the URL of a specified site, like
<a href="www.codecademy.com">Codecademy</a>
Links can also be set to link to documents and files, such as text, audio, video and image files. For example,
<a href="www.example.com/image.svg">Image</a>
HTML links can also be set to a specific part of the same webpage, such as a section header. This can be done using the id attribute of an element, and using that id value preceded by a # as the value of the href attribute. For example, in the following code, clicking the “Main” text would make the browser jump to the section with the corresponding id value of "main".
In the second HTML link where it gives you an example of what it would look like, why does the example:
Image
^
Shouldn’t “Image” have its own tag ? Wouldn’t it potentially mess up the formatting on the website since it does not have it’s own tag designator ? At least according to the text in the exercise, it makes it seem like that would be the case.
You can add images by using theimgelement, and point to a specific image’s location using the src attribute. That location can be (a) an URL (online) or (b) a file on your computer (then instead of the URL, we will need to specify the path of the file).
(a) <img src="https://content.codecademy.com/programs/code-foundations-path/web-dev-survey/pets.jpg" alt="a cat playing with a dog">
(b) <img src="images/mypets.jpg" alt="a cat playing with a dog">
(There are other (optional) attributes available for the img tag (such as width , length … but the alt attribute is necessary because if the user cannot see the image, they can at least see the text stored in the alt attribute.)
You can turn your image (imgelement) into a link (clickable element) by wrapping or nesting it within a a element: <a href="www.codecademy.com"><img src="images/mypets.jpg" alt="a cat playing with a dog"></a>
You can turn any part of your text into a link. In the example, they turned the word “Image” into a link (not the imgelement). It could have also been: <a href="www.example.com/image.svg">Click here to see my image</a>
I love how thorough and indepth these highlighted FAQs are. I’ve always just skimmed through the HTML portion thinking it’s quite trivial. But that last bit, about how we can use href with a pound sign(#) to jump from section to section is a great to know tidbit.
What you say is really inspiring. I’m 32 and i’m starting to learn the career path for being a Full Stack Developer, and some of my doubts were about my age and also my language as i’m not a natively english speaker.
hey folks, thanks to be feeding the forum with so many good information. Im 39 years old, brazilian (not a english native speaker) but I hope with your help by here I can finally have a new profession and help my family for a better life.