Question about Chore Door step 4

A quick question. It says that I should put the id before the src attribute in the Chore Door project from Building Interactive Websites with JavaScript. What’s the reason for that?


link to project: https://www.codecademy.com/paths/web-development/tracks/build-interactive-websites/modules/web-dev-interactive-websites/projects/chore-door

Convention, though there isn’t a definite rule of which order you should put these things in.

There’s things, like this style guide from one of the creators of Bootstrap which suggests an order - but the actual HTML parser won’t care what order they’re in.

If you pick an order that makes sense, and you apply it consistently, that’s fine. If you’re working with others on an established project, you’d go with whatever the prevailing style there was.


The reason that the Codecademy material has you put CSS-related attributes, like id and style, in a specific order is because of the specificity of those rulesets.

id selectors are more specific than class selectors, which is why CC has you put id before class.