<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=243545376313250&amp;ev=PageView&amp;noscript=1">

Corgi mode

Jane Austin Headshot

Jane Austin

CEO

Lorem ipsum dolor sit amet, ei quod consectetuer eam, has erat forensibus disputationi te. Possit discere principes et usu.

Emma Watson Headshot

Emma Watson

Sr. Sales Engineer

Lorem ipsum dolor sit amet, ei quod consectetuer eam, has erat forensibus disputationi te. Possit discere principes et usu.

Sarah Jones Headshot

Sarah Jones

Marketing Automation

Lorem ipsum dolor sit amet, ei quod consectetuer eam, has erat forensibus disputationi te. Possit discere principes et usu.

joey joe Headshot

joey joe

Content Marketer

Lorem ipsum dolor sit amet, ei quod consectetuer eam, has erat forensibus disputationi te. Possit discere principes et usu.

Tara Jepson Headshot

Tara Jepson

Staff Software Engineer

Lorem ipsum dolor sit amet, ei quod consectetuer eam, has erat forensibus disputationi te. Possit discere principes et usu.

Shannon McGrath Headshot

Shannon McGrath

Recruiter

Lorem ipsum dolor sit amet, ei quod consectetuer eam, has erat forensibus disputationi te. Possit discere principes et usu.

Your Guide to Several CSS Selector Types

Aug 19, 2017 4:30:00 PM / by Amanda Danielson

Universal selector: overrides all other selectors
  • * { }
Type selector (element selectors)
  • Uses the html name as selector
  • Ex: body

pexels-photo-270360.jpeg

Id selectors:

  • Can target an element based on an id attribute
  • #primary-content (matches html attribute with that id)
  • In html: <div id="primary-content">
  • An element can only have one ID (the div above can only have one)
  • A page can only have one element with the same ID name in a given html file
  • Once an id name is used, it cannot be used anywhere else.
  • Carry more weight than class—styles in id selector take precedence over those defined in class

Class selectora

The difference between class and id selectors is that IDs are unique to one element, but classes can be used to target more than one element.

  • Defined with .classname {}
  • Only target elements with matching class selectors
  • An element can have multiple classes assigned to it
  • You are able to apply both a class and an ID to an element

startup-photos.jpg

Descendant selector

Targets an element that’s a descendent of another element

  • Ex: targets a span tag within header
  • Useful for targeting lists

    ul li {
       color: white;
       background-color: tomato;
       }


Pseudo classes:

  • Special keywords added to selectors
  • Link history pseudo-classes style links that have or haven’t been clicked
  • a:link, hover, focus, and active are examples

Topics: stormi new tag

Amanda Danielson

Written by Amanda Danielson

New HubSpot support engineer

Subscribe to Email Updates

Recent Posts