CSS Tutorial For Beginners 12 - Selector Specificity

Поделиться
HTML-код
  • Опубликовано: 17 окт 2024
  • Hey guys, in this CSS tutorial for beginners, we're going to take a look at selector specificity (I hate pronouncing that word, even though I'm a ninja!). Essentially, this translates as how specific and how much weight your CSS selector has when it comes to dealing with conflicts. It's a really important subject that I suggest you guys master. Keep coding :).
    SUBSCRIBE TO CHANNEL - / @netninja
    ========== CSS for Beginners Playlist ==========
    • CSS Tutorials For Begi...
    ========== HTML Basics Course ==========
    • HTML Tutorials For Beg...
    ========== The Net Ninja ============
    For more front-end development tutorials & to black-belt your coding skills, head over to - / @netninja or thenetninja.co.uk
    ========== Social Links ==========
    Twitter - @TheNetNinja - / thenetninjauk

Комментарии • 78

  • @Gruximillian
    @Gruximillian 8 лет назад +46

    I never knew of this points system, never read about it anywhere...
    This is veeery helpful! Thank you for this video!

  • @SamA-xy9zx
    @SamA-xy9zx 4 года назад +13

    You're a true ninja when it comes to teaching.

  • @cmoney1928
    @cmoney1928 4 года назад +2

    Nobody has ever explained specificity this well. Thank you

  • @seanadamson7640
    @seanadamson7640 7 лет назад +26

    What a great way of explaining spec...spec...specifififty :D
    You're a fantastic teacher, I've learnt more from you than my lecturers. Thank so much for your hard work, dedication and enthusiasm.

  • @Nahid_97
    @Nahid_97 8 лет назад +23

    I love this tutorial - the point system rocks!!

  • @thedevcristian
    @thedevcristian 7 лет назад +8

    Your videos are big help to us. I'm now making my website, and i'm going to spread your tutorials and your channel (of course). Continue making, your tutorials are on-point.

    • @NetNinja
      @NetNinja  7 лет назад +1

      Thanks so much! Really glad you like them :D

    • @thedevcristian
      @thedevcristian 7 лет назад +1

      Big blessing to us. Thank you guys!

  • @souravkumar6269
    @souravkumar6269 4 года назад +7

    your voice: 6:20 min "whatttt!!!! hhhhhmm mmmmmmmm", was really amazing...hahahaha

    • @d3vboii
      @d3vboii 4 месяца назад

      No Cap

  • @lemonandgaming6013
    @lemonandgaming6013 6 лет назад +1

    most important vid about css i watched from you so far
    and seriously, hasnt anybody noticed that all these css rules are just like learning how to style ancient greek words ?
    they both have complicated and kinda conflicting rules

  • @arlandwi2008
    @arlandwi2008 7 лет назад +4

    This is the important part in learning CSS, thank you

  • @niddaaa1233
    @niddaaa1233 7 лет назад +1

    you cover things that some lecturers don't even mention! I'm so thankful that I found you!!!!

    • @keyos27
      @keyos27 6 лет назад +1

      Exactly! Did not learn point system in my school.

  • @magica2z
    @magica2z 6 лет назад +1

    I'm not gonna watch any CSS videos after watching this series... this has everything..

  • @knowthyinfinity7255
    @knowthyinfinity7255 5 лет назад +4

    I have finally found a meaningful explanation. Thank you very much!

  • @michalmacko631
    @michalmacko631 7 лет назад +2

    Thanks for the videos, they cut and make a mark that's easy to remember and understand!

  • @francisjacquart9618
    @francisjacquart9618 2 года назад

    BRILLIANT EXPLANATION AND EXAMPLES AS USUAL. I UNDERSTAND IT ALL! THOSE ARE NOT THAT EASY TO UNDERSTAND, BUT YOU HAVE MADE IT QUITE CLEAR! THANKS AGAIN!

  • @CoolW-x1y
    @CoolW-x1y 5 лет назад +2

    Thanks! The points system help me unstand it.

  • @Unwired9374
    @Unwired9374 7 лет назад +1

    Great video! Just what I was looking for. Very helpful.

  • @oluwapelumiadekunmi210
    @oluwapelumiadekunmi210 Год назад

    when you said the word (specific), a light bulb came on in my head; thus: the more specific you are about your description of a tag in css, the more its ability to override other tags in selecting which style option to be used

  • @patrickfreitas254
    @patrickfreitas254 7 лет назад +1

    thanks mate, best course ever, I am learning lots new skills

  • @kenshinnanashi9469
    @kenshinnanashi9469 5 лет назад

    The tutorials are very useful. It's great the content is not just one huge 3 hour video, but a series of small, more focused elements. But concerning the inheritance, i think it would be much easier to visualize if you instead of changing the color of font, did the same thing but with the background-color, which makes everything more legible.

  • @peterbinder1023
    @peterbinder1023 7 лет назад +5

    i almost got a heart attack at 3:25
    btw nice video, very helpful! :)

    • @BrianArtea
      @BrianArtea 7 лет назад +2

      I know right but you have to admit it's pretty cool.

  • @BonCrowderPresents
    @BonCrowderPresents 7 лет назад +1

    Nice explanation. Thanks!

  • @anishadhikari3690
    @anishadhikari3690 5 лет назад +3

    That "WHAT" 😂😅👌

  • @duxiao5121
    @duxiao5121 5 лет назад +2

    'points' concepts help me a lot.haha

  • @vixi6293
    @vixi6293 4 года назад +1

    what if the main-content id didnt have a p tag specified in it? That would make it also explicitly targeting the strong tag right? Essentially making all of them red

  • @astronaut1751
    @astronaut1751 3 года назад

    2021 amazing almost 6 years

  • @ecosunflower1892
    @ecosunflower1892 4 года назад

    I was wondering. Maybe not so important, but still: Witch specificity point has an inherited element?

  • @marcspaul
    @marcspaul 4 года назад +1

    @8:00 will the strong tag work if the first rule was just #main_content{ } and not #main_content p{ }?

  • @Backflipmarine
    @Backflipmarine 4 года назад +1

    "WAAAAAAA" haha, awesome

  • @ZOULUYANG
    @ZOULUYANG 8 лет назад +5

    so, how about if i still want to be green? what should i do in this css file to make it green?

    • @NetNinja
      @NetNinja  8 лет назад +17

      +Luyang Zou You could make a more specific CSS rule, so it overrides the one making it red. For example - #main-content p.test{color: green;}

    • @DebjitMajumdar
      @DebjitMajumdar 5 лет назад +1

      I think usually use class for small indentations/ingeneral styling and ids for very specific ones.
      Also the point system makes it easier . Its all about the selector specificity.
      #maincontent + p+ .test= 100 + 1 + 10 = 111points which is greater than 100. So you will have your green text

  • @ErrorJordan1s
    @ErrorJordan1s 8 лет назад +2

    Very helpful tutorials. I have a question or a scenario rather. I'm using a Theme in wordpress and I'm trying to create a banner with css. I'm running into alot of trouble. Since it's a company site I don't want to place the url here without permission. Thanks to your tutorial I understand now that the themes point system overrode my code and I'm finally able to make changes. Thank you! If you have time I can send the url to you. If not thanks for your tutorials anyway.

    • @NetNinja
      @NetNinja  8 лет назад +1

      +Jaymartv Thanks, glad you enjoy the vids :). Sure, paste your URL...

    • @ErrorJordan1s
      @ErrorJordan1s 8 лет назад

      wordpress.ciactuation.com/valves/
      I'm trying to place the jpgs as a banner on the sides of the h2 Pipeline valves. And this theme isn't letting remove the jpegs from the site either.

    • @ErrorJordan1s
      @ErrorJordan1s 8 лет назад +1

      I think I actually figured it out right after I sent the message. Your the best though for sure.

    • @NetNinja
      @NetNinja  8 лет назад +1

      +Jaymartv See this fiddle - jsfiddle.net/tczp57md/ . Grab the CSS rule there and paste it in your CSS file, it will centre the image behind the PIPELINE VALVES text, if that's what you want to do? The image is being controlled by a bg-image property in CSS, so to remove it, just delete the CSS rule controlling it.

  • @MrNeogoyal
    @MrNeogoyal 5 лет назад

    Nice and apt video.

  • @lancer7344
    @lancer7344 3 года назад

    Best Shaun

  • @atomicatom9126
    @atomicatom9126 4 года назад

    You're a great teacher!!!
    But I found mistake over here.
    6:08 Here you reacted "WHAT" because there MUST BE green color in "p class="test".
    6:02 But the problem is YOU DIDN'T SAVE your FILE! (how can i say that you didn't save is when i first downloaded "Brackets" i noticed there on left side 'near to project' there is a DOT, that dot appears if you DON'T save your file)

  • @wizzbarclay7175
    @wizzbarclay7175 8 лет назад

    Super enthuisiastic at the beginning of this vid. ha ha

  • @LuamCortez
    @LuamCortez 6 лет назад +1

    So, if I write an element rule 102 times, will it win the ID rule? Or is this ranking system just a metaphor for priority? lol

    • @DebjitMajumdar
      @DebjitMajumdar 5 лет назад +2

      Remember , Implicit vs Explicit styling always has Explicit as the winner .
      Explicit vs Explicit follows Cascading( top to bottom and bottom is the winner )
      But Implicit vs Implicit always has Points System come into play.

  • @nsf56k
    @nsf56k 7 лет назад

    What do you think about google canary?

  • @uselesvideo
    @uselesvideo 7 лет назад

    dude will id.class take preference and override id element ?

  • @skfotograf
    @skfotograf 6 лет назад +1

    what about "!important" where he is? :)

  • @note-karlo
    @note-karlo 4 года назад

    Done

  • @ahmedimam6496
    @ahmedimam6496 8 лет назад

    Hello sir, I thought we can have only one ID per page but in the above example you have made three IDs header, content header and main header is that possible or I did't get it right ? Thanks..

    • @NetNinja
      @NetNinja  8 лет назад +2

      +Ahmed Imam Hey... You can only have 1 of each id on a page. So for example, only 1 'header' id, and 1 'main-header' id, whereas with classes you could have multiple of each one. :)

    • @ahmedimam6496
      @ahmedimam6496 8 лет назад

      +The Net Ninja Thanks sir, that was very helpful.
      I want u also to clarify for me another thing if u don't mind plz
      #MainContent {
      color:blue;
      }p{
      color:green;
      }
      in this above codes the ID points r 100 and the element is 1 point only but sill the element override the ID, why is that sir ? sorry if I'm asking a lot, it just coz i am a beginner in css. Thanks

    • @NetNinja
      @NetNinja  8 лет назад +1

      +Ahmed Imam It is ok :). That is because you are targeting the element directly with the P tag. The points rule only comes into play when you have more than 2 selectors that target the same element. #mainContent{ } targets a container element, but p{ } targets the p element. If it was #mainContent p{ }, then that selector would have more points and win :).

  • @PapyMougeot79
    @PapyMougeot79 7 лет назад +10

    In the title of your video, you typed: "Selector Specificty" there's a 'i' missing in Specific*I*ty

  • @leg3ndtariq
    @leg3ndtariq 6 лет назад +1

    Are you human ? Or our Humble , honourable Teacher ? :D
    Love from Bangladesh.

  • @happymilliarta5931
    @happymilliarta5931 6 лет назад +1

    why strong win? at this point I confused

    • @spraywhat4785
      @spraywhat4785 6 лет назад +1

      Explicit rules override implicit rules. "strong" was not directly targeted by any previous rules

    • @DebjitMajumdar
      @DebjitMajumdar 5 лет назад +1

      Implicit ( inherited ) vs Explicit Styling always has Explicit styling as the winner .
      Where as Implicit vs Implicit styling has the point system coming into play

  • @LyricalThamizhan
    @LyricalThamizhan 6 лет назад +1

    Go to be honest man. Hide all the tutorials in this RUclips and display only yours. Until you told about these rules, I had no idea that there is something like this.

  • @maciejs8293
    @maciejs8293 7 лет назад +2

    so how many points is strong ? thanks

  • @RameenFallschirmjager
    @RameenFallschirmjager 5 лет назад

    And you spelled specificity, 'specificty' in the title!

    • @NetNinja
      @NetNinja  5 лет назад +1

      Well observed :) I have corrected it now thank you!

    • @RameenFallschirmjager
      @RameenFallschirmjager 5 лет назад

      @@NetNinja It's an honor to do any service for you master ninja! I'm sure you can even kill John Wick with just a blink of an eye!

  • @moatasemkamaleltunsy6996
    @moatasemkamaleltunsy6996 5 лет назад

    how you calculate the points ? i didn't understand that?

  • @lawrence2121211
    @lawrence2121211 2 года назад

    I have an idea just say Specific lol. Hell that's what I do, because that's what it means.

  • @brod515
    @brod515 5 лет назад

    I think you come from the same area as Michael Bisping

  • @maksym.pavlenko
    @maksym.pavlenko 2 года назад

    Correct me if I'm wrong, but this points system isn't exactly correct.
    i.e. you can't override an id selector rule with eleven class selectors (1 * 100 < 11 * 10), the id selector would always win.
    Be aware of that.

  • @hzyounes6780
    @hzyounes6780 3 года назад +1

    i didnt understand something . i saw somewhere esle that we write " p#id" and not "#id p" can anyone help me here

  • @zensasquatch4627
    @zensasquatch4627 5 лет назад

    Should we stand infront of a mirror while learning to say Specificity?

  • @bablushofi6068
    @bablushofi6068 6 лет назад +5

    please stop your "oh" sound. It's really annoying for listening

    • @fritz-creates
      @fritz-creates 5 лет назад +1

      please stop your complaining. It's really annoying for reading because the net ninja is giving great value FOR FREE