CSS Selectors Tutorial for Beginners

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 มิ.ย. 2024
  • Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGrayWebDevRoadmap
    In this CSS selectors tutorial for beginners you will learn the types of CSS selectors and how CSS selectors are applied. You will also learn about the basics of cascade, specificity, and inheritance.
    🚩 Subscribe ➜ bit.ly/3nGHmNn
    🚀 This lesson is part of a CSS for Beginners tutorial series playlist:
    • CSS Tutorials for Begi...
    🔗 All Resources for this CSS Tutorial Series: github.com/gitdagray/css_course
    📬 Course Updates ➜ courses.davegray.codes/
    CSS Selectors Tutorial for Beginners
    (00:00) Intro
    (00:05) Welcome
    (00:25) Setup
    (01:01) Element selectors
    (02:20) Class selectors
    (03:42) ID selectors
    (04:59) Group selectors
    (06:25) Nested selectors
    (08:11) Universal selector
    (09:04) The Cascade
    (10:01) Specificity
    (11:10) Check your selectors in dev tools
    (12:53) Inheritance
    (14:11) You do not inherit from the universal selector
    (14:44) More on inheritance
    (17:11) Do not use this!
    (19:01) Specificity calculator
    ⚙ Web Dev Tools:
    Chrome Browser: www.google.com/chrome/
    Visual Studio Code (VS Code): code.visualstudio.com/
    Live Server VS Code Extension: marketplace.visualstudio.com/...
    vscode-icons VS Code Extension: marketplace.visualstudio.com/...
    Github Themes VS Code Extension: marketplace.visualstudio.com/...
    W3C CSS Validator: jigsaw.w3.org/css-validator/
    Specificity Calculator: specificity.keegan.st/
    📚 References:
    MDN CSS: developer.mozilla.org/en-US/d...
    MDN CSS Basics: developer.mozilla.org/en-US/d...
    MDN CSS Selectors: developer.mozilla.org/en-US/d...
    ✅ Follow Me:
    Github: github.com/gitdagray
    Twitter: / yesdavidgray
    LinkedIn: / davidagray
    Blog: yesdavidgray.com
    Reddit: / daveoneleven
    Was this tutorial about CSS Selectors for beginners helpful? If so, please share. Let me know your thoughts in the comments.
    #css #selectors #tutorial

