I’m totally new to HTML and studying and making notes from Codeacademy. From what i understood is that “id” attribute have no effect and only use to identify an element. Is it Correct?
If it’s correct, Is it really helpful to use it in HTML? to me it looks like it can be extremely helpful since ‘id’ attribute can identify the element (which you might need to Edit etc.) easily from your more than 1,000 coding lines.
The attribute has no effect but it does have a variety of important roles.
- Fragment anchor … The element can be hooked with a link
- Higher importance … id has specificity
0 1 0 0
- Unique selector … Styles can be confined to one fragment
- Unique node … Script can listen for events on single element node
Like everything else in HTML, need is the driver of design. If there is no need for it, then don’t use it.
From a coding perspective, line number bookmarks are usually available in most text editors, but searching for hooks in the code is a time saver. Can’t really say I’ve ever relied on that approach but it does have some value.
Thanks for the Reply! much appreciated.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.