Contact Number

+91 908 908 6161

Email Address

info@darlic.com

Sign up
Login

Learn with Darlic®
  • HTML
  • CSS
  • JQuery
  • Javascript
  • PHP
  • SQL
  • Tutorials
  • Courses

Selector

Selector

Posted on October 21, 2015 by

CSS Selectors

CSS selectors are used to “find” (or select) HTML elements based on their id, class, type, attribute, and more.

Types of CSS Selectors

  1. The element Selector

  2. The element selector selects elements based on the element name.You can select all <p> elements on a page like this: (all <p> elements will be center-aligned, with a red text color)

     p {
    	text-align: center;
    	color: red;
       } 
  3. The Universal Selector

  4. Rather than selecting elements of a specific type, the universal selector quite simply matches the name of any element type.This rule renders the content of every element in our document in red.

     * {
    	color: red;
       } 
  5. The Descendant Selector

  6. Suppose you want to apply a style rule to a particular element only when it lies inside a particular element. As given in the following example, style rule will apply to <em> element only when it lies inside <ul> tag.

     ul em {
    	color: red;
       } 
  7. The ID Selector

  8. You can define style rules based on the id attribute of the elements. All the elements having that id will be formatted according to the defined rule.This rule renders the content in black for every element with id attribute set to black in our document.

     #black {
    	color: #000000;
       } 
  9. The Class Selector

  10. You can define style rules based on the class attribute of the elements. All the elements having that class will be formatted according to the defined rule.This rule renders the content in black for every element with class attribute set to black in our document.

     .black {
    	color: #000000;
       } 

Post navigation

Previous
Next

Empty Widget Area

About Darlic®

Darlic® is innovative platform to create websites, web applications, progressive web applications, mobile applications without a pain. Darlic® is registered Trademark of OXO IT SOLUTIONS PRIVATE LIMITED.

Links

  • Home
  • About
  • Features
  • Templates
  • Career
  • Blog
  • Contact

Resources

  • Documentation
  • Resources
  • Tools
  • Bits
  • Learn
  • Ask

Email Address

info@darlic.com

Contact Number

+91 908 908 6161

Social Links

Copyright Right
  • Privacy Policy
  • Terms and Condition