简体   繁体   English

html5:css样式: <ul><li> 与 <p> 用于链接列

[英]html5: css styling: <ul> <li> vs <p> for column of links

There are 4 columns of links in the footer each of 25% of width. 页脚中有4列链接,每列的宽度为25%。 The css style of each column is the same (they belong to the same class). 每列的css样式相同(它们属于同一类)。 The first column looks like: 第一列如下所示:

Title of Column 1 第一栏标题

link11 链接11

link12 链接12

link13 链接13

I think it is possible to use <ul><li> tags or <p> tags to reach the goal. 我认为可以使用<ul><li>标记或<p>标记来达到目标​​。 Which way is better, using <ul>, <li> or <p> ? 使用<ul>, <li><p>哪种方法更好?

Added to the question: PSI've just checked the link http://www.w3schools.com/html5/tag_nav.asp , they use <!DOCTYPE html> (as I understand, html5), but if you check how they wrap the column of linke (my question), they just use <br/> instead of <p> or <li> (see the view source of the left column). 问题的补充: PSI刚刚检查了链接http://www.w3schools.com/html5/tag_nav.asp ,他们使用<!DOCTYPE html> (据我所知,html5),但是如果您检查它们的包装方式链接列(我的问题),他们只是使用<br/>而不是<p><li> (请参阅左列的视图源)。 Is using <br/> even better than <ul><li> or <p> ? 使用<br/>是否比<ul><li><p>更好?

If you want to do it semantically correct, you would write the html according to your content. 如果您想做到语义上正确,则可以根据内容编写html。 As you are displaying "a list of links", an "ul" is the way to go. 当您显示“链接列表”时,要使用“ ul”。

And (as a bonus) if you want to make it HTML5 compliant while you're at it, wrap the list in a "nav" tag. 而且(作为奖励),如果您想使其兼容HTML5,请将列表包装在“ nav”标签中。

<nav>
<ul>
<li><a href="#">link 1</a></li>
<li><a href="#">link 2</a></li>
<li><a href="#">link 3</a></li>
</ul>
</nav>

You should use both nav and ul tags to achieve this. 您应该同时使用nav和ul标签来实现此目的。

<nav>
    <h1>Title of Column 1</h1>
    <ul>
        <li>link11</li>
        <li>link12</li>
        <li>link13</li>
    </ul>
</nav>

我认为最好使用列表,并通过CSS使ul none成为list-style-type。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM