When a field’s Label is empty, the resulting HTML element is rendered like this:
<div class="acf-label"> </div>
Due to the space in between the opening and closing tags, you cannot use the CSS3 :empty
selector to select the empty element, because technically it’s not empty. If the whitespace in the element was removed, we could use CSS such as:
.acf-field .acf-label:empty {
margin-bottom: 0;
}
Alternatively, a class could be added to the element, like <div class="acf-label empty"> </div>
. This method would be more backwards compatible in case some people are using JavaScript to find .acf-label elements containing only a space and hiding them.