html - Is there a selector or a work around to select any element with no children -


Looking at the CSS3 specs, I can not find any way to select any element whose children do not have children.

Explain to me

  & lt; Body & gt; & Lt; H1 & gt; Home page & lt; / H1> & Lt; Div id = "main" & gt; & Lt; Div class = "post" & gt; & Lt; H2 & gt; Article 1 & lt; / H1> & Lt; P & gt; Some text & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "post" & gt; & Lt; H2 & gt; Article 2 & lt; / H1> & Lt; P & gt; Some text & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt;  

I am looking for a CSS syntax to select H1, two H2 and two P One way to select any page, all elements without children Any suggestions?

Sorry, I forgot to add a "blank" part, I'm actually using * * blank selector, but it does not work for any tag In which a nodetext as a child. So it is working for any input, image, object, but not for h2, h1, or any p

There is also a node for CSS as a text node , You can not do it with any CSS selector Before doing this with Javascript, you should select all nodes with only one child and by testing if it is only a text node.


Comments