Тёмный

CSS Tutorial - Selectors, Element, Class and ID (3/13) 

ColorCode
Подписаться 77 тыс.
Просмотров 49 тыс.
50% 1

CSS Tutorial - Selectors, Element, Class and ID (3/13)
So we just looked at a basic CSS statement and it starts with a selector. So what the hell are selectors, again?
Say you are brangelina, and you have a bunch of kids, you wanna dress them for school except only one of them is old enough for school. So first you have to pick the right kid, then dress/style them. That’s what selectors are. Choose which kid you wanna prepare for school. Or since you’re not brangelina, Choose which element you wanna style. It all starts with the selector.
There are different kinds of selectors. In our example, we used what’s called an element selector because it targets your styles based on the element type, That’s the most basic selector there is. By using the element type. Like a p tag. Cool? Cool.
The problem with element selectors is that you might not want to turn ALL your paragraphs blue. What if you had 3 paragraphs and you only want one of them to be blue? The element type is an identifier but in this case it’s too general.
I wanna show you an example. Look at this thing on atom’s website. See these two sections? One of them has a white background, the other one is beige. If you inspect it you’ll see they’re both divs, here they are, so clearly the dudes who made this couldn’t have said oh select all divs and change the background to white or beige. They needed to be more specific.
You can select elements based on other kinds of identifiers. Classes and ID. Class is the most common and useful one, in fact that’s exactly what Atom is using. Take a look. They have wrapper class on one, and highlight on the other. If you click on highlight, you’ll see that class has a beige background on it.
So let’s do one ourselves. Let’s say you have 4 paragraphs and you want to alternate between dark and light. So dark, light, dark, light. In other words you wanna reuse a style for multiple elements. In this case you can use a CLASS selector. The way you write these in CSS is you write the name of your class, this could be whatever you want, just can’t have spaces and some special characters, say DARK, and you put a DOT in front of it. Why a DOT? Well, I dunno what to tell you. There’s no good explanation why, that at least I know about. It’s just syntax that you have to remember. This tells the browser hey this is a CLASS selector. Then of course you have to add the class to your element in HTML.
This means “hey select all the elements that have a class attribute and the value is dark. Let’s try it:
DEMO 4 -
I’m gonna cover ID selectors too just for the sake of it although we don’t use them much. ID attributes are specific to one element only. If you have a style that you want to apply to only one element, for some reason, you can add an ID to that element (for example: my-blue-paragraph), then use an ID selector in CSS to style it. ID selectors are just like CLASS selectors, except you put a # in front of the name instead of the DOT. That becomes the CSS selector for the element with that ID. So let’s try it.
DEMO 3 -
The problem with ID is that it’s limited to only 1 element. Remember IDs can’t be shared between elements. So you can’t reuse my-blue-paragraph ID for multiple elements.
So those are the 3 basic selectors. Element, Class and ID. “Element” to style the elements of that type. ID to target only one specific element. And Class to reuse for multiple elements. We’ll be using all of them from now on. Selectors can get much much more complicated and they will, but now you know the basics.
So next, we’re gonna look at some of our options when it comes to style properties, like color, so far that’s all we’ve used so I’m gonna talk about it in detail. Later, fonts, sizes, background, border, animations, display types, flexbox, where’d everyone go? I was talking.

Опубликовано:

 

