简体   繁体   中英

When should you use <article> as opposed to <ul>?

What determines whether one should prefer to use <ul> over <article> , or vice versa in a HTML document?

As an example I have a portfolio page with a list of items, which would be more appropriate?

Element names form part of the semantic web/HTML, so you should use the one you deem most appropriate for your content, MDN is often a good resource to get an overview on what appropriate content may be, some suggestions from which are below.

Lists tend to include shorter, more concise often text only or very image-light content. It sounds like you likely want to look at the section or article tags.

Section

The HTML Section Element ( <section> ) represents a generic section of a document, ie, a thematic grouping of content, typically with a heading.

Article

The HTML <article> Element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable, eg, in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.

List (ul)

The HTML unordered list element ( <ul> ) represents an unordered list of items, namely a collection of items that do not have a numerical ordering, and their order in the list is meaningless. Typically, unordered-list items are displayed with a bullet, which can be of several forms, like a dot, a circle or a squared.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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