Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which HTML elements can't contain child nodes?

I've been looking for an exhaustive list, but can't find one anywhere. To avoid having to trawl through the specs, does anyone know what they are (and I suppose a complementary list of elements that can contain children would be useful too).

And how much does this list vary between XHTML 1 and HTML5?

like image 531
wheresrhys Avatar asked Feb 04 '11 13:02

wheresrhys


People also ask

Can elements have child nodes?

Definition and UsageThe childNodes property returns a collection (list) of an elements's child nodes. The childNodes property returns a NodeList object. The childNodes property is read-only. childNodes[0] is the same as firstChild .

Which of the following tags do not have any child element?

Explanation: An empty element is an element of HTML that do not have any child nodes.

Can NodeList have child nodes?

Child nodes include elements, text and comments. Note: The NodeList being live means that its content is changed each time new children are added or removed. The items in the collection of nodes are objects, not strings. To get data from node objects, use their properties.


1 Answers

You can find a list of void elements (elements that cannot have any child content) in the HTML spec.

With the exception of the new elements introduced in HTML5, the list of void elements in XHTML is the same.

like image 189
一二三 Avatar answered Oct 21 '22 10:10

一二三