Campsite Coders

Learn CSS

Learn to code and become a Front End Web Developer

Campsite Coders Bootcamp Coding Advenuture

CSS Selectors : Select Element by Class ID

Selecting an element that has an ID is the easiest way to know you are selecting the exact item because every ID on a page has to be unique. You can give every element on the page a class ID if you want to but no two elements can have the same ID name. CSS IDs are identified in CSS with the pound sound (aka "hashtag") #.

When you think of assigning an ID to an element think of it being like a fingerprint padlock. Once programmed there is only ONE fingerprint that will open the lock. When you have a class ID on a page, you can only have one. You could have many different padlocks that could be assigned to different people with different fingerprints, but only the fingerprint programmed for each specific lock will open it.

unique ID

Element Name Selectors

HTML

html code with class id

CSS

css class id

RESULTS

  • Your fingerprint is the password.
  • Fingerprint ID function provides a safe way for unlocking
  • Locking device can record up to 10 fingerprints

NOTE


If you can make a habit of assigning a class ID to every element on the page (each one is unique - no 2 the same) then you will find it easy to style your elements.


Do you believe you understand how to select elements by name? If yes, hit the next button below and continue learning more about CSS.

Campsite Coders Bootcamp Coding Adventure
Road Map for Coding Adventure One

Campsite Coders

56747 Ewing Rd

Moffat, CO 81143

720-515-1124

Campsite Coders logo in footer

Copyright 2023 . All rights reserved