9/15 HTML Where do I put the alt text attribute within the image code?


#1

Hi All-
I'm working on exercise 9/15 in the html intro section, where it is asking us to insert the alt text attribute into the photo link. Where do we insert it into the image link? at the beginning, middle, end? The sample they give is presented out of context, so it's hard to tell exactly where to put the alt text attribute in the image link. Here is the link to the exercise in question:

https://www.codecademy.com/courses/learn-html-css/lessons/common-elements/exercises/img-alt?action=lesson_resume

Thanks.


#2

There is no steadfast rule about order of attributes. An element is an object, and its attributes have no definitive order, so can be written in any way.

<img alt="" src="">

is the same as,

<img src="" alt="">

#3

There are some popular HTML style guides that can help you make these sorts of decisions.

For example, you might want to look at:

http://codeguide.co/#html-attribute-order

or

https://google.github.io/styleguide/htmlcssguide.html#Multimedia_Fallback

These are only guidelines, and as you get more experienced you will become more confident in deciding when (and when not) to follow them.

Moreover, if you are coding as part of a team, it is very likely that the team will have agreed some coding style guidelines at the beginning of the project.


#4

The best guide is your own intuition. Form good habits and the rest will follow. Consistency is what makes for a readable writing style. We have two readers... The computer and whatever API's are involved; and, the reader, a human trying to make sense of our code.


#6