HTML links doubt


I dont know why the second image is not appearing here in the forum but in the codeacademy editor it appears. My question is: when i write <a href="url" , Do i need to write http://? Or can i just write Because it seems to work either way.

HTML Basics part 12

<!DOCTYPE html>
	<a href=""
	<img src="" />
	<img src="" />

Replace this line with your code.


you should use http(s).

Uhm.. your <a> opening tag is missing the > and the closing tag (</a>) seem to be missing altogether.


But in the instructions it says that when inserting a link, he first "<a" tag doesnt have the ">"closing tag. But yes i am missing the closing "</a>" tag.


that is not possible, <a> should still have a closing >:

<a href="url">click me</a>


Oh yes sorry i didnt explain my self very well. I meant it didnt have it right after the "a" like in other tags such as "p" or "h3".


what? no? if you add attributes (like href) the > should be after the attribute, paragraphs can also have attributes:

<p style="color: red">i am a paragraph</p>

see how the > is after the attribute? (in case it isn't obvious, this will make the text red)

attributes are in essences added to opening tag (like <a> or <p>) which means they come before the closing > of the opening tag


I understand now. Sorry but its my first time learning code in my life, I didnt understand what the attribute is. The attribute is what's between the tag right?


attributes are things we add to opening tag, so far you have seen 3:
and i just showed you style

so anything which is added to opening tag, is an attribute. There are obviously more, which you will learn while you progress through the course


Wait about the http part. In the examples of the instructor it shows <a href="" but if i write just it still works. So is the "https://" part actually important?


the code will work in both cases (it is a valid url), but if you right click the linked image, and select: open in new tab, only the one with http(s) will work, since then codecademy it has to open a specific webpage, where it thinks it need to open the file called from the same directory as the current page. Bit tricky maybe a bit for now, read this later again :stuck_out_tongue:

Both will work to pass the exercise, that is important for now


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.