Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it valid to put table element into list element in HTML5?

Tags:

html

So that is the question, can i do thing like this:

<li><table></table></li>

I can't check on W3 as it's disabled at my workplace...

like image 705
wintercounter Avatar asked Jul 11 '13 08:07

wintercounter


People also ask

Can tables be used in HTML5?

However, HTML5 changed the rules and now tables for layout, while not recommended, are considered valid HTML. The HTML5 specification states: "Tables should not be used as layout aids." This is because tables for layout are difficult for screen readers to differentiate, as previously mentioned.

Is table tag deprecated in HTML5?

Deprecated AttributesSome attributes from HTML4 are no longer allowed in HTML5 at all and they have been removed completely. img and iframe. caption, iframe, img, input, object, legend, table, hr, div, h1, h2, h3, h4, h5, h6, p, col, colgroup, tbody, td, tfoot, th, thead and tr.

What elements can go inside an LI?

TL;DR: an <li> can contain any element that is valid in <body> . This specifies that an <li> may contain flow content, which is the collection of all block and inline elements. The HTML5 spec for an <li> is the same in that it also allows any flow content.

What element is used to add tables to a website?

The <table> tag defines an HTML table. An HTML table consists of one <table> element and one or more <tr>, <th>, and <td> elements. The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell.


1 Answers

You don't necessarily need to check with W3 for information like this. Mozilla Developer Network is a great resource full of information regarding standards and compatibility. For instance, the page for <li> elements describes them as follows (emphasis mine):

Content categories: None.
Permitted content: Flow content.

And there's even a section describing flow content:

Elements belonging to the flow content category typically contain text or embedded content. They are: <a>, <abbr>, <address>, <article>, <aside>, <audio>, <b>, <bdo>, <blockquote>, <br>, <button>, <canvas>, <cite>, <code>, <command>, <datalist>, <del>, <details>, <dfn>, <div>, <dl>, <em>, <embed>, <fieldset>, <figure>, <footer>, <form>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <header>, <hgroup>, <hr>, <i>, <iframe>, <img>, <input>, <ins>, <kbd>, <keygen>, <label>, <map>, <mark>, <math>, <menu>, <meter>, <nav>, <noscript>, <object>, <ol>, <output>, <p>, <pre>, <progress>, <q>, <ruby>, <samp>, <script>, <section>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <svg>, <table>, <textarea>, <time>, <ul>, <var>, <video>, <wbr> and Text.

So, those pages tell us that a <table> is indeed valid within a <li>. Of course, you can find this information in mirrors of the HTML spec too, I just find MDN a little quicker to navigate.

like image 197
Andy E Avatar answered Sep 28 '22 09:09

Andy E