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...
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With