Before and After pseudo elements explained - part one: how they work

Поделиться
HTML-код
  • Опубликовано: 13 фев 2018
  • The before and after pseudo elements are super useful part of CSS, but are often misunderstood. This is part of a three-part series where I look at how they work, and cool stuff we can do with them.
    In this video, I focus on what ::before and ::after even are and how we can use them, and even why we use the double colon before them, instead of a single one (it's to distinguish them from pseudo-classes, like :hover).
    One important thing with both the before and after pseudo elements is that they require us to define the content property. Without it, it defaults to none and, well, we can use it!
    ---
    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

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

  • @jacklee8446
    @jacklee8446 3 года назад +313

    I wasn't prepared to be attacked by this masterpiece.

    • @katriels8639
      @katriels8639 2 года назад +15

      I wasn't prepared to be attacked by the bright white background

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

      LOL! Agreed.

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

      To which I was, indeed.

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

      Same bruh , as a backend developer I used get irritatedly confuse bc of this, it's masterpiece indeed

  • @RainOnline
    @RainOnline 4 года назад +162

    this guy is my life when it comes to understanding css syntaxes in a quick second

  • @martefact
    @martefact Год назад +95

    I was an adobe certified trainer/developer with focus on html CSS and Dreamweaver between 1999 - 2016 ish years. I now code creatively. Your videos are outstanding!!! I do think your personality plays a huge part. But your love of the craft makes the learning experience a total buzz and joy. Wow man. Kudos to you. So glad i stumbled on your work. A gifted instructor ..Thank You.

  • @mr.mikaeel6264
    @mr.mikaeel6264 3 года назад +50

    When you told us that you did not want us to have similar struggles as you had with the images i could almost hear a curse being lifted and a part of you moving on freely finally again ^^

  •  3 года назад +18

    As a singer, I use my page to promote my shows: I use ::before to show the words: "Next", "Tomorrow" and "Today" to highlight the next show, after I've assign such classes in JS depending on its date

  • @nashmiaadnan3560
    @nashmiaadnan3560 2 года назад +52

    You're the most helpful CSS instructor out there! Thank you for simplifying complicated concepts so easily

  • @WolfieSilveira
    @WolfieSilveira 6 лет назад +272

    I've seen the before and after option pop op often when I code. Though never used it.. This definitely gave me some design ideas

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

      Awesome! They are really handy for adding some nice flourishes without needing any extra markup :)

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

      Still?

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

      Yes

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

      @@KevinPowell Kevin, I have not been able to apply transitions to before and after pseudo classes. How to do it?

  • @dentheadgaming4400
    @dentheadgaming4400 4 года назад +71

    Hey, new coder here, thanks for clarifying this. I was so confused on this topic.

  • @JohnsonKongor
    @JohnsonKongor 4 года назад +36

    As a beginner in full stack web development, this topic had given me some headache. At least you have helped me out. Thanks so much. Will always follow on to find out more....

  • @p_o_z_e
    @p_o_z_e 4 года назад +15

    I've been a web dev student for around 2 months now, i just found your channel and your videos have helped me alot, thx for the awesome work!

  • @aybmab2
    @aybmab2 5 лет назад +26

    This was awesome!! I've always ignored these when looking at sample code with very little thought. Very informative.

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

    New coder as well, was so lost when it came to the ::before and ::after pseudo-classes. I just thought people were using them for the hell of it. Now I know! Thanks KP.

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

    I swear, been doing this web dev for a while and this guy always amazes me with the detail straightforward explanations. Nice!

  • @kite4792
    @kite4792 5 лет назад +13

    thanks for the taking the time to demonstrate the various examples, instead of just saying it. ❤️

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

    This is amazing explaination. I spend a week fighting with ::before and ::after and gave up until I find myself a good explanation and u to that job very well. Thanks

  • @charlotte.upandaway
    @charlotte.upandaway 3 года назад +2

    This was SO helpful! Thank you so much for this video series. Heading straight over to part two!!

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

    Kevin, you're amazing. In the first three minutes you solved my problem! Thanks. Can't wait to watch the rest of the series.

  • @d.bachmann6798
    @d.bachmann6798 4 года назад +4

    Hello Kevin,
    Thanks a lot for taking time and making this video... short and concise explaining exactly what one needs to understand and even explaining what is not explained here and why and where you are elaborating on it...
    May you have blessing in your work
    David B.
    Israel

  • @Andrea-lf3jq
    @Andrea-lf3jq 4 года назад +7

    This was the most easy to understand explanation I have come across since starting to learn Web Development. Thank you!!

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

    I had the same confusion trying to use ::before on input elements. Thanks for noting this problem!

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

    I spent so long trying to figure out what does before and after actually do. Thank you so much, cleared out alot of doubts

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

    I love the fact that I learn something new from each and every one of your videos. This one included obviously. 👍

  • @jasonshere
    @jasonshere Год назад +5

    I'm a new viewer (and subscriber) and I just wanted to say that I appreciate your professionalism and expert knowledge, that even present in your lessons 4 years ago.
    Thanks for pointing out :: vs :

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

    Man, your videos are just amazing! What a simple way to explain those things! Congratulations!

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

    God why has it taken me this long to learn this properly. Thanks again!!!

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

    5 years and still helpful thank you

  • @EduardoOliveira77
    @EduardoOliveira77 11 месяцев назад +1

    Finally I understood how the pseudo elements works. Thanks!

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

    After I finish any lesson about Css I immediately look for a video from you to help me better understand the subject matter. Thanks for helping me become a better developer.

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

    THANK YOU! This was so helpful! I will be checking out more of your videos! You explained this concept so well!

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

    Thank you from the bottom of my heart for simplifying this for me!! The best explanation ever!

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

    Wow , before and after was driving me nuts because I was using it without knowing why, now it is all starting to make more sense!

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

    This is the 2nd video I watched and then?
    Subscribed. Awesome explanation and with also clear examples. Before this, I saw at lots of places those" before" and "after" pseudo stuff but I didn't understand. Now I did. And just when I needed. Thanks Dude. You're freaking awesome. Your channel deserves more attention.

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

      So glad that the video was able to help, and thanks for subscribing! Also, thank you so much for the kind words 😊

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

    Love how the quality of your videos just keeps getting better

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

    5:58 Beware the wrath of a patient man... when a Canadian says the word "hell", you know he was supremely frustrated.

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

    So, actually for pseudo elements on Images, a great use case for them would be if for some reason the image failed then the pseudo element would actually show. So , instead of seeing the broken image placeholder or just the alt text , you could have something in the content property that you want displayed instead .

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

    Really great stuff Kevin! Keep at it!

  • @salimal-tarsha5564
    @salimal-tarsha5564 Год назад

    I never get bored watching you Kevin
    thanks for sharing

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

    Thank you, thank you, so, so much! I was so confused about this until I stumbled upon your video. You explained it masterfully. I really appreciate it!

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

    Thank you for the video, Kevin. This really was well-explained and helpful.

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

    This is a game-changer!!! Thank you, Sir!!

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

    Definitely love your tutorials, Kevin!

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

    Thank you bro, now I get the clarity about ::before and ::after

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

    Im binge watching your whole channel and I love it. Thank you.

  • @TheNarancia
    @TheNarancia 3 года назад +5

    Thank you for this content. It is so clear! You know, I'm from Pisa, and when I saw the tower appears on screen I started to laugh :)

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

    Thanks kevin for clearing the confusion!!

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

    Thanks a million Kevin!!! Whooa what an eye opener. Made so much sense and made me realize how to make it useful. Thanks again man, for videos. Take care.

  • @FordExplorer-rm6ew
    @FordExplorer-rm6ew 4 года назад +2

    Your stuff has taught me alot. Been about 2 years since I've been watching

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

      Thanks for sticking around for so long :D

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

    Finally understood what these are !!! Thanks Kevin, you are really a CSS master !!!

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

    Hello sir. I'm awfully thankful to you for all the knowledge I've learned from u ... appreciate your efforts very much. Ur tutorials r always properly explained and just so easy to understand. looking forward to a lot more of your awesome tutorials.

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

    This video is just great. I started to understand pseudo elements a long time ago with it.
    Now I forgot something, and it helped me a lot. Which makes it a very good video.
    SO, WILL GO YOU THIS:
    li:not(:last-child)::after {content:";"}
    li:last-child::after{content:"."}
    that code adds semi-colons to the end of each li, and dot to the end of the last one.

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

    Thanks for clarifying this subject!

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

    Yo man! I just randomly clicked your video for some explanation and now I’ll totally subscribe to your channel, nice content ! Keep it up!

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

    OMG you are incredible I was looking for this and I can't leave this channel without subscribing !!

  • @JR-em2hn
    @JR-em2hn 4 года назад

    Very simple and useful explanation! Thanks Kevin!

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

    these were one of the most mystic elements for me, thank you for the explanation ! going to next video...

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

    Wonderful explanation - the power of before and after is so much fun to play with :D

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

    Best video on before and after so far.

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

    Thank you Kevin. Was really waiting for these concepts :)

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

      No problem at all, glad you liked it!

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

    Best explanation of this topic on the whole Internet!!!

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

    Thank you for this video, Kevin! And as almost anyone else here, I also thought that ::before and ::after would create a new HTML thing in respective position.

  • @geekatari4391
    @geekatari4391 6 лет назад +12

    Excelente work! I am retaking web design and this clarifies a lot. Thank you for a short and informative video.

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

    How have I never noticed it's before the content but within the element itself! I've been using this for years too... Always good to learn new stuff thanks Kevin

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

      I thought the same thing forever too David. I forget when I realized that it didn't work that way. With the way we use them (and how they are named), it just makes sense that they'd be before and after the element itself. Makes it easier to use that it isn't though :).

  • @21thTek
    @21thTek 4 года назад +2

    Thank you Kevin, nice tutorial, very objective, goes to the point !!

  • @RahulSharma-ox6se
    @RahulSharma-ox6se 3 года назад

    Awesome video, Kevin!!!

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

    Great video! Clear, understandable, even inspiring. Thank you for making this. I learned something today. - Many blessings.

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

    Thank you Kevin, you are a blessing

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

    Thanks for the little gem about images not being able to utilize the sudo elements, it's these little extras that I love with your videos

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

      Haha, I had to share that, I spend *so* much time trying to figure out why it wasn't working, lol.

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

    This is really useful, thanks Kevin!

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

    This helped a lot! I was having a bit of trouble wrapping my mind around pseudo classes and elements, and this answered quite a few questions I had. :D

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

      So glad to hear that it helped clear things up! Very happy to help 👍

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

      Seriously I appreciate your content! :D I'm also glad you replied because I realized now that I forgot to subscribe to your channel xD Currently doing a 2-year front end developer course online. Think I'll get a lot out of your videos, we use Lynda but those tutorials often gets too dry and boring.

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

    Terrific video!! Finally understood what these are!

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

    Dear Kevin! You are a wonderful teacher! Thank you!

  • @kopilkaiser8991
    @kopilkaiser8991 5 месяцев назад

    Thank you for sharing with us your knowledge. This helped me to clear my confusion on pseudo elems and helpes me to understand the topic better 😊

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

    Another good one, Kevin, thanks!

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

    you are one of the best web dev tutors in this platform

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

    Found your channel and was like... JACKPOT! definitely subscribed

  • @00el04
    @00el04 3 года назад +1

    Amazing tutorial Kevin!

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

    But still able to explain each stage in a basic manner. Honestly thanks man!

  • @SteveSmith-jc7pc
    @SteveSmith-jc7pc 3 года назад

    Great simple and clear explanation. Thanks.

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

    There are lot of people teaching CSS on youtube and Udemy. But truly anyone knows and understands it; it's you.
    "If you can't explain something; you don't know it well" and opposite is true for you.

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

    At first I was planning to skip the video but after watching, I came to know that I was doing the biggest mistake of skipping😢🙏🙏Thanku sooo very much🙏🙏

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

    Amazing, I am so happy I came across this. Thank you

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

    Simple & effective, Kevin. Cheers.

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

    This was so helpful, thank you very much.

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

    This video is amazing your explanation was great. all of my confusion was gone after watched this video.

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

    wow this is amazing! I am defo becoming a programmer now! when I found out your channel even better than design course

  • @GauravSingh-sv5cw
    @GauravSingh-sv5cw 3 года назад

    wow! This makes so many things easier!! Thank you Kevin!!

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

    Thank you Kevin. Now i understand what is the use of these pseudo-classes. ++++

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

    Hi Kevin. Great video. Looking forward to the other ones!

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

      Thanks, Marcel, glad you liked it :)

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

    Thanks for clearing this up!

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

    Very clear and precise explanation. I like this!!!

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

    I'm here! 😎 Great video, just posting a comment to show some support! Keep up the good work. 🤙

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

    Thanks Kevin, this is great!

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

    Thanks Kevin, great explanation

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

    very clear and precise explanation.

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

    Terrific video! I FINALLY understood these pseudo elements. Thank You!

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

    Love the before and after pseudo elements.

  • @user-qz4rp4ie7x
    @user-qz4rp4ie7x 6 лет назад

    Amazing!
    Very clear explanation!

  • @789tridente
    @789tridente Год назад

    this is truly a before and after in my css

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

    I like your videos Kevin, very clear to understand and I benefit a a lot from this channel .

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

    Very nice video!! Really cool stuff, you taught there