antonnb
antonnb

Reputation: 35

Adding id into li list

i have li list like this

<ol>
    <li>washing aaa</li>
    <li>washing bbb</li>
    <li>washing ccc</li>
    <li>washing ddd</li>
    <li>washing eee</li>
    <li>washing fff</li>
    <li>washing ggg</li>
</ol>

And want to Jump tag for each li (sorry i dont know what its called)

https://www.website.com/step.html#washing aaa

If i modified li list into something like this, are they still valid? or are we allowed to add id into li list

<ol>
    <li id="step1">washing aaa</li>
    <li id="step2">washing bbb</li>
    <li id="step3">washing ccc</li>
    <li id="step4">washing ddd</li>
    <li id="step5">washing eee</li>
    <li id="step6">washing fff</li>
    <li id="step7">washing ggg</li>
</ol>

https://www.website.com/step.html#step1

i don't use any css just html

Upvotes: 0

Views: 543

Answers (3)

user13146129
user13146129

Reputation:

<ol>
  <li><a href="https://www.website.com/step.html#washing aaa">washing aaa</a></li>
  <li><a href="https://www.website.com/step.html#washing bbb">washing bbb</li></a>
</ol>

You can try something just like this. Read more about a tag in w3schools

Upvotes: 1

mkayaalp
mkayaalp

Reputation: 2716

It is called a URI fragment.

In a HTML web page, the agent will look for an anchor identified with a HTML tag that includes an id= or name= attribute equal to the fragment identifier.

Yes, it can be given to <li> elements.

Upvotes: 1

St3an
St3an

Reputation: 806

Yes I assume you can add an id on every HTML element
https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#the-id-attribute doesn't explicitly say it though.
[EDIT] : I've found a more complete answer there :https://www.quora.com/Which-HTML-tags-cannot-have-an-ID-or-a-class-attribute

Upvotes: 1

Related Questions