Why do we add a space before /


#1

I'd like to know why there is a space before the forward slash for the below code.
Do I have to add the space and if so why?

Thank you in advance for your help.

<img src="" alt="A field of yellow sunflowers" />


#2

its xml syntax, if you use xml, you have to use this syntax

for html you can just do:

<img src="#">

some lessons require xml syntax


#3

Thanks. And sorry for the confusion. I was referring to the space right before the forward slash. E.g. sunflower" />.

Is adding a space a best practice?


#4

that is part of the xml syntax, without the space, its not valid xml syntax


#5

So then for the following, I don't need to worry about the space since I have the link address to the image?

<img src="https://s3.amazonaws.com/codecademy-content/courses/web-101/web101-image_brownbear.jpg" alt="brown bear" />


#6

you could even leave out the forward slash if you are using html


#7

Perfect. Got it. Thanks for the quick response! :slight_smile:


#8

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