You can target an element to have no child elements by using the :empty
pseudo-class. With browser support down to IE9, it's solid, easy-to-select empty elements without any additional markup.
Be aware this whitespace is considered a ' child ', so would not work :empty
if the element have no children, but have space bet Ween the opening and closing tags.
<!DOCTYPE HTML><HTML><Head> <Linkhref= "Https://fonts.googleapis.com/css?family=Work+Sans"rel= "stylesheet"> <Linkrel= "stylesheet"href= "Style.css"></Head><Body> <Divclass= "Alert"> <P>success! Your profile has been updated.</P> </Div> <!--This empty alert box won ' t is show - <Divclass= "Alert"></Div></Body></HTML>
{ border: 3px solid Darkgreen; margin: 1em; padding: 1em; background-color: seagreen; color: White; Border-radius: 4px;} . Alert:empty{ display:none;}
[CSS] Target empty elements using The:empty Pseudo-class