Software Development and QA Tips

Dev and QA Tips What Is CSS Selector Syntax?

What Is CSS Selector Syntax?

CSS Selector Syntax | By Vakul Gotra | December 28, 2020

What Is CSS Selector Syntax?

CSS stands for Cascading Style Sheets and it is the mixture of an element and a selector which helps in identifying particular elements on a web page like xpath, CSS selector which can be used to locate web elements that does not contain ID, class or name.

Different kind of selectors are available in css and some are mentioned below:

1. Class selector: It’s declared with a dot preceding a string of one or more characters.

HTML code

{code}

<div class="testing"></div>

{code}

css class syntax: .testing

2. id selector: It is declared using a hash or pound symbol (#) preceding a string of characters.

HTML code

{code}

<div id="testing"></div>

{code}

CSS ID syntax: #testing

3. Attribute: It can be a value, type or name etc.

{code}

<input type="submit"></input>

{code}

CSS Attributesyntax: input[type=’submit’]

Disclaimer

This publication is for informational purposes only and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.