Semantic HTML: List of Users
Asked Answered
M

1

4

How should I mark up a list of users?

Each user has a name, picture, and job title.

user

How's this?

<h1>Venmo</h1>

<h2>Employees</h2>

<ul>
  <li>
    <article>
      <img src="http://www.gravatar.com/avatar/7e6e0e2b73358e47e0b7f83f8111f75b">
      <h3>Matt Di Pasquale</h3>
      <p>Software Engineer</p>
    </article>
  </li>
  <!-- ... -->
</ul>

Should I remove the article elements? Should I remove the ul & li elements?

Margy answered 30/8, 2015 at 23:53 Comment(3)
Have you considered using <figure> and <figcaption>? Also, using microfomats might be a valid option. microformats.org/wiki/h-cardFenestrated
No, I hadn't. I guess they could work too. hCards sound cool. Thanks! :-)Margy
Related question: https://mcmap.net/q/734088/-is-it-semantically-correct-to-nest-an-lt-article-gt-element-within-a-lt-li-gt-element/242933Margy
T
1

This isn't so much a list of users as a table of data about the users. Each user has an image, a name and a job title. That gives you rows and columns.

table {
    display: block;
}
tr {
    display: block;
    overflow: auto;
    clear: left;
    margin-bottom: 10px;
}
td {
    display: block;
    width: 200px;
}
td:first-child {
    float: left;
    width: auto;
}
td:nth-child(2) {
    margin-left: 60px;
    padding-bottom: 6px;
    border-top: solid grey 2px;
}
td:nth-child(3) {
    margin-left: 60px;
    padding-top: 6px;
    border-bottom: solid grey 2px;
}
<table>
    <tr>
        <td>
            <img src="http://b.dryicons.com/images/icon_sets/shine_icon_set/png/256x256/black_female_business_user.png" alt="" width="50" />
        </td>
        <td>Jane Smith</td>
        <td>Software Engineer</td>
    </tr>
    <tr>
        <td>
            <img src="http://b.dryicons.com/images/icon_sets/shine_icon_set/png/256x256/black_female_business_user.png" alt="" width="50" />
        </td>
        <td>Jane Smith</td>
        <td>Software Engineer</td>
    </tr>
    <tr>
        <td>
            <img src="http://b.dryicons.com/images/icon_sets/shine_icon_set/png/256x256/black_female_business_user.png" alt="" width="50" />
        </td>
        <td>Jane Smith</td>
        <td>Software Engineer</td>
    </tr>
</table>
Tog answered 31/8, 2015 at 10:32 Comment(1)
Genius! Because: (1) I'm getting the data from a table (the users table), (2) the data is 2-dimensional, and (3) I'd use a table view in an iOS app.Margy

© 2022 - 2024 — McMap. All rights reserved.