In html, is there a tag that I can add an id attribute to, that does not have any effect on the html page, but can still be accessed with a jQuery selector?
Here is an example:
<li><a href="#"><i class='fa fa-link'></i> <span>Another Link</span></a></li>
If I have the above code in a list, what tag can I add to this html, so that I can then use jQuery to perform actions on the code items as children?
The above code is just an example, I am wanting to be able to use this technique for any html element.
EDIT
Is the <span>
tag what I am looking for?
EDIT2
I have tried the following with a span tag:
<span id="qwerty123"><li><a href="#"><i class='fa fa-link'></i> <span>Another Link</span></a></li></span>
However, the list items are not being displayed correctly. I am using an AdminLTE template and this template uses custom styling for these list items.
How else can I achieve the desired result? Can I add data attributes or some other html coding technique?
EDIT3
The html tag with the id needs to be before any of the other tags, so that all the rest of the tags can be treated as children.
What is the html tag that doesn't really do nothing? The <span> and <div> tags signify no specific meaning and are intended only for markup.
Answer. Empty elements (also called self-closing or void elements) are not container tags — that means, you can not write <hr>some content</hr> or <br>some content</br> . A typical example of an empty element, is the <br> element, which represents a line break.
There are many other tags with their own classes that may have specific properties and methods, while some elements, such as <span> , <section> , <article> do not have any specific properties, so they are instances of HTMLElement class.
HTML elements with no content are called empty elements.
The span
tag is indeed what you are looking for: it's the only HTML inline container tag. Unless you apply CSS to it, it's simply an inline tag that doesn't alter the way your document is displayed.
Read this for more details: http://www.w3.org/TR/2014/REC-html5-20141028/text-level-semantics.html#the-span-element
Please also note that you could use a div
tag and apply CSS display:inline;
to achieve the same result.
Hope this helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With