[CSS] Target empty elements using The:empty Pseudo-class

Source: Internet
Author: User
Tags opening and closing tags

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.