Front-end learning--CSS--Brother element Selector

Source: Internet
Author: User

Set the CSS style for the element behind an element:

Syntax: Previous + next.

Function: You can select an element next to the specified sibling element immediately after it.

Sets the CSS style for all the same elements that are behind an element:

Syntax: previous ~ all behind.

<!DOCTYPE HTML><HTML>    <Head>        <MetaCharSet= "UTF-8">        <title></title>        <styletype= "Text/css">H1 + P{Background-color:Orange;            }span ~ P{Background-color:Green;Color: White;Font:"Courier New";            }                    </style>    </Head>    <Body>        <H1>I am a h1 tag</H1>        <P>I am a P tag</P>        <P>I am a P tag</P>        <P>I am a P tag</P>        <P>I am a P tag</P>        <P>I am a P tag</P>        <P>I am a P tag</P>        <span>I am a span</span>        <P>I am a P tag</P>        <P>I am a P tag</P>        <P>I am a P tag</P>        <ahref= "Http://www.baidu.com">Baidu</a>        <P>I am a P tag</P>    </Body></HTML>

Effect:

Front-end learning--CSS--Brother element Selector

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.