All language subtitles for 008 Pseudo-classes_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,380 --> 00:00:02,350 Let's now learn 2 00:00:02,350 --> 00:00:05,510 about something called pseudo classes. 3 00:00:05,510 --> 00:00:09,010 Now, pseudo class sounds very strange, 4 00:00:09,010 --> 00:00:12,003 but it's actually pretty straightforward. 5 00:00:13,500 --> 00:00:14,820 And as an example, 6 00:00:14,820 --> 00:00:17,650 let's try to style the first list elements 7 00:00:17,650 --> 00:00:20,400 different from the other ones. 8 00:00:20,400 --> 00:00:23,820 So we have this list here and this list. 9 00:00:23,820 --> 00:00:25,800 And so, as I just said, 10 00:00:25,800 --> 00:00:28,470 let's try to style the first element 11 00:00:28,470 --> 00:00:30,780 of each of the lists differently. 12 00:00:30,780 --> 00:00:33,330 for example, by making them bold. 13 00:00:33,330 --> 00:00:36,428 So this element and this element 14 00:00:36,428 --> 00:00:38,810 now the straightforward way 15 00:00:38,810 --> 00:00:42,700 of doing this would be to add a class to each of them 16 00:00:42,700 --> 00:00:44,470 and then style them. 17 00:00:44,470 --> 00:00:45,303 Right? 18 00:00:45,303 --> 00:00:47,763 So let's actually try that first example. 19 00:00:48,660 --> 00:00:50,183 So here is one list. 20 00:00:51,440 --> 00:00:53,710 So let's add a class of 21 00:00:55,060 --> 00:00:56,120 first 22 00:00:56,120 --> 00:00:57,720 li, 23 00:00:57,720 --> 00:00:59,740 and then let's do the same 24 00:00:59,740 --> 00:01:02,693 to the other lists that we have up here. 25 00:01:06,650 --> 00:01:09,493 And then back in or CSS, 26 00:01:11,110 --> 00:01:14,793 let's select all the elements with the first li class. 27 00:01:15,990 --> 00:01:18,870 And then remember to make text bold. 28 00:01:18,870 --> 00:01:20,210 We use font-weight 29 00:01:21,230 --> 00:01:22,143 set to bold, 30 00:01:23,080 --> 00:01:25,500 and indeed, here we are. 31 00:01:25,500 --> 00:01:28,490 So now this one is bold and this one, 32 00:01:28,490 --> 00:01:31,390 but we can actually do better than this. 33 00:01:31,390 --> 00:01:33,530 So instead of doing this manually, 34 00:01:33,530 --> 00:01:36,519 we can actually have CSS automatically figure out, 35 00:01:36,519 --> 00:01:41,519 which is the first li element inside of a container. 36 00:01:41,930 --> 00:01:46,930 So let's actually do that and I will still keep 37 00:01:46,950 --> 00:01:51,501 the classes in the HTML, just so we keep it as a reference, 38 00:01:51,501 --> 00:01:54,923 but now let me show you how we can actually do it better. 39 00:01:56,940 --> 00:01:58,583 So we start by using li, 40 00:01:59,430 --> 00:02:02,640 which will basically select all the li elements, 41 00:02:02,640 --> 00:02:05,040 but then we use a pseudo class 42 00:02:05,040 --> 00:02:06,385 and we start a pseudo class 43 00:02:06,385 --> 00:02:08,114 by writing a colon 44 00:02:08,114 --> 00:02:09,098 like this. 45 00:02:09,098 --> 00:02:12,250 And then to one that we're interested in here 46 00:02:12,250 --> 00:02:13,770 is called first 47 00:02:15,250 --> 00:02:16,483 dash child. 48 00:02:17,660 --> 00:02:18,493 And that's it. 49 00:02:19,470 --> 00:02:24,470 And now here, we can say font weight and set it to bold. 50 00:02:25,420 --> 00:02:27,220 So let's see. 51 00:02:27,220 --> 00:02:31,152 And indeed it worked now they are back to being bold. 52 00:02:31,152 --> 00:02:35,110 So we basically changed our selector here 53 00:02:35,110 --> 00:02:36,692 and added a pseudo class to it. 54 00:02:36,692 --> 00:02:40,540 And what this first child pseudo class does 55 00:02:40,540 --> 00:02:43,080 is that it will select an li element, 56 00:02:43,080 --> 00:02:47,730 or actually it was select all the li elements that are 57 00:02:47,730 --> 00:02:51,500 the first child elements of its parent elements. 58 00:02:51,500 --> 00:02:55,653 And so that is exactly the case right here and right here. 59 00:02:57,410 --> 00:02:58,500 Right? 60 00:02:58,500 --> 00:03:00,166 So this li element here 61 00:03:00,166 --> 00:03:04,260 is the first-child element of its parent. 62 00:03:04,260 --> 00:03:06,470 So in this case, the Ol element, 63 00:03:06,470 --> 00:03:08,030 and therefore this selector 64 00:03:08,030 --> 00:03:11,340 that we wrote here will target that element. 65 00:03:11,340 --> 00:03:13,610 And the exact same thing is too 66 00:03:13,610 --> 00:03:16,409 for this other list down here. 67 00:03:16,409 --> 00:03:18,320 Okay. 68 00:03:18,320 --> 00:03:21,970 So let's try another one again, li. 69 00:03:21,970 --> 00:03:25,253 and then we also have one called the last-child. 70 00:03:27,560 --> 00:03:29,453 Until lets make it italic, 71 00:03:30,580 --> 00:03:32,100 so font style 72 00:03:33,080 --> 00:03:34,563 and set it to a italic. 73 00:03:35,580 --> 00:03:39,410 And indeed, now the last one became italic. 74 00:03:39,410 --> 00:03:40,970 So both here 75 00:03:40,970 --> 00:03:42,350 and both here 76 00:03:42,350 --> 00:03:43,670 because again, 77 00:03:43,670 --> 00:03:48,154 both of them are li elements that are now the last-child 78 00:03:48,154 --> 00:03:50,493 inside of its parent container. 79 00:03:51,841 --> 00:03:56,840 Next up, we can actually also target a specific child. 80 00:03:56,840 --> 00:04:00,730 So for example, the third or the second child. 81 00:04:00,730 --> 00:04:05,120 So for that, we use the nth-child pseudo class, 82 00:04:05,120 --> 00:04:07,810 and then here we actually need to write parenthesis 83 00:04:07,810 --> 00:04:12,728 like this so we can specify which of the child that we want. 84 00:04:12,728 --> 00:04:15,091 So let's say we want the second child 85 00:04:15,091 --> 00:04:17,116 to have a color of 86 00:04:17,116 --> 00:04:17,949 red. 87 00:04:19,660 --> 00:04:22,823 So using just a coded color name here, 88 00:04:23,700 --> 00:04:25,010 let's see. 89 00:04:25,010 --> 00:04:27,083 And indeed here it is. 90 00:04:28,310 --> 00:04:30,402 Or if we tried the third one, 91 00:04:30,402 --> 00:04:34,440 then indeed it would be the third one here 92 00:04:34,440 --> 00:04:36,220 and here as well. 93 00:04:36,220 --> 00:04:37,527 And even better than that, 94 00:04:37,527 --> 00:04:41,530 is that we can actually use some keywords here. 95 00:04:41,530 --> 00:04:44,180 so we can write odd. 96 00:04:44,180 --> 00:04:47,390 And now all the odd elements will be red. 97 00:04:47,390 --> 00:04:50,763 So element number one, then number two, 98 00:04:50,763 --> 00:04:54,730 or actually number three, and here it's element number one, 99 00:04:54,730 --> 00:04:57,290 number three, and number five. 100 00:04:57,290 --> 00:04:58,434 And if there were more, 101 00:04:58,434 --> 00:05:01,409 then it would select number seven, nine, eleven 102 00:05:01,409 --> 00:05:03,673 and so on and so forth. 103 00:05:03,673 --> 00:05:06,920 And of course, if we can do odd, 104 00:05:06,920 --> 00:05:08,590 then we can also do even 105 00:05:09,750 --> 00:05:12,590 so that we'll then select a number two, 106 00:05:12,590 --> 00:05:14,450 four, six, eight 107 00:05:14,450 --> 00:05:16,313 and so on and so forth. 108 00:05:16,313 --> 00:05:18,570 So you see number two 109 00:05:18,570 --> 00:05:21,400 and here two and four. 110 00:05:21,400 --> 00:05:22,233 Right? 111 00:05:22,233 --> 00:05:24,461 So this technique is quite useful 112 00:05:24,461 --> 00:05:26,245 for example, to style tables, 113 00:05:26,245 --> 00:05:31,000 which oftentimes have like alternating background colors. 114 00:05:31,000 --> 00:05:32,674 So I'm sure you have seen that somewhere. 115 00:05:32,674 --> 00:05:36,440 And so it's very helpful for that this technique here. 116 00:05:36,440 --> 00:05:39,788 Now let's actually comment out this property here 117 00:05:39,788 --> 00:05:43,610 because we don't want or text here to be red 118 00:05:43,610 --> 00:05:45,223 actually in a final page. 119 00:05:46,340 --> 00:05:48,010 Alright, So this was just to show you 120 00:05:48,010 --> 00:05:50,520 everything that we can do here. 121 00:05:50,520 --> 00:05:53,940 Now finally, let me clear up a common misconception 122 00:05:53,940 --> 00:05:57,200 that there is around the pseudo classes. 123 00:05:57,200 --> 00:05:58,888 So let's say that we wanted to select 124 00:05:58,888 --> 00:06:03,670 the first paragraph element that's inside of the article. 125 00:06:03,670 --> 00:06:06,373 So let's check that out here in our markup. 126 00:06:07,970 --> 00:06:09,838 So inside of the article, 127 00:06:09,838 --> 00:06:14,590 the first paragraph would basically be this one here. 128 00:06:14,590 --> 00:06:15,423 Right? 129 00:06:15,423 --> 00:06:18,268 So let's see what we can do here. 130 00:06:18,268 --> 00:06:20,140 So what I just said 131 00:06:20,140 --> 00:06:21,010 is basically 132 00:06:23,440 --> 00:06:25,569 article and then p. 133 00:06:25,569 --> 00:06:28,310 so that's the descendant selector. 134 00:06:28,310 --> 00:06:29,210 Right? 135 00:06:29,210 --> 00:06:32,980 So selecting a paragraph that's inside of the article 136 00:06:32,980 --> 00:06:36,013 and now selecting the very first of that. 137 00:06:38,250 --> 00:06:39,893 So first-child. 138 00:06:41,440 --> 00:06:43,463 And now let's say we want the color. 139 00:06:44,690 --> 00:06:47,048 To be red in this one, 140 00:06:47,048 --> 00:06:51,050 but as we reload this and check out our page, 141 00:06:51,050 --> 00:06:53,290 you see that nothing happened. 142 00:06:53,290 --> 00:06:56,320 So no paragraph actually turned red. 143 00:06:56,320 --> 00:07:00,470 So again, the misconception is that this selector here 144 00:07:00,470 --> 00:07:03,048 should have selected the first p element 145 00:07:03,048 --> 00:07:05,210 inside of the article. 146 00:07:05,210 --> 00:07:08,070 And so this would be this one. 147 00:07:08,070 --> 00:07:08,930 Right? 148 00:07:08,930 --> 00:07:12,050 So as we just saw before this paragraph is in fact, 149 00:07:12,050 --> 00:07:15,230 the first paragraph inside of the article however, 150 00:07:15,230 --> 00:07:19,890 this is not how the first child pseudo class actually works. 151 00:07:19,890 --> 00:07:24,593 Instead, what CSS will do is to select a p element 152 00:07:24,593 --> 00:07:28,543 that is actually the first child of the article. 153 00:07:30,710 --> 00:07:32,070 Alright? 154 00:07:32,070 --> 00:07:35,430 So the p element is the first p element 155 00:07:35,430 --> 00:07:36,588 inside of the article, 156 00:07:36,588 --> 00:07:40,800 but it is not the first child of article. 157 00:07:40,800 --> 00:07:44,590 The first child of article is actually header. 158 00:07:44,590 --> 00:07:45,423 Right? 159 00:07:45,423 --> 00:07:47,110 It is not a paragraph. 160 00:07:47,110 --> 00:07:51,180 And so therefore this selector here does not work in a way 161 00:07:51,180 --> 00:07:53,810 that maybe we might think it would. 162 00:07:53,810 --> 00:07:55,790 So this would only work if a paragraph, 163 00:07:55,790 --> 00:08:00,314 would actually be to first element of the article. 164 00:08:00,314 --> 00:08:02,043 So let's do that. 165 00:08:04,380 --> 00:08:09,190 So if we save now then indeed we get some red paragraph. 166 00:08:09,190 --> 00:08:13,260 So now this paragraph is the first-child of the article. 167 00:08:13,260 --> 00:08:15,823 And so therefore now our selector applies. 168 00:08:18,200 --> 00:08:19,560 Alright? 169 00:08:19,560 --> 00:08:22,883 now let's see the end of our article. 170 00:08:24,630 --> 00:08:26,350 So it ends here 171 00:08:26,350 --> 00:08:29,125 and we can see that a paragraph is actually 172 00:08:29,125 --> 00:08:32,679 the last-child of the article element. 173 00:08:32,679 --> 00:08:33,659 Right? 174 00:08:33,659 --> 00:08:36,623 And so what would work is this. 175 00:08:39,610 --> 00:08:41,919 So let's see our result. 176 00:08:41,919 --> 00:08:44,680 And indeed, now this text is the red. 177 00:08:44,680 --> 00:08:46,460 And so it makes sense. 178 00:08:46,460 --> 00:08:47,670 Right? 179 00:08:47,670 --> 00:08:48,970 Again this worked 180 00:08:48,970 --> 00:08:52,970 because it is a p element inside of the article 181 00:08:52,970 --> 00:08:57,750 and it is indeed the last-child of that article. 182 00:08:57,750 --> 00:09:01,550 And so therefore this selector then applied 183 00:09:01,550 --> 00:09:04,690 and did exactly what it should do. 184 00:09:04,690 --> 00:09:07,560 So basically what this means is that 185 00:09:07,560 --> 00:09:11,381 when we mix multiple elements inside of a parent element, 186 00:09:11,381 --> 00:09:14,486 then the pseudo classes don't work really well. 187 00:09:14,486 --> 00:09:18,940 They are however perfect for situations like this one, 188 00:09:18,940 --> 00:09:22,150 where all the child elements are the same. 189 00:09:22,150 --> 00:09:26,020 So in a list like ul or ol all the child elements 190 00:09:26,020 --> 00:09:30,180 are supposed to be li and so the does pseudo class, 191 00:09:30,180 --> 00:09:35,180 like first-child, last-child or nth-child work perfectly. 192 00:09:35,947 --> 00:09:36,980 Alright. 193 00:09:36,980 --> 00:09:40,580 And this is how you work with these pseudo classes. 194 00:09:40,580 --> 00:09:43,435 Now, the pseudo classes that we just learned about 195 00:09:43,435 --> 00:09:48,380 are all about matching the existing HTML structure. 196 00:09:48,380 --> 00:09:52,170 However, there are also other types of pseudo classes. 197 00:09:52,170 --> 00:09:54,712 And so let's use some of them in the next video 198 00:09:54,712 --> 00:09:57,903 to finally style or hyperlinks. 13691

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.