ความคิดเห็น • 80

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  2 ปีที่แล้ว +11

    One of the first stops on your journey towards learning CSS is to learn the most common CSS selectors. CSS selectors allow you to select the parts of the HTML document that you want to apply CSS styles to. Just starting to learn CSS? I suggest going to the beginning of this CSS for Beginners playlist here: th-cam.com/play/PL0Zuz27SZ-6Mx9fd9elt80G1bPcySmWit.html

  • @lltechnology4330
    @lltechnology4330 2 ปีที่แล้ว +25

    Great tutorial. To help me remember the CSS specificity order, I use the mnemonic: ICE (ID, Class, Element).

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +4

      Great suggestion! 💯🚀

    • @Valdaur
      @Valdaur 2 ปีที่แล้ว +3

      This has helped me remember the order of specificity. Thank you for leaving this here.

    • @kraken993
      @kraken993 7 หลายเดือนก่อน +1

      thank you for the mnemonic, its very useful!

    • @taniadinis4103
      @taniadinis4103 6 หลายเดือนก่อน +1

      Thanks!!

  • @samirsamir7779
    @samirsamir7779 10 หลายเดือนก่อน +5

    it's very difficult to be a better teacher than Dave, we understand from the first reading, what pedagogy! Thank you for all your content , :=)

  • @saoumoyaghosh8635
    @saoumoyaghosh8635 ปีที่แล้ว +8

    I started with HTML tutorial and now got into css. Your content is elaborated, informative and keeps me glued to the video. Finding this channel is of the best thing happened to me in learning web development journey.
    Thank you

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +1

      You're very welcome! 💯

    • @ryanakers3678
      @ryanakers3678 2 หลายเดือนก่อน

      HEY YOURE THAT GUY THAT GETS ALL THE PUSSY!

  • @ahmad-murery
    @ahmad-murery 2 ปีที่แล้ว +5

    css selectors is like a game to me where I try to find the shortest way to target a specific element especially when there are more than one way to do that, and the lower the specificity score is the better so that it's easier to override it if necessary.
    Thanks Dave,

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Gamification! That's always a good approach. Thanks, Ahmad! 💯

  • @DH-jw4th
    @DH-jw4th 2 ปีที่แล้ว +4

    Dave, Not sure it was meant as humorous, but your “I want you to struggle to write good code rather than cheat” certainly got me laughing out loud!!!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Ha! That may be paraphrased but yes the struggle is worth it! 💯🚀🚀

  • @jshootsraw
    @jshootsraw 10 หลายเดือนก่อน

    Dave you’re incredible. Thank you, just started a coding boot camp and this helped tremendously !

  • @osh2023
    @osh2023 4 หลายเดือนก่อน +1

    This was a good refresher and also included a couple notes I never learned.

  • @portiseremacunix
    @portiseremacunix 2 ปีที่แล้ว +2

    thanks for the video. this channel has been the one for all for everything about web dev. great contents!

  • @VanPetersonKpoti
    @VanPetersonKpoti 8 หลายเดือนก่อน

    What a great teacher!
    We love you a lot.

  • @dakoderii4221
    @dakoderii4221 2 หลายเดือนก่อน

    I'm going back over the basic stuff I know because you keep dropping tibits of wisdom that are hard to find elsewhere. You are very aware of what questions are popping up in a student's mind and the tricky challenges that will come along the way. I start making incredible progress in things once I understand how a system works.
    Congrats on you're channel growing. I read a comment on this page from 2 years ago congratulating you on 20K something subscribers. Now it's at 292K!

  • @lessorncoley763
    @lessorncoley763 8 หลายเดือนก่อน

    Thank you so much, I was having difficulty figuring out how to add two class selectors in CSS and got the answer 2 minutes into the video.

  • @TravinskiyVladislav
    @TravinskiyVladislav ปีที่แล้ว

    Thank you, Dave

  • @mostinho7
    @mostinho7 ปีที่แล้ว +1

    Done thanks
    Can select by html tag (p, h1) or by class (and then the html element would have that class assigned) or by id (avoid doing this)
    Can select multiple html tags like h1,h2 but if u don’t have the comma then it’ll select h2 that is inside an h1
    Precedence ICE id then class then element

  • @Ariquel
    @Ariquel ปีที่แล้ว

    Finally found someone who explains well for beginners! Thanks!

  • @sebg2678
    @sebg2678 ปีที่แล้ว

    Thank you sir!

  • @sonamohialdin3376
    @sonamohialdin3376 2 ปีที่แล้ว

    Awesome CSS tutorial thank you

  • @fairytail6896
    @fairytail6896 5 หลายเดือนก่อน

    A very well explained video, Sir.

  • @videopresentation1469
    @videopresentation1469 23 วันที่ผ่านมา

    great lesson

  • @Acksakal
    @Acksakal 8 หลายเดือนก่อน +1

    Good day, Mr. Gray. This is the first video of yours that I've watched and liked it! I also have one question: "How did you manage to give different colors to your TAG, CLASS and ID selectors?" in my vscode all types of selectors are of the same orange colors and I wanna change it

  • @zrezaeimobin
    @zrezaeimobin 28 วันที่ผ่านมา

    Tnx for the great tutorial 👍👍👍👍👍👍

  • @octoberman104
    @octoberman104 2 ปีที่แล้ว +1

    27k subscribers!! Should be more thumbs up 👍👍love your videos, for me being a newbie, I find the topics explained in a way I can retain and understand them much better than most instructors, thanks Dave and peace

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Thank you so much for the kind words 🙏 I'm glad I could help you 💯

  • @a7med2o6
    @a7med2o6 ปีที่แล้ว

    I love your tutorial your way of explanation is very easy and anyone can understand it easily

  • @nourhamada1409
    @nourhamada1409 2 ปีที่แล้ว

    Great tutorial 👏🏻👏🏻👏🏻

  • @aytenchelebili2213
    @aytenchelebili2213 ปีที่แล้ว

    thank you for good expalining

  • @aragorn2753
    @aragorn2753 ปีที่แล้ว

    Great explanation as always

  • @codingSparrow143
    @codingSparrow143 ปีที่แล้ว +1

    Sir, I really like your tutorials because you don't explain things superficially i.e. this element does this and that, but also give info. About good coding practices and important rules to remember that are not explained generally.
    Really appreciate 👏👏👏 your tutorials and wish you all the best. ❤️❤️❤️

  • @user-jc5tu4el4d
    @user-jc5tu4el4d ปีที่แล้ว

    Amazing video and full explain and understand able for me

  • @TeomunMete
    @TeomunMete 5 หลายเดือนก่อน

    Thanks

  • @Grishopping
    @Grishopping ปีที่แล้ว

    Greetings DAVE, I know css but I am aware that I still have a lot to learn, that is why I am encouraged to see your videos that I know are very good. Att. Joseph Grillo
    español
    Saludos DAVE, yo conozco de css pero estoy consciente que me falta todavia mucho por aprender, por eso es que me estoy animando a ver tus video que se que son muy buenos. Att. Jose Grillo

  • @GabrielSouza-yy2rq
    @GabrielSouza-yy2rq ปีที่แล้ว

    Once again, thanks a lot for your effort Dave!!

  • @CTILET
    @CTILET 2 ปีที่แล้ว

    The best way to learn programing is to learn on its native language.
    And this channel is the best in this!

  • @khoka22
    @khoka22 ปีที่แล้ว

    Great Video. like this video and I learn from Bangladesh.

  • @8m4an
    @8m4an 2 ปีที่แล้ว

    you are awesome !

  • @user-du2bj8pv4l
    @user-du2bj8pv4l 2 ปีที่แล้ว

    just dont know how to thank you! . may g-d bless you

  • @rapixstudio
    @rapixstudio ปีที่แล้ว

    Hi Dave. Unfortunately, the Turkish subtitle option does not work in the CSS series, is it possible to activate it? I follow you and I find your content very instructive and educational. thanks

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +1

      Sorry to hear that, but I do not think I have control over the subtitle languages that TH-cam provides.

  • @lecturesfromleeds614
    @lecturesfromleeds614 10 หลายเดือนก่อน

    Monospace looks better, it reminds me of those vintage video games

  • @user-ru6fz1yy8g
    @user-ru6fz1yy8g หลายเดือนก่อน

    Why can't we do styling in html file.... itself?

  • @confidential303
    @confidential303 ปีที่แล้ว

    He Dave, a mathematical question about the specificity calculator. You showed that ID has a score of 100 and a class has 10 points.. but 2 nested classes will get 20 points.. so in theory what if I have 11 nested classes ..then you will get a score of 110 which is higher then 100. Or is the total points just made up by the developer :D.. and ID in any case will enjoy highest priority

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +2

      Good question! You can use the specificity calculator linked to in the course resources - or just here: specificity.keegan.st/ - to compare two different selectors. It will show you that an element with 11 classes on it actually gets a score of: 0 11 0 ...and this allows an ID selector to still outrank it with a score of: 1 0 0 ...so the math doesn't carry the columns as a traditional equation.

  • @mihaelacostea5783
    @mihaelacostea5783 9 หลายเดือนก่อน

    Where can we find the specificity calculator as it is not in the resources?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  9 หลายเดือนก่อน

      Follow the link in the description that says "All resources for this CSS course" and then look under "Free Web Dev Tools" on that page.

  • @fabrice9848
    @fabrice9848 ปีที่แล้ว

    Why should we avoid using the ID selector ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +2

      It works, but it is not common practice. Styles are usually applied with classes. Later in this series, I cover the BEM naming convention that uses classes. Also, modern libraries/frameworks like Bootstrap and Tailwind use classes.

  • @developerashed610
    @developerashed610 2 ปีที่แล้ว +1

    Hello and welcome😊 hi I am rashed😊

  • @5amsa
    @5amsa ปีที่แล้ว

    wow

  • @djlipua9327
    @djlipua9327 15 วันที่ผ่านมา

    How to merge css and html

    • @mkmkmkmk6294
      @mkmkmkmk6294 9 วันที่ผ่านมา

      Use below tag in your html file.

  • @yavuzselimoksuz6795
    @yavuzselimoksuz6795 10 หลายเดือนก่อน

    It twice

  • @ruslangilyazov7733
    @ruslangilyazov7733 19 ชั่วโมงที่ผ่านมา