This is the allowed Tags (htmlTag) in Container:
protected $allowedTags = [
'aside',
'dd',
'div',
'dl',
'fieldset',
'main',
'nav',
'header',
'footer',
'ol',
'p',
'section',
'table',
'tfoot',
'ul',
];
You will see it in class Magento\Framework\View\Layout\Container
.
So, you can't wrap an element using li
tag.
And here, Magento render a container to HTML. You can rewrite it if want to wrap a li
in ul
tag.
(https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/View/Layout.php#L603)
protected function _renderContainer($name)
{
$html = '';
$children = $this->getChildNames($name);
foreach ($children as $child) {
$html .= $this->renderElement($child);
}
if ($html == '' || !$this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG)) {
return $html;
}
$htmlId = $this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_ID);
if ($htmlId) {
$htmlId = ' id="' . $htmlId . '"';
}
$htmlClass = $this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_CLASS);
if ($htmlClass) {
$htmlClass = ' class="' . $htmlClass . '"';
}
$htmlTag = $this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG);
$html = sprintf('<%1$s%2$s%3$s>%4$s</%1$s>', $htmlTag, $htmlId, $htmlClass, $html);
return $html;
}