CSS Positioning method

Source: Internet
Author: User

CSS Expressions Matching element description Xpath
* Match any element //*
Div Label Div
Div#eleid by ID div[@id = ' Eleid ')
Div.class by class Div[contains (@class, "class")]

DIV[TITLE=AB]

Div[title ^=a]

Div[title $=a]

By property

=ab

Start with a

End With a

div[@title = "AB"]

div[@title ^= "A"]

div[@title $= "A"]

div #id > *

div #id > H1

Child elements

div[@id = "id"]/*

div[@id = "id"]/h1

Div H1

locating descendant elements Div//h1
Li:hth (5) by index LI[6]
A:contains ("abc") by content A[contains (., "abc")]

Li{a:contains ("abc")}

Ul{a:contaions ("abc")}

Backtracking parent elements based on child elements

Li[a[contains (., "abc")]

Li[./a[contains (., "abc")]

Ul[.//a[contains (., "abc")]

Css=li:contains ("abc") +li

Css=ul{a:contains ("abc")}~ul

Positioning based on neighboring elements

Li[preceding-sibling::li[contains (., "abc")]

Ul[preceding-sibling::ul[.//a[contains (., "abc")] []

Div.a.b Multiple class positioning

CSS Positioning method

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.