Step up your CSS game using these selectors and combinators

Поделиться
HTML-код
  • Опубликовано: 30 янв 2018
  • Most people know the basic selectors, but aren't aware that there are some really useful advanced selectors as well.
    In this video, I take a look at the universal, direct child, general sibling, adjacent sibling, and a bunch of attribute selectors.
    While I'm a big advocate of trying not to nest selectors too much, we can use these advanced CSS selectors in fun ways to save us having to write extra CSS.
    CodePen: codepen.io/kevinpowell/pen/MQ...
    ---
    New to Sass, or want to step up your game with it? I've got a course just for you: www.kevinpowell.co/learn-sass
    ---
    My Code Editor: VS Code - code.visualstudio.com/
    How my browser refreshes when I save: • How to automatically r...
    ---
    Support me on Patreon: / kevinpowell
    I'm on some other places on the internet too!
    If you'd like a behind the scenes and previews of what's coming up on my RUclips channel, make sure to follow me on Instagram and Twitter.
    Instagram: / kevinpowell.co
    Twitter: / kevinjpowell
    Codepen: codepen.io/kevinpowell/
    Github: github.com/kevin-powell

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

  • @MavericKKumar
    @MavericKKumar 3 года назад +3

    This is one of the most underrated channel on whole RUclips for web dev.
    One of the best explanation of advance selector on whole RUclips..

  • @amina___6443
    @amina___6443 6 лет назад +92

    You're one of my constant go-tos in the RUclips Realm, thanks so much for your high quality content!

    • @KevinPowell
      @KevinPowell  6 лет назад +4

      So glad to hear that Jane! Really glad that you're enjoying my videos!

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

      @@KevinPowell Just as a side note... the emoticon gallery has been really extensivelt developed, and many icons you can find in this gallery, which is built in, which means you do not have to make another separate request for an icon. You need to set UTF-8, but everyone should use that anyways. And emoticons can be used as single colors too, so you can color it. You should use the entities for it, just to be sure.

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

    The attribute selector was what I had been looking around for months. You sir just answered all of my questions related to that here. Thank you very much, mate!

  • @TransverseAudio
    @TransverseAudio 5 лет назад +5

    Great video, I really like the level of depth you put into the explanations and for even setting up the demo. Well done, keep up the good work!

  • @francopdx
    @francopdx 2 года назад +2

    Thank you for providing us with so many helpful explanations. I've been using advanced selectors for several months, but it's often been a bit of a trial & error guessing game to figure out which one I need. This video gave me a much better understanding of the children and sibling selectors. And I had barely looked at the attribute selector before, but now that makes a lot more sense too.

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

    Very helpful tutorial. Short and to the point. Thanks Kevin!

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

    Thanks for the video, Kevin. Like all of your videos, I found it very helpful. Please keep them coming.

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

    at 12:19 >> *"|"* is called >> verti-bar, vbar, stick, vertical line, vertical slash,bar, pike, or pipe, and several variants on these names. from en.wikipedia.org/wiki/Vertical_bar My teacher Called it Pipe Symbol in class.

  • @preethi-dev
    @preethi-dev 2 года назад +1

    every day really your videos brush up my CSS skills. while I see your thumbnails of videos, feel like finally will go to understand the crucial concepts. feeling blessed

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

    Kevin, Every time I watch a video for you I learn something new, no idea where you get the stuff from, but here I am learning something new today, Thanks a million and God Bless You.

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

      Hopefully I can keep finding these things 😂

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

    Excellent content; I like the level of detail while remaining basic and easy to comprehend with an example. Thank you for providing such high-quality information. Bravo!

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

    I really appreciate you explaining the reset. So many people just tells you to include a reset with minimal explanation.
    Enjoy your tutorials. Thanks!

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

      No problem at all! Thanks for the feedback, it's good to know when these things are appreciated 👍

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

    Very informative and technical info. Thanks a lot. Examples really show something different like blue vs green, like totally different

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

    I not only liked it, instead I loved it and I love all your efforts that are helping us incredibly and amazingly... Love you Man

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

      So happy that you enjoyed it that much Ankit!

  • @ashleyhoward14
    @ashleyhoward14 3 года назад +6

    I loved your easy explanation of + and ~. I was using + everywhere because I didn't really understand the other. It really cleared things up for me!

    • @Victor_Marius
      @Victor_Marius 3 года назад +3

      + is the selector for the next SINGLE ELEMENT (of some kind) after some element while the other, ~, selects the next MULTIPLE ELEMENTS (of some kind) after some element. You can think of + as a css way for js Element.nextElementSibling with additional check to Element.matches()

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

    thanks so much! another great use of selectors is in javascript with document.querySelector, I use it for automating stuff on websites all the time, and with these new css tricks i'll be UNSTOPPABLE :))

  • @fzben44
    @fzben44 6 лет назад +6

    omg this is GREAT ! i learnt a lot ! thank you so much Kevin :)

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

    Looking forward to using attribute selectors. Good stuff.

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

    I basically had no idea these existed, so thank you!

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

    I'am loving it
    this is just so easy and clear to understand
    thank you sooooo much...........

  • @benzflynn
    @benzflynn 4 года назад +25

    One almost essential selector these days is the *:not* selector.
    It's the best way to do things like:
    1) Exclude the logo (home page link) from the usual rule of marking the current webpage (here classed as ".point")
    e.g. .point:not(.mylogo)::after {
    width: 100%;
    height: 2px;
    }
    2) Exclude the current page from the usual hover marker
    e.g. .navlink:not(.point):hover::after {
    width: 100%;
    height: 2px;
    }

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

      True!! I use this selector almost every time!!

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

      The :not() selector is said to be expensive for performance but it is used a lot in the implementation of the Edge (the new version) DevTools UI an probably in Chrome DevTools also... So... If it's good enough for them it for me too.

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

      @@Victor_Marius It's not a *visible* issue on my Huawei Y6 smartphone. But surely the preprocessor could handle this type of selection assignment ?

  •  3 года назад

    Thanks for high quality and easy to understand contents.

  • @GoskitarDTV
    @GoskitarDTV 6 лет назад +4

    Kevin, you are awesome. I always learn thanks to your videos

    • @KevinPowell
      @KevinPowell  6 лет назад

      Thanks Oscar, glad you like my content :D

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

    Thank you Kevin, you are the best css teacher I ever had.

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

    Tremendous content kevin. millions of kudos for you.

  • @AmitKumar-sl3cr
    @AmitKumar-sl3cr 5 лет назад +1

    I just wanna say thank you to upload these awesome videos.it helped me a lot :)

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

    Awesome demo, Kevin Powell. Thanks! Just one thing I’ll point out, and I’ve used it for this before: attribute selectors are a good workaround to override !important. As I’m sure you’re well aware, Bootstrap templates/overrides can be a bit (ahem) clunky, so that’s been a failsafe for me in some situations.

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

    The attribute selectors felt familiar . . . regular expressions! Had no idea we could use regexp in css. Super helpful information.

  • @facundocorradini
    @facundocorradini 6 лет назад

    Nice tutorial as always. A nice use case for attribute selectors is combining them with data- attributes

    • @KevinPowell
      @KevinPowell  6 лет назад

      Good point, I should have mentioned that in the video 😕

  • @konraddariuszwoloszyn9206
    @konraddariuszwoloszyn9206 6 лет назад +8

    If I remember correctly, we call the "straight line down thing" a pipe :). Great video!

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

    Many thanks for all of the tutorials. You are the best.

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

    It's detailed information about advanced selector, Thank you so much for it.

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

    Great and informative video. I didn't know you could put an url in the content, that was something new for me. I don't understand why they don't clearify that the vertical bar selector hasn't anything to do with what the word starts with rather that it needs to be one exact word, unless you have a hyphen seperating it (but this is just an exeption).

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

    Good one. Very clean explanation. I enjoyed it.

  • @akhil5020
    @akhil5020 6 лет назад +4

    Thanks Kevin,fr taking out time to make videos

    • @KevinPowell
      @KevinPowell  6 лет назад +2

      No problem at all Mari, glad you liked it :)

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

    I love the technicals !!!!! Very clean coding is soo much BETTER ! Thank You. Peace :)

  • @darkpain4208
    @darkpain4208 2 года назад +1

    You made that look too easy! Thanks a million, Kevin. Practically, what I'm gonna be watching next is, you versus Kevin on a css battle. 😂♥️

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

    Nice explanation.....Best video of selectors
    Learned so much from you sir..

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

    BAH DAH BAH BAH BAHHH....I'M LOVING IT!!! Thanks KP!

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

    12:19 That's usually called a vbar, for vertical bar, or just bar. It has some other names when it's used for logic or math though.

  • @seemsas
    @seemsas 6 лет назад

    Thanks for the video. It filled some gaps and I can use some of the advanced selectors right now :)

  • @darrellparkhouse175
    @darrellparkhouse175 6 лет назад +122

    the character that is up and down is called the pipe symbol lol

    • @KevinPowell
      @KevinPowell  6 лет назад +15

      Thanks Darrell, I should've know that :\

    • @JayCarey45
      @JayCarey45 6 лет назад +3

      Came here for this.... four months too late.

    • @ELP1125
      @ELP1125 6 лет назад

      Or a separator

    • @JawsoneJason
      @JawsoneJason 5 лет назад +17

      Its official typography name is "vertical bar": en.m.wikipedia.org/wiki/Vertical_bar

    • @benzflynn
      @benzflynn 4 года назад +5

      Or the OR symbol, if you're a Java(Script) coder LOL . . .

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

    Great Video . Thanks a lot , very helpful

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

    Man those attribute selectors! How have I not heard of these before!?

  • @indieNik
    @indieNik 6 лет назад

    Thank you Kevin. Your videos are Awesome as always :)

  • @DINESHKUMAR-xn6ij
    @DINESHKUMAR-xn6ij 6 лет назад

    Thanks a lot Kevin, Very nice explanation

    • @KevinPowell
      @KevinPowell  6 лет назад

      Thanks Diniesh! Glad you liked it!

  • @jatindersingh-lq2fd
    @jatindersingh-lq2fd 6 лет назад

    Very helpful, thanks a lot Kevin.

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

    love it. Thanks alot for your video

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

    Awesome explanation. I liked it :)

  • @albertgalvez2556
    @albertgalvez2556 6 лет назад

    These are going to be very helpful, thank you.

  • @udarakasun
    @udarakasun 6 лет назад

    You are Great kevin. Thanks lot.

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

    Great explanation

  • @anasrida3454
    @anasrida3454 6 лет назад

    Found out about your channel today. Incredible content. Instant subscribe!!

    • @KevinPowell
      @KevinPowell  6 лет назад

      Glad you liked it and thanks so much for the sub!

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

    What an awesome lesson!

  • @LuisReyes-zs4uk
    @LuisReyes-zs4uk 2 года назад

    my favorite RUclips channel.

  • @rgraph
    @rgraph Год назад +1

    This isx a great video - previously I was using JavaScript to add a little icon after external links - but now I've changed that to this CSS:
    a[rel*="external"]::after {
    content: url('/images/external-link.png');
    padding-left: 5px;
    }
    Thanks!

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

      Thanks so much for the super kind words, and really glad that you're enjoying my content!

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

    Super useful, thanks

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

    The universal selector is also used to set the box sizing calculation:
    * {
    box-sizing: border-box;
    }

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

    Great video. Thank you

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

    Loved the videos!

  • @Safwan.Hossain
    @Safwan.Hossain 4 года назад

    Really well made video.

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

    Awesome, content. Thanks.

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

    I know I'm kinda late, but I just want you to know I like this video.

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

    I really enjoyed this

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

    u r my boss, clear and cool videos, plz more :D

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

    Really helpful thanks a lot !

  • @nonchalant8473
    @nonchalant8473 6 лет назад

    Very helpful tutorial. Thanks

  • @nmoschen
    @nmoschen 6 лет назад

    Awesome video!

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

    Great content!

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

    Great Video. thanks

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

    Great tutorial!!! I learned a lot from your tutorial...tysm :):)
    I want to select the parent list element by selecting the child anchor tag in it with CSS only not JS, can you help me out?

  • @vhwc4191
    @vhwc4191 6 лет назад

    Thanks for your clear explanation on the selectors with great examples.

  • @RoshanPradhan2
    @RoshanPradhan2 3 года назад +2

    11:25 It would have been more handy if Relational operators (like ==) are used.

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

    Thank you!

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

    Great video 👏🏼👏🏼👏🏼👏🏼👏🏼

  • @josephboykin3443
    @josephboykin3443 6 лет назад

    The "straight line" is a pipe. This video is excellent bty.

    • @KevinPowell
      @KevinPowell  6 лет назад

      I always forget that for some reason! And glad you enjoyed the video

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

    So good tutorial

  • @tomasslezak3628
    @tomasslezak3628 6 лет назад

    Great tips, thanks.

    • @KevinPowell
      @KevinPowell  6 лет назад

      No problem, glad you liked it.

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

    Thanka for this!

  • @gknt694
    @gknt694 6 лет назад

    thank you sir!

  • @ram-gb4xg
    @ram-gb4xg 4 года назад

    thanks a lot!

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

    Thank you alot.

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

    awesome genius man

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

    thanks for the help👌👌

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

    Good stuff man, thanks.

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

    thanks man, make a video with pseudo element selector like nth-child

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

    Best teacher!!!

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

    Thanks!

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

    Ty

  • @EmmainthePNW
    @EmmainthePNW 6 лет назад

    so helpful

  • @eslama.h6238
    @eslama.h6238 5 лет назад +1

    loved it

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

    great video...thank you!

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

    King, the straight line down thing is called 'pipe' .

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

    Kevin, I love your content. I find it hard to see where you are "swishing lol" around with your mouse when you are pointing out a feature. Could you be a little more descriptive of where you are pointing with your teeny tiny pointer? Good video!

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

      Protip: Make the mousepointer larger and set it to the 'negative' theme (it'll turn black on a white background and white on a black background!)

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

    Clearly explained

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

    Thank you sir, very informative video to learn CSS Selector. These days I am hearing a lot about SelectorsHub CSS Selector tool, hows that tool sir?

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

    12:19, it is called "Pipe" symbol.

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

    gud one .. thanks!

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

    You are great!

  • @pablofigueroa9455
    @pablofigueroa9455 3 месяца назад

    Gracias..! Genial..!