30 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 91   
@florinamartinez4282
@florinamartinez4282 5 лет назад
I am a visual learner, so your channel is going to save my life this semester! Awesome video!
@ColorCodeio
@ColorCodeio 5 лет назад
I'm so glad to hear that :) That's awesome. Enjoy.
@TheKetoSurvivor
@TheKetoSurvivor 6 лет назад
Dude! Great presentation. Great graphics (not overbearing). Great subtle and humor and metaphors. Great pacing (not speaking to me like I'm a 4 yr old all slow and simple. Thank you for not taking me through a trip to file linking land, a review of such, or 5 minutes of self-promotion}. Now I just need to look at your channel to see if you got anything that uses combonations of selectors and psudos.
@xchemicalXladybugx
@xchemicalXladybugx 4 года назад
Of all the videos and channels I used in school this is by far the best. Thanks so much, I really love the simplicity and graphics as well as the use of an actual website.
@ColorCodeio
@ColorCodeio 4 года назад
Thanks Maddy. I’m glad you like the channel :)
@reidwilliamson6477
@reidwilliamson6477 2 года назад
I wish all the other coding youtubers were as laid back and easy to understand as you. Blessings
@ColorCodeio
@ColorCodeio 2 года назад
Thank you Reid :) Appreciate the kind words.
@abggirma8320
@abggirma8320 2 года назад
Oh my God! it is clear the blue sky man!!!
@warrenresearchinc.1883
@warrenresearchinc.1883 2 года назад
Great refresher if you are running into a airhead moment when its been a while since diving deep into CSS. Doing some deep customization for a client and I was running into a simple way to explain how this worked verbally. I was totally having a 🤪 moment and needed more coffee.
@ColorCodeio
@ColorCodeio 2 года назад
Appreciate that!
@drewskii9708
@drewskii9708 2 года назад
Started off with a simple and funny hook and gave great visuals, awesome video man!
@ColorCodeio
@ColorCodeio 2 года назад
👍
@r.sriram5820
@r.sriram5820 2 года назад
What my teacher failed to convey in 2 months, you did in 6 minutes! My practical exams are in 45 mins, wish me luck bro!
@ColorCodeio
@ColorCodeio 2 года назад
Good luck!
@r.sriram5820
@r.sriram5820 2 года назад
@@ColorCodeio Thanks to you, It went really well, I got the desired output. I was clueless on how to use selectors. thanks a lot, I owe you
@liamthomson8787
@liamthomson8787 4 года назад
This is very helpful. Thank you for making it so clear to understand!
@ColorCodeio
@ColorCodeio 4 года назад
Awesome. You're very welcome.
@kosonamam4397
@kosonamam4397 2 года назад
Thank you man, you made my day. I have been looking for this answer for awhile. Now I've found it. Cheers
@ColorCodeio
@ColorCodeio 2 года назад
Awesome!
@YahyaZekry
@YahyaZekry 3 года назад
THANK YOU, I was so confused about Classes and Ids
@ColorCodeio
@ColorCodeio 3 года назад
Awesome :D
@cherl2289
@cherl2289 3 года назад
Ahhhh! Finally someone who helps me understand.. 😀😀😀
@ColorCodeio
@ColorCodeio 3 года назад
:)
@sergerudasingwa7638
@sergerudasingwa7638 3 года назад
Thanks , now i can understand selectors and what they do. Keep it up!!!
@ColorCodeio
@ColorCodeio 3 года назад
Glad to hear that!
@alexq3498
@alexq3498 3 года назад
Funny. More enjoyable than other tutorials and still learning! Thanks for posting.
@ColorCodeio
@ColorCodeio 3 года назад
Glad you like them!
@layanmawri3720
@layanmawri3720 Год назад
Your way of explaining is a masterpiece.
@ColorCodeio
@ColorCodeio Год назад
🙏Thank ya
@yudarecht572
@yudarecht572 2 года назад
perfect! not too long, not too short
@ColorCodeio
@ColorCodeio 2 года назад
Sweet
@sbf.2189
@sbf.2189 Год назад
YOU HAVE A GREAT WAY TO EXPLAIN.
@studiodeconcept2807
@studiodeconcept2807 4 года назад
Great explanation and not overcomplicating matters!
@ColorCodeio
@ColorCodeio 4 года назад
Awesome! Thank you.
@queenlwiindi8998
@queenlwiindi8998 5 лет назад
this really helped. thank you!
@ColorCodeio
@ColorCodeio 5 лет назад
Thank you for your comment 👍🏼
@hamedriahizadeh2645
@hamedriahizadeh2645 4 года назад
that was fantastic!!!! clear and comprehensive thanks amillion
@ColorCodeio
@ColorCodeio 4 года назад
Awesome. Thank you :)
@destineevalenzuela2493
@destineevalenzuela2493 4 года назад
THANK YOU! I am taking the product design program through bloc.io and these videos are so so so helpful.
@ColorCodeio
@ColorCodeio 4 года назад
Great to hear! :) Let me know if you have any questions.
@gugacorchog1
@gugacorchog1 2 года назад
You are the only one explaining how to separate Class. thanks.
@ColorCodeio
@ColorCodeio 2 года назад
:)
@youngcoder7782
@youngcoder7782 4 года назад
Thanks so much,you helped me!!
@ColorCodeio
@ColorCodeio 4 года назад
Awesome :)
@yaramesallam2983
@yaramesallam2983 3 года назад
This is great thank you so much it helped a lot!
@ColorCodeio
@ColorCodeio 3 года назад
You're welcome!
@jiayian2309
@jiayian2309 Год назад
so very helpful, thank you so much.
@drawdownwind6636
@drawdownwind6636 Год назад
Thanks bro, really helpful.... *I enjoyed your mafiosi type hand gestures, while you talked about Brangelina xx
@ColorCodeio
@ColorCodeio Год назад
🤌🇮🇹
@theg.o.a.t1014
@theg.o.a.t1014 2 года назад
🤝after lesson I decide to subscribe
@ColorCodeio
@ColorCodeio 2 года назад
Awesome!
@DumbSkippy
@DumbSkippy 3 года назад
Thanks for a great video !
@ColorCodeio
@ColorCodeio 3 года назад
My pleasure
@OmerMan992
@OmerMan992 3 года назад
Great video! How did you arranged the color square on the left of the color oyu wrote? is it a color picker?
@ColorCodeio
@ColorCodeio 3 года назад
Yeah, I believe it comes with Visual Studio Code by default. You should see the color picker in your CSS.
@mikebcreative
@mikebcreative 6 лет назад
Great tutorials, really appreciate you sharing web knowledge. Also, is it possible to let me know which software you are using to for CSS and HTML? Thanks I'm a newbie to it.
@ColorCodeio
@ColorCodeio 6 лет назад
Sure Michael. I'm using Visual Studio Code and Google Chrome but you can use any IDE or browser you prefer. I talk about IDEs a bit here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Whps_IeaetM.html
@mikebcreative
@mikebcreative 6 лет назад
Thank you very much!
@humblemillionaire
@humblemillionaire Год назад
This video reallly helped me 👌
@ColorCodeio
@ColorCodeio Год назад
I'm glad
@andrewmccoy3773
@andrewmccoy3773 2 года назад
awesome video... very well produced
@ColorCodeio
@ColorCodeio 2 года назад
Glad you enjoyed it!
@rejaulhaque7948
@rejaulhaque7948 3 года назад
This is really good 👌👌👌👌
@ColorCodeio
@ColorCodeio 3 года назад
Awesome :)
@amiralinaser2452
@amiralinaser2452 5 лет назад
May God bless you. you saved my life. Thanks...
@ColorCodeio
@ColorCodeio 5 лет назад
Awesome :)
@steveroberts3868
@steveroberts3868 4 года назад
Perfect for my class I am teaching :-)
@ColorCodeio
@ColorCodeio 4 года назад
Awesome. Crush it 👊🏼
@farwatariq1445
@farwatariq1445 3 года назад
great explanation
@ColorCodeio
@ColorCodeio 3 года назад
Glad it was helpful!
@palakbasak3551
@palakbasak3551 3 года назад
helpful video thanks
@ColorCodeio
@ColorCodeio 3 года назад
Great
@avilashbhowmik3995
@avilashbhowmik3995 4 года назад
Gratitude
@ColorCodeio
@ColorCodeio 4 года назад
🙏🏼
@hanusaikrishna9707
@hanusaikrishna9707 3 года назад
hi can we give same id for 3 elements, and if we give some style will it work
@ColorCodeio
@ColorCodeio 3 года назад
You shouldn’t be using id’s that way. I explain why in the video.
@P_W_N_G_H_O_S_T
@P_W_N_G_H_O_S_T 6 лет назад
Nice video
@ColorCodeio
@ColorCodeio 6 лет назад
Thanks for checking it out :)
@Engycation
@Engycation 3 года назад
nice video
@ColorCodeio
@ColorCodeio 3 года назад
Thanks
@Human_Evolution-
@Human_Evolution- 3 года назад
Great but if like to see html and css at the same time.
@ColorCodeio
@ColorCodeio 3 года назад
Here is the HTML course that goes with it: ru-vid.com/group/PL1PqvM2UQiMrSuA6NHrwPZMrRN108Tdhy
@jerze6000
@jerze6000 Год назад
Name of the program he's using at 2:54 ?
@ColorCodeio
@ColorCodeio Год назад
VSCode
@webgard.
@webgard. 4 месяца назад
عاالی..
@danielhain40
@danielhain40 4 года назад
My Teacher sucks !! your rock
@ColorCodeio
@ColorCodeio 4 года назад
Thanks Daniel :)
@webgard.
@webgard. 4 месяца назад
آخر ویدیو فقط 😆
@TheFoezee
@TheFoezee 2 года назад
I really pay my school $5K a year to teach myself on youtube smh.
@ColorCodeio
@ColorCodeio 2 года назад
Thanks for the comment. Hope the video helped.
Далее
Learn Every CSS Selector In 20 Minutes
19:38
Просмотров 439 тыс.
He turned a baseball into a stylish shoe😱
00:59
Просмотров 788 тыс.
Using CSS custom properties like this is a waste
16:12
Просмотров 160 тыс.
When to Use CSS Classes vs Ids
16:07
Просмотров 11 тыс.
Learn Flexbox CSS in 8 minutes
8:16
Просмотров 1,4 млн
CSS Tips And Tricks I Wish I Knew Before
12:12
Просмотров 438 тыс.
Learn CSS in 12 Minutes
12:11
Просмотров 2,3 млн
Are You Making These CSS Height Mistakes?
8:54
Просмотров 122 тыс.
CSS Selector Basics
13:50
Просмотров 1,7 тыс.
Learn CSS flexbox in 10 minutes! 💪
10:01
Просмотров 120 тыс.