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

  Рет қаралды 1,075,718

Kevin Powell

Kevin Powell

6 жыл бұрын

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 KZbin 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 жыл бұрын
I wasn't prepared to be attacked by this masterpiece.
@katriels8639
@katriels8639 2 жыл бұрын
I wasn't prepared to be attacked by the bright white background
@lynscott6171
@lynscott6171 2 жыл бұрын
LOL! Agreed.
@SEALteam6Operator
@SEALteam6Operator 2 жыл бұрын
To which I was, indeed.
@sid4827
@sid4827 2 жыл бұрын
Same bruh , as a backend developer I used get irritatedly confuse bc of this, it's masterpiece indeed
@RainOnline
@RainOnline 4 жыл бұрын
this guy is my life when it comes to understanding css syntaxes in a quick second
@martefact
@martefact Жыл бұрын
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.
@bookwyrm4559
@bookwyrm4559 Жыл бұрын
He gotta be the greatest
@mr.mikaeel6264
@mr.mikaeel6264 3 жыл бұрын
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 ^^
@WolfieSilveira
@WolfieSilveira 6 жыл бұрын
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 жыл бұрын
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?
@nashmiaadnan3560
@nashmiaadnan3560 2 жыл бұрын
You're the most helpful CSS instructor out there! Thank you for simplifying complicated concepts so easily
@anonymous_basics
@anonymous_basics Жыл бұрын
he introduce himself as the css king lol
3 жыл бұрын
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
@dentheadgaming4400
@dentheadgaming4400 4 жыл бұрын
Hey, new coder here, thanks for clarifying this. I was so confused on this topic.
@guanahtamar914
@guanahtamar914 2 жыл бұрын
same here, guessing you are not a new coder anymore lol.
@alirezalatifi3565
@alirezalatifi3565 2 жыл бұрын
@@guanahtamar914 but i am. There are always some new coders :D
@danielaguilera4782
@danielaguilera4782 2 жыл бұрын
Same
@aybmab2
@aybmab2 5 жыл бұрын
This was awesome!! I've always ignored these when looking at sample code with very little thought. Very informative.
@p_o_z_e
@p_o_z_e 4 жыл бұрын
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!
@rboy879
@rboy879 2 жыл бұрын
I swear, been doing this web dev for a while and this guy always amazes me with the detail straightforward explanations. Nice!
@JohnsonKongor
@JohnsonKongor 4 жыл бұрын
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....
@bobdinitto
@bobdinitto 2 жыл бұрын
Kevin, you're amazing. In the first three minutes you solved my problem! Thanks. Can't wait to watch the rest of the series.
@charlotte.upandaway
@charlotte.upandaway 3 жыл бұрын
This was SO helpful! Thank you so much for this video series. Heading straight over to part two!!
@firstlast6956
@firstlast6956 3 жыл бұрын
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.
@d.bachmann6798
@d.bachmann6798 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
@kite4792
@kite4792 5 жыл бұрын
thanks for the taking the time to demonstrate the various examples, instead of just saying it. ❤️
@ammarhassan_
@ammarhassan_ 5 жыл бұрын
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
@alvaronaranjo2589
@alvaronaranjo2589 Жыл бұрын
Love how the quality of your videos just keeps getting better
@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
@kamoroso94
@kamoroso94 5 жыл бұрын
I had the same confusion trying to use ::before on input elements. Thanks for noting this problem!
@danielribeiro356
@danielribeiro356 Жыл бұрын
Man, your videos are just amazing! What a simple way to explain those things! Congratulations!
@chinmaymathur2430
@chinmaymathur2430 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🙏🙏
@LokiDaFerret
@LokiDaFerret 3 жыл бұрын
I love the fact that I learn something new from each and every one of your videos. This one included obviously. 👍
@somnvm37
@somnvm37 3 жыл бұрын
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.
@benzflynn
@benzflynn 3 жыл бұрын
Works too.
@Andrea-lf3jq
@Andrea-lf3jq 4 жыл бұрын
This was the most easy to understand explanation I have come across since starting to learn Web Development. Thank you!!
@marksolon1874
@marksolon1874 4 жыл бұрын
same here
@djhonza1939
@djhonza1939 Жыл бұрын
Thank you from the bottom of my heart for simplifying this for me!! The best explanation ever!
@jamesbowdren7237
@jamesbowdren7237 2 жыл бұрын
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!
@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 😊
@jasonshere
@jasonshere Жыл бұрын
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 :
@KevinPowell
@KevinPowell Жыл бұрын
Welcome aboard!
@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!
@thiagoterceiro9902
@thiagoterceiro9902 5 жыл бұрын
Really great stuff Kevin! Keep at it!
@hossesarse
@hossesarse Жыл бұрын
5:58 Beware the wrath of a patient man... when a Canadian says the word "hell", you know he was supremely frustrated.
@salimal-tarsha5564
@salimal-tarsha5564 Жыл бұрын
I never get bored watching you Kevin thanks for sharing
@abishkarkarki268
@abishkarkarki268 Жыл бұрын
5 years and still helpful thank you
@itameio6161
@itameio6161 2 жыл бұрын
Thank you for the video, Kevin. This really was well-explained and helpful.
@JR-em2hn
@JR-em2hn 4 жыл бұрын
Very simple and useful explanation! Thanks Kevin!
@hoangtronglap2015
@hoangtronglap2015 5 жыл бұрын
Definitely love your tutorials, Kevin!
@Furki4_4
@Furki4_4 Жыл бұрын
these were one of the most mystic elements for me, thank you for the explanation ! going to next video...
@Stevenbustamento
@Stevenbustamento 5 жыл бұрын
Im binge watching your whole channel and I love it. Thank you.
@evergreen7781
@evergreen7781 3 жыл бұрын
Finally understood what these are !!! Thanks Kevin, you are really a CSS master !!!
@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!
@candicelitteral1954
@candicelitteral1954 2 жыл бұрын
Thanks for clarifying this subject!
@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.
@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.
@chlobdya3756
@chlobdya3756 4 жыл бұрын
Thanks kevin for clearing the confusion!!
@sivasanthosh9610
@sivasanthosh9610 5 жыл бұрын
Thank you bro, now I get the clarity about ::before and ::after
@almostworthy2973
@almostworthy2973 4 жыл бұрын
This is a game-changer!!! Thank you, Sir!!
@anjirnoor950
@anjirnoor950 3 жыл бұрын
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.
@SteveSmith-jc7pc
@SteveSmith-jc7pc 3 жыл бұрын
Great simple and clear explanation. Thanks.
@kopilkaiser8991
@kopilkaiser8991 4 ай бұрын
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 😊
@CazCreates
@CazCreates Жыл бұрын
This is really useful, thanks Kevin!
@footballskills6574
@footballskills6574 2 жыл бұрын
OMG you are incredible I was looking for this and I can't leave this channel without subscribing !!
@TheNarancia
@TheNarancia 3 жыл бұрын
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 :)
@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!
@10760910eugenioyoutu
@10760910eugenioyoutu 4 жыл бұрын
Thank you Kevin, nice tutorial, very objective, goes to the point !!
@ThiagoAdomaitis
@ThiagoAdomaitis 3 жыл бұрын
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.
@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 :).
@EduardoOliveira77
@EduardoOliveira77 11 ай бұрын
Finally I understood how the pseudo elements works. Thanks!
@IntlStudentStorytime
@IntlStudentStorytime 2 жыл бұрын
Thank you Kevin, you are a blessing
@stavroskefaleas6320
@stavroskefaleas6320 2 жыл бұрын
Best explanation of this topic on the whole Internet!!!
@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.
@BalakishanGundi
@BalakishanGundi 3 жыл бұрын
Dear Kevin! You are a wonderful teacher! Thank you!
@nathancornwell1455
@nathancornwell1455 4 жыл бұрын
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 .
@kinstar
@kinstar Жыл бұрын
God why has it taken me this long to learn this properly. Thanks again!!!
@00el04
@00el04 3 жыл бұрын
Amazing tutorial Kevin!
@ElTsakoss
@ElTsakoss 3 жыл бұрын
you are one of the best web dev tutors in this platform
@indieNik
@indieNik 6 жыл бұрын
Thank you Kevin. Was really waiting for these concepts :)
@KevinPowell
@KevinPowell 6 жыл бұрын
No problem at all, glad you liked it!
@RockstahRolln
@RockstahRolln 4 жыл бұрын
Terrific video!! Finally understood what these are!
@armorinformationtechnology7309
@armorinformationtechnology7309 3 жыл бұрын
Another good one, Kevin, thanks!
@FordExplorer-rm6ew
@FordExplorer-rm6ew 4 жыл бұрын
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
@georgetomeh8898
@georgetomeh8898 3 жыл бұрын
Thanks Kevin, great explanation
@TanishqSharma
@TanishqSharma 4 жыл бұрын
Simple & effective, Kevin. Cheers.
@jcpartri
@jcpartri 6 жыл бұрын
Great video! Clear, understandable, even inspiring. Thank you for making this. I learned something today. - Many blessings.
@KevinPowell
@KevinPowell 6 жыл бұрын
So happy to hear that John!
@rubhan94
@rubhan94 6 жыл бұрын
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.
@paulsonstechpoint773
@paulsonstechpoint773 3 жыл бұрын
Very clear and precise explanation. I like this!!!
@JessLord1
@JessLord1 Жыл бұрын
This was so helpful, thank you very much.
@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.
@markkfitx
@markkfitx 3 жыл бұрын
Found your channel and was like... JACKPOT! definitely subscribed
@GauravSingh-sv5cw
@GauravSingh-sv5cw 3 жыл бұрын
wow! This makes so many things easier!! Thank you Kevin!!
@lamyabenammar3050
@lamyabenammar3050 Жыл бұрын
simple and informative, THANKS!
@Vxortex
@Vxortex Жыл бұрын
But still able to explain each stage in a basic manner. Honestly thanks man!
@darpananeja4751
@darpananeja4751 2 жыл бұрын
Very nice video!! Really cool stuff, you taught there
@Encysted
@Encysted Жыл бұрын
5:07 It’s been a few years, but it’s worth adding that is a void element, like and , all of which seem to “ignore” ::before and ::after
@RahulSharma-ox6se
@RahulSharma-ox6se 3 жыл бұрын
Awesome video, Kevin!!!
@fullstackgreekdeveloper8033
@fullstackgreekdeveloper8033 3 жыл бұрын
This explanation is simply awesome!
@mahmudulislammaruf9405
@mahmudulislammaruf9405 2 жыл бұрын
Easily understood. Thank you!
@ckernest
@ckernest 5 жыл бұрын
very clear and precise explanation.
@codervince4957
@codervince4957 2 жыл бұрын
Very easy to understand! Thanks a lot!
@martakay4602
@martakay4602 4 жыл бұрын
Amazing, I am so happy I came across this. Thank you
@muntadheralnoor8365
@muntadheralnoor8365 6 жыл бұрын
I like your videos Kevin, very clear to understand and I benefit a a lot from this channel .
@KevinPowell
@KevinPowell 6 жыл бұрын
Glad to hear that Alibadi!
@user-qz4rp4ie7x
@user-qz4rp4ie7x 6 жыл бұрын
Amazing! Very clear explanation!
@RockstahRolln
@RockstahRolln 6 жыл бұрын
Terrific video! I FINALLY understood these pseudo elements. Thank You!
@KevinPowell
@KevinPowell 6 жыл бұрын
Awesome!
@kalebgobert8293
@kalebgobert8293 3 жыл бұрын
Extremely helpful video. Thanks
@franciscobarria3647
@franciscobarria3647 2 жыл бұрын
Great intro to before & after, been using them like a noob
@marcelvanlierop
@marcelvanlierop 6 жыл бұрын
Hi Kevin. Great video. Looking forward to the other ones!
@KevinPowell
@KevinPowell 6 жыл бұрын
Thanks, Marcel, glad you liked it :)
@radomirmijovic2605
@radomirmijovic2605 2 жыл бұрын
Thanks Kevin, this is great!
@tylercode2207
@tylercode2207 2 жыл бұрын
You are great G!...your videos help a lot!..Keep going!
Three fun uses for  ::before and ::after
12:04
Kevin Powell
Рет қаралды 122 М.
OMG 😨 Era o tênis dela 🤬
00:19
Polar em português
Рет қаралды 8 МЛН
Why? 😭 #shorts by Leisi Crazy
00:16
Leisi Crazy
Рет қаралды 44 МЛН
FOOTBALL WITH PLAY BUTTONS ▶️ #roadto100m
00:29
Celine Dept
Рет қаралды 71 МЛН
Set and HashSet in Java - Full Tutorial
20:43
Coding with John
Рет қаралды 190 М.
TypeScript Generics are EASY once you know this
22:21
ByteGrad
Рет қаралды 120 М.
Are you using the right CSS units?
6:30
Kevin Powell
Рет қаралды 439 М.
Learn CSS Pseudo Elements In 8 Minutes
7:50
Web Dev Simplified
Рет қаралды 248 М.
Learn CSS pseudo elements in 4 minutes 🔎
4:49
Bro Code
Рет қаралды 22 М.
From Design to Code // HTML & CSS from scratch // Frontend Mentor
35:33
6 Advanced Flexbox Features You Probably Don’t Know
14:54
Web Dev Simplified
Рет қаралды 108 М.
Flexbox or grid - How to decide?
18:51
Kevin Powell
Рет қаралды 695 М.
OMG 😨 Era o tênis dela 🤬
00:19
Polar em português
Рет қаралды 8 МЛН