HTML: How to insert links into Ordered/Unordered Lists?

83,750

Solution 1

Like this:

<ul>
    <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 2</a></li>
</ul>

li stands for "list item". This is the only tag you can have as a direct child of <ul>...</ul>, so you have to put your links inside the <li>.

Solution 2

I created an example for you.

Here is the code of my jsfiddle:

<p id="top">This is the top of the file</p>

<ul> Favourite sports
<li><a href="http://en.wikipedia.org/wiki/Football">Football</a></li>
<li><a href="http://en.wikipedia.org/wiki/Tennis">Tennis</a></li>
<li><a href="http://en.wikipedia.org/wiki/Rugby_football">Rugby</a></li>
</ul>



<p><a href="#top">This link goes to the top</a></p>

The tag li refers to list item. Links are written the same way in ordered and unordered lists.

Share:
83,750
Carlos Lombardii
Author by

Carlos Lombardii

Updated on August 24, 2020

Comments

  • Carlos Lombardii
    Carlos Lombardii over 3 years

    Hello guys I'm creating a website for fun and I was wondering how can you insert a link inside an order/unordered list? Also (although it's not in the title) what is the <li></li> tag?