Nested Lists and Nested Blockquotes

I hit some issues with my previous entry where I wanted to have nested lists and nested blockquotes. However, WordPress’ automatic XHTML correction broke it every time.

So I went searching for ways to get around this. Apparently you can disable the automatic XHTML correct by going to Options > Writing > and uncheck the WordPress should correct invalidly nested XHTML automatically option.

After disabling that I was able to manually insert tags where before it wouldn’t let me. So first…

Nested Lists:

Turns out that what I was doing was incorrect and W3 Validator threw an error, even though my lists showed up correctly. I then found this site: XHTML vs HTML: A common mistake in nested lists, is to forget that the inside list must be within a li element.

Incorrect:
<ul>
  <li>level 1</li>
  <ul>
    <li>level 2</li>
    <li>level 2</li>
  </ul>
</ul>

Correct:
<ul>
  <li>level 1
  <ul>
    <li>level 2</li>
    <li>level 2</li>
  </ul></li>
</ul>

The above code would generate this:

  • level 1
    • level 2
    • level 2

Turns out the XHTML auto correction will accept the above correct model.

Nested Blockquotes:

The next thing was the nested blockquotes that kept getting “fixed”. W3 Validator wasn’t throwing any fit with the nested blockquotes. I searched to see if there’s a problem with WordPress and it turns out there is a bug. Not sure if it’ll be fix, but for now, the only way to have nested blockquotes is to disable the auto correction (instructions above).

Code:
<blockquote>level 1
<blockquote>level 2</blockquote>
level 1</blockquote>

Generated Output:

level 1

level 2

level 1

Leave a Reply