HTML:如何将链接插入有序/无序列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18413660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 12:31:36  来源:igfitidea点击:

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

htmlcsslisthyperlink

提问by Carlos Lombardii

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?

大家好,我正在创建一个有趣的网站,我想知道如何在订单/无序列表中插入链接?另外(虽然它不在标题中)<li></li>标签是什么?

回答by Romain Paulus

Like this:

像这样:

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

listands 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>.

li代表“列表项”。这是您可以作为其直接子代的唯一标记<ul>...</ul>,因此您必须将链接放在<li>.

回答by pablofiumara

I created an examplefor you.

我为你创建了一个例子

Here is the code of my jsfiddle:

这是我的 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.

标签 li 指的是列表项。链接在有序列表和无序列表中的编写方式相同。