Forum How do I...?

selecting empty paragraphs

ricky.how
Hi - I need to select empty paragraphs (i.e. ones with a non-breaking space).
Source sample:
<p>&nbsp;</p>

Last unsuccessful attempt
/* Set the space between blocks */
p:contains("&nbsp;") {
height:.1em !important; color:red;
}
mikeday
I would expect that selector to work, although the color property will have no effect as there is no visible text in the paragraph to begin with. (You could try setting background-color).

Note that &nbsp; will only work as an entity reference inside an XML or HTML document, not inside an external CSS file. If you are using an external style sheet, you will need to write it like this:
p:contains("\A0") { ... }
ricky.how
I tried the following and it still not working...

/* Set the space between blocks */
p:contains("\A0") { height:1px !important; }

BTW I am using Deki and the FCKeditor, which inserts the <p>&nbsp;</p> code.
mikeday
When I try the following document it seems to work:
<html>
<head>
<style>
p:contains("\A0") { border: solid red thin; height: 1px }
</style>
</head>
<body>
<p>&nbsp;</p>
</body>
</html>
Can you try adding a border to the paragraph to determine whether or not the selector is matching?