Can id attributes only be used on <div> tags?


#1

Question

In this exercise we give multiple <div> tags an id. Can any opening <html> tag have an id attribute or can only opening <div> tags have this attribute?

Answer

Any opening <html> tag can have an id attribute. While the id attribute defines an identifier which should be unique to the whole document, it is not uncommon for several different <html> tags to have unique id attributes. To find out which attributes are available to every tag, take a look at this list of global attributes.


FAQ: Learn HTML Elements - Intro to HTML - Attributes
#2

Do i need to use quote marks in an ID attribute?


#3

Do we need to? Try it and see. Should we always quote attributes? Yes.


#4

I have a question; and really appreciate your responses. As some one learns to code, are there resources/guides/books/sites that tell you how and what to do? You don’t have to memorize all these html codes, right? where do you find that information?

Also, on this website we have a little project that we type into, and it highlights our mistakes. Are there programs that do the same when you are writing HTMl? if not, is it pretty hard to go back and see your mistakes?

ALSO, 1 more question - are there search functions within html coding? some really long files could take forever to look through, right?
thanks!


#5

Yes, plenty of them. Start with the documentation on w3.org. Try a search,

html elements list site:w3.org

We will do very well to study usage, permitted attributes and validation. This will lead you to UI best practices, usability and accessibility.

Top of the list for usage guidance is MDN (Mozilla Developer Network) but you will quickly add to that bookmark many other authority sites. SitePoint offers a good lot of resources to learners. Their Premium plan is affordable and opens up their massive library of reading resources.

Syntax highlighting is available in all text editors that recognize HTML, CSS, etc. For beginners there is a very popular and well equipped Notepad++. When you reach the level where you are truly commited to developing, then it will be worthwhile looking into paid for IDE’s, but not until then.

You can test drive several online developer environments such as repl.it, codepen, &c. which can prove very useful since they have built in linting, which is the feature you asked about. Once you get on with your learning you may wish to look into a linter plug-in for your text editor.

The common search tools usually found in the Edit menu of a text editor are more than adequate. Editors will have segment toggling to hide large sections of code to tuck it out of the way. They help to track nesting, as well. Once you discover and learn to use the many tools in your free editor, you’ll be more at home and less distracted once you move up to more professional workflow environments.

Be sure to make good use of validation. validator.w3.org