All language subtitles for English (auto-generated)_en_0_HTML _ CSS Full Course - Beginner to Pro(1080P_60FPS)

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (SoranĂ®)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,240 --> 00:00:04,799 Welcome to the complete HTML and CSS 2 00:00:03,200 --> 00:00:06,400 course. In this course, we're going to 3 00:00:04,799 --> 00:00:09,040 learn how to build websites from a 4 00:00:06,400 --> 00:00:10,400 beginner to a professional level. And by 5 00:00:09,040 --> 00:00:12,719 the end of this course, we're going to 6 00:00:10,400 --> 00:00:14,559 build YouTube.com. 7 00:00:12,719 --> 00:00:17,039 Now, you don't need any previous coding 8 00:00:14,559 --> 00:00:18,720 or technical experience. This course is 9 00:00:17,039 --> 00:00:20,640 designed to be your first step to 10 00:00:18,720 --> 00:00:22,240 becoming a software engineer. We're 11 00:00:20,640 --> 00:00:25,519 going to start from the very basics of 12 00:00:22,240 --> 00:00:27,680 HTML and CSS and build our way up step 13 00:00:25,519 --> 00:00:29,439 by step. And along the way, we're going 14 00:00:27,680 --> 00:00:31,119 to learn all the major skills that we 15 00:00:29,439 --> 00:00:33,440 need to create websites at a 16 00:00:31,119 --> 00:00:35,200 professional level. You can find the 17 00:00:33,440 --> 00:00:38,320 different sections of this course below 18 00:00:35,200 --> 00:00:39,920 the video here and here. And after each 19 00:00:38,320 --> 00:00:42,160 section, I'm going to give you a bunch 20 00:00:39,920 --> 00:00:44,640 of exercises that you can do on your own 21 00:00:42,160 --> 00:00:46,559 to practice the skills that we learned. 22 00:00:44,640 --> 00:00:50,000 In total, this course is going to have 23 00:00:46,559 --> 00:00:51,520 more than 100 exercises. Lastly, you 24 00:00:50,000 --> 00:00:54,559 don't have to worry about taking notes. 25 00:00:51,520 --> 00:00:56,320 I created an HTML and CSS reference that 26 00:00:54,559 --> 00:00:58,480 will list everything that we learn in 27 00:00:56,320 --> 00:01:01,480 this course. With that said, let's get 28 00:00:58,480 --> 00:01:01,480 started. 29 00:01:04,640 --> 00:01:08,159 I'm going to be doing this course on a 30 00:01:06,159 --> 00:01:10,720 Mac, but everything is the same for a 31 00:01:08,159 --> 00:01:12,960 Windows computer. Before we begin, we're 32 00:01:10,720 --> 00:01:16,000 going to need two pieces of software. A 33 00:01:12,960 --> 00:01:17,840 web browser and a code editor. A web 34 00:01:16,000 --> 00:01:20,000 browser lets us view websites on the 35 00:01:17,840 --> 00:01:21,600 internet. It's also going to let us view 36 00:01:20,000 --> 00:01:23,920 the website that we create in this 37 00:01:21,600 --> 00:01:26,799 course. The most popular web browser for 38 00:01:23,920 --> 00:01:29,759 web development is Google Chrome. A code 39 00:01:26,799 --> 00:01:32,240 editor helps us write our HTML and CSS 40 00:01:29,759 --> 00:01:34,960 code. The most popular code editor for 41 00:01:32,240 --> 00:01:37,680 web development is called VS Code or 42 00:01:34,960 --> 00:01:40,560 Visual Studio Code. To install both of 43 00:01:37,680 --> 00:01:46,880 these, we can go to google.com and then 44 00:01:40,560 --> 00:01:49,439 search for Google Chrome or for VS Code 45 00:01:46,880 --> 00:01:51,520 and then open the first result and 46 00:01:49,439 --> 00:01:53,439 follow the instructions to download and 47 00:01:51,520 --> 00:01:55,360 install. 48 00:01:53,439 --> 00:01:57,920 Once we have those two installed, we can 49 00:01:55,360 --> 00:02:01,600 start the course. We'll begin by 50 00:01:57,920 --> 00:02:04,240 learning what is HTML. HTML stands for 51 00:02:01,600 --> 00:02:06,000 hypertext markup language. You don't 52 00:02:04,240 --> 00:02:07,680 have to worry about what that means. 53 00:02:06,000 --> 00:02:10,560 Just know that it's a tool that we use 54 00:02:07,680 --> 00:02:13,680 to create websites. Every website from 55 00:02:10,560 --> 00:02:16,959 YouTube to Google to Amazon uses a 56 00:02:13,680 --> 00:02:20,080 combination of HTML and CSS to create 57 00:02:16,959 --> 00:02:22,640 everything that we see on the website. 58 00:02:20,080 --> 00:02:24,640 The easiest way to understand what HTML 59 00:02:22,640 --> 00:02:27,440 is is that we're simply giving 60 00:02:24,640 --> 00:02:30,239 instructions to a computer. We're 61 00:02:27,440 --> 00:02:32,720 telling the computer what to do step by 62 00:02:30,239 --> 00:02:35,760 step. The computer will then follow our 63 00:02:32,720 --> 00:02:38,160 instructions to create our website. So, 64 00:02:35,760 --> 00:02:40,160 I find the best way to learn HTML is to 65 00:02:38,160 --> 00:02:42,640 jump in and give it a try. So, we're 66 00:02:40,160 --> 00:02:45,120 going to create our first HTML file and 67 00:02:42,640 --> 00:02:47,040 our first website. Let's go to our 68 00:02:45,120 --> 00:02:48,560 computer and we're going to create a new 69 00:02:47,040 --> 00:02:50,400 folder. 70 00:02:48,560 --> 00:02:52,879 So, this folder is going to contain all 71 00:02:50,400 --> 00:02:55,440 the code for this course. I'm going to 72 00:02:52,879 --> 00:02:58,440 call this HTML- 73 00:02:55,440 --> 00:02:58,440 CSS-course. 74 00:02:59,599 --> 00:03:03,840 Next, we're going to open this folder in 75 00:03:01,280 --> 00:03:07,319 our code editor. So, I'm going to open 76 00:03:03,840 --> 00:03:07,319 VS Code 77 00:03:08,239 --> 00:03:14,000 and then I'm going to click file, open, 78 00:03:12,159 --> 00:03:18,360 and I'm going to find the folder that we 79 00:03:14,000 --> 00:03:18,360 just created, which is this one. 80 00:03:19,599 --> 00:03:23,360 Now, once that's open, you should see 81 00:03:21,200 --> 00:03:25,680 the folder name at the top here and on 82 00:03:23,360 --> 00:03:28,800 the side here. 83 00:03:25,680 --> 00:03:30,799 Now, let's create our first HTML file. 84 00:03:28,800 --> 00:03:32,720 We're going to click this icon to create 85 00:03:30,799 --> 00:03:34,480 a new file. 86 00:03:32,720 --> 00:03:37,480 And we're going to call this file 87 00:03:34,480 --> 00:03:37,480 website.html. 88 00:03:38,159 --> 00:03:41,920 So we have to make sure that this file 89 00:03:39,840 --> 00:03:43,519 ends withhtml. 90 00:03:41,920 --> 00:03:46,080 This tells a computer that this file 91 00:03:43,519 --> 00:03:49,200 contains HTML code rather than just 92 00:03:46,080 --> 00:03:51,200 text. So as I mentioned HTML is 93 00:03:49,200 --> 00:03:53,360 basically some instructions you give to 94 00:03:51,200 --> 00:03:57,360 the computer. We're going to learn our 95 00:03:53,360 --> 00:03:59,200 first instruction which is less than 96 00:03:57,360 --> 00:04:01,760 button 97 00:03:59,200 --> 00:04:04,720 greater than. And we also need to type 98 00:04:01,760 --> 00:04:06,640 less than /button greater than but our 99 00:04:04,720 --> 00:04:09,840 code editor might autocomplete this for 100 00:04:06,640 --> 00:04:12,959 us. So this is an instruction to create 101 00:04:09,840 --> 00:04:16,239 a button. And inside the button we're 102 00:04:12,959 --> 00:04:18,160 going to have the text hello. 103 00:04:16,239 --> 00:04:19,840 Now let's save our file and we're going 104 00:04:18,160 --> 00:04:21,440 to learn how to open this in our web 105 00:04:19,840 --> 00:04:23,680 browser. 106 00:04:21,440 --> 00:04:26,320 To open our new website we're going to 107 00:04:23,680 --> 00:04:29,199 go to the folder that contains our code. 108 00:04:26,320 --> 00:04:30,960 We're going to find our HTML file. We're 109 00:04:29,199 --> 00:04:35,080 going to rightclick, 110 00:04:30,960 --> 00:04:35,080 open with Google Chrome. 111 00:04:35,680 --> 00:04:39,759 And now you can see that we have our 112 00:04:37,199 --> 00:04:42,400 first website that has a button with the 113 00:04:39,759 --> 00:04:44,880 text hello inside. And if we look back 114 00:04:42,400 --> 00:04:46,160 to our code, that's exactly the 115 00:04:44,880 --> 00:04:47,680 instruction that we gave to the 116 00:04:46,160 --> 00:04:49,840 computer. 117 00:04:47,680 --> 00:04:51,280 So, as you can see, HTML is pretty 118 00:04:49,840 --> 00:04:53,919 straightforward. It's pretty easy to 119 00:04:51,280 --> 00:04:55,759 understand what's going on. Now, let's 120 00:04:53,919 --> 00:04:58,240 try another instruction we can give to 121 00:04:55,759 --> 00:05:02,400 the computer. On a new line, we're going 122 00:04:58,240 --> 00:05:04,800 to type less than P greater than. And we 123 00:05:02,400 --> 00:05:06,479 also need to type less than /p greater 124 00:05:04,800 --> 00:05:09,360 than. And our code editor might 125 00:05:06,479 --> 00:05:11,919 autocomplete this for us, too. So the P 126 00:05:09,360 --> 00:05:14,880 here stands for a paragraph. This is a 127 00:05:11,919 --> 00:05:17,280 paragraph of text. Inside a paragraph, 128 00:05:14,880 --> 00:05:21,440 we can put some text. So let's put the 129 00:05:17,280 --> 00:05:24,320 text paragraph of text. Now we can save 130 00:05:21,440 --> 00:05:27,120 this. And to get our website to reflect 131 00:05:24,320 --> 00:05:29,759 our most current code, we're going to go 132 00:05:27,120 --> 00:05:31,840 to our web page and refresh. And now you 133 00:05:29,759 --> 00:05:34,240 can see that our website is displaying a 134 00:05:31,840 --> 00:05:37,120 paragraph of text just like we told the 135 00:05:34,240 --> 00:05:40,479 computer to do. So that's basically how 136 00:05:37,120 --> 00:05:43,680 HTML works. The computer reads our HTML 137 00:05:40,479 --> 00:05:47,039 code from top to bottom and then follows 138 00:05:43,680 --> 00:05:50,800 those instructions and creates a button 139 00:05:47,039 --> 00:05:54,160 and a paragraph of text. 140 00:05:50,800 --> 00:05:56,400 If we reverse the order of these lines, 141 00:05:54,160 --> 00:05:58,000 for example, if I put the paragraph up 142 00:05:56,400 --> 00:06:01,520 here 143 00:05:58,000 --> 00:06:04,080 and I save it and refresh the page, then 144 00:06:01,520 --> 00:06:05,919 the paragraph will appear on top because 145 00:06:04,080 --> 00:06:09,680 again the computer is just following our 146 00:06:05,919 --> 00:06:12,400 instructions one by one. Now I'm going 147 00:06:09,680 --> 00:06:14,240 to introduce some terminology. So each 148 00:06:12,400 --> 00:06:17,680 of these things that we're displaying on 149 00:06:14,240 --> 00:06:20,479 the web page is called an HTML element. 150 00:06:17,680 --> 00:06:23,199 So a button is a type of HTML element 151 00:06:20,479 --> 00:06:25,919 and a paragraph is another type of HTML 152 00:06:23,199 --> 00:06:28,160 element. So element is just a generic 153 00:06:25,919 --> 00:06:30,400 term that we use to describe anything 154 00:06:28,160 --> 00:06:31,600 that we can display on the web page. And 155 00:06:30,400 --> 00:06:34,560 we're going to be using this term 156 00:06:31,600 --> 00:06:36,400 element throughout this course. So now I 157 00:06:34,560 --> 00:06:38,800 want to explain why we have to write all 158 00:06:36,400 --> 00:06:41,680 of these symbols. This less than, this 159 00:06:38,800 --> 00:06:44,319 greater than, and this less than slash. 160 00:06:41,680 --> 00:06:46,400 This is something called syntax. Syntax 161 00:06:44,319 --> 00:06:48,880 are the rules for how a coding language 162 00:06:46,400 --> 00:06:51,039 like HTML should be written. If you 163 00:06:48,880 --> 00:06:52,880 think of a language like English, we 164 00:06:51,039 --> 00:06:55,280 have something called grammar, which is 165 00:06:52,880 --> 00:06:57,120 the rules of the language. Syntax is 166 00:06:55,280 --> 00:06:59,440 basically the same thing except for 167 00:06:57,120 --> 00:07:00,880 coding languages. Now, the biggest 168 00:06:59,440 --> 00:07:03,440 difference between a language like 169 00:07:00,880 --> 00:07:05,199 English and a coding language is that in 170 00:07:03,440 --> 00:07:07,360 English, you don't have to follow the 171 00:07:05,199 --> 00:07:09,440 rules of grammar perfectly. People can 172 00:07:07,360 --> 00:07:11,360 still understand you. But in a coding 173 00:07:09,440 --> 00:07:14,000 language, if you don't follow the rules 174 00:07:11,360 --> 00:07:17,039 of syntax, the computer won't understand 175 00:07:14,000 --> 00:07:19,919 your code. For example, let's break the 176 00:07:17,039 --> 00:07:21,759 rules of syntax by deleting this greater 177 00:07:19,919 --> 00:07:23,840 than symbol. 178 00:07:21,759 --> 00:07:25,199 And now we're going to save our file and 179 00:07:23,840 --> 00:07:27,599 we're going to go to our website and 180 00:07:25,199 --> 00:07:30,080 refresh. And now you notice that our 181 00:07:27,599 --> 00:07:32,240 button is gone. And that's because we're 182 00:07:30,080 --> 00:07:34,800 not following the proper syntax. So the 183 00:07:32,240 --> 00:07:36,800 computer doesn't understand our HTML 184 00:07:34,800 --> 00:07:38,639 code anymore. 185 00:07:36,800 --> 00:07:40,160 So let's put that greater sign back so 186 00:07:38,639 --> 00:07:43,919 that we're following the proper rules of 187 00:07:40,160 --> 00:07:46,639 syntax and we don't need this. So let's 188 00:07:43,919 --> 00:07:48,319 save and refresh our page. And now our 189 00:07:46,639 --> 00:07:50,720 button is back because we're following 190 00:07:48,319 --> 00:07:53,120 the rules of syntax. 191 00:07:50,720 --> 00:07:54,639 So what exactly are the syntax rules for 192 00:07:53,120 --> 00:07:56,720 HTML? 193 00:07:54,639 --> 00:07:59,759 So this part of the code is called an 194 00:07:56,720 --> 00:08:02,319 HTML tag. It basically tells a computer 195 00:07:59,759 --> 00:08:04,879 what we're trying to create. We write a 196 00:08:02,319 --> 00:08:06,960 tag by writing the less than symbol. 197 00:08:04,879 --> 00:08:08,400 This is the tag name which tells the 198 00:08:06,960 --> 00:08:10,319 computer what kind of element we're 199 00:08:08,400 --> 00:08:13,199 trying to create and then the greater 200 00:08:10,319 --> 00:08:16,639 than symbol. So every element consists 201 00:08:13,199 --> 00:08:19,360 of two tags, an opening tag and a 202 00:08:16,639 --> 00:08:22,080 closing tag. The closing tag is the same 203 00:08:19,360 --> 00:08:24,080 as the opening tag except it has a slash 204 00:08:22,080 --> 00:08:27,360 in front of the tag name. That's how you 205 00:08:24,080 --> 00:08:29,599 can tell it is a closing tag. 206 00:08:27,360 --> 00:08:31,840 You can think of the opening tag as the 207 00:08:29,599 --> 00:08:34,159 start of the button and the closing tag 208 00:08:31,840 --> 00:08:36,080 as the end of the button. And then in 209 00:08:34,159 --> 00:08:38,640 between is the content or the text 210 00:08:36,080 --> 00:08:40,479 inside the button. 211 00:08:38,640 --> 00:08:42,959 And the same thing for the paragraph. 212 00:08:40,479 --> 00:08:45,440 The paragraph has an opening tag, a 213 00:08:42,959 --> 00:08:47,120 closing tag, and some content inside the 214 00:08:45,440 --> 00:08:48,959 paragraph. 215 00:08:47,120 --> 00:08:51,680 So, as long as we follow these syntax 216 00:08:48,959 --> 00:08:54,000 rules for HTML, we have an opening tag 217 00:08:51,680 --> 00:08:55,839 and a closing tag. And the closing tag 218 00:08:54,000 --> 00:08:58,240 starts with a slash in front of the tag 219 00:08:55,839 --> 00:09:00,959 name, then our computer will know what 220 00:08:58,240 --> 00:09:02,720 to do and display our elements on our 221 00:09:00,959 --> 00:09:03,920 web page. 222 00:09:02,720 --> 00:09:06,880 The next element that we're going to 223 00:09:03,920 --> 00:09:09,360 learn is a link to another website. For 224 00:09:06,880 --> 00:09:12,080 example, if we go to Google and we 225 00:09:09,360 --> 00:09:13,760 search for something on Google, it will 226 00:09:12,080 --> 00:09:15,760 give us a bunch of links. And when we 227 00:09:13,760 --> 00:09:17,600 click these links, it will take us to 228 00:09:15,760 --> 00:09:20,480 another website. So, we're going to 229 00:09:17,600 --> 00:09:22,720 learn how to do that in our HTML code. 230 00:09:20,480 --> 00:09:24,800 So, we'll go back to our website here. 231 00:09:22,720 --> 00:09:28,560 And in our code, we're going to type 232 00:09:24,800 --> 00:09:31,360 less than a greater than. 233 00:09:28,560 --> 00:09:33,839 So this A here represents an anchor 234 00:09:31,360 --> 00:09:36,000 element. An anchor is basically a link 235 00:09:33,839 --> 00:09:38,959 to another website. 236 00:09:36,000 --> 00:09:41,519 So inside this anchor, we're going to 237 00:09:38,959 --> 00:09:45,920 put the text of our link. So let's put 238 00:09:41,519 --> 00:09:47,760 the text as link to YouTube. 239 00:09:45,920 --> 00:09:51,120 We're going to save this and then 240 00:09:47,760 --> 00:09:52,720 refresh. And now we have a link. But if 241 00:09:51,120 --> 00:09:55,200 we click this, it doesn't actually take 242 00:09:52,720 --> 00:09:57,519 us to YouTube. And that's because we 243 00:09:55,200 --> 00:09:59,760 haven't told the computer where this 244 00:09:57,519 --> 00:10:01,120 link is supposed to take us. Right now, 245 00:09:59,760 --> 00:10:04,320 we just have a link without a 246 00:10:01,120 --> 00:10:06,560 destination. So to set a website to link 247 00:10:04,320 --> 00:10:09,360 to, we have to learn a little bit more 248 00:10:06,560 --> 00:10:11,839 HTML syntax. So we're going to go into 249 00:10:09,360 --> 00:10:16,399 the opening tag and we're going to type 250 00:10:11,839 --> 00:10:18,160 space href equals double quotes double 251 00:10:16,399 --> 00:10:19,839 quotes. 252 00:10:18,160 --> 00:10:23,200 So inside these quotes, we're going to 253 00:10:19,839 --> 00:10:25,680 copy and paste YouTube's website URL. So 254 00:10:23,200 --> 00:10:29,040 to get that, we can go to our web page 255 00:10:25,680 --> 00:10:32,079 and then type in youtube.com 256 00:10:29,040 --> 00:10:35,519 and at the top here we have the URL. So 257 00:10:32,079 --> 00:10:37,839 we're going to copy this and paste this 258 00:10:35,519 --> 00:10:41,040 into our quotes. 259 00:10:37,839 --> 00:10:43,440 And now we're going to save our file. 260 00:10:41,040 --> 00:10:45,279 We're going to go back to our website 261 00:10:43,440 --> 00:10:47,040 and refresh. 262 00:10:45,279 --> 00:10:49,920 And now we have a link that we can 263 00:10:47,040 --> 00:10:52,800 click. So when we click this link, it's 264 00:10:49,920 --> 00:10:54,480 now going to take us to youtube.com. So 265 00:10:52,800 --> 00:10:58,000 that's how we create a link to another 266 00:10:54,480 --> 00:11:00,000 website with HTML. 267 00:10:58,000 --> 00:11:03,120 Now let's go back here and explain what 268 00:11:00,000 --> 00:11:05,760 this syntax means. So this is called an 269 00:11:03,120 --> 00:11:08,640 HTML attribute. An attribute basically 270 00:11:05,760 --> 00:11:11,440 modifies how an element behaves. In this 271 00:11:08,640 --> 00:11:13,360 example, we're using the href attribute 272 00:11:11,440 --> 00:11:15,680 and it determines where this link 273 00:11:13,360 --> 00:11:17,920 element will take us when we click it. 274 00:11:15,680 --> 00:11:19,680 Right now it's going to youtube.com, but 275 00:11:17,920 --> 00:11:21,920 if we change this, it will take us to a 276 00:11:19,680 --> 00:11:25,600 different website. So this attribute is 277 00:11:21,920 --> 00:11:28,640 modifying how the link element behaves. 278 00:11:25,600 --> 00:11:30,720 So the syntax rules for an attribute are 279 00:11:28,640 --> 00:11:33,200 we have to have a space between the 280 00:11:30,720 --> 00:11:36,079 attribute and the tag name. Otherwise if 281 00:11:33,200 --> 00:11:37,760 I write href here, the browser is just 282 00:11:36,079 --> 00:11:39,760 going to think that this whole thing is 283 00:11:37,760 --> 00:11:42,160 a tag name. So that's why we have to 284 00:11:39,760 --> 00:11:45,920 have a space. So then we're going to 285 00:11:42,160 --> 00:11:48,320 have an equal sign and double quotes. So 286 00:11:45,920 --> 00:11:51,120 the text to the left of the equal sign 287 00:11:48,320 --> 00:11:54,399 is known as the attribute name and on 288 00:11:51,120 --> 00:11:56,959 the right side is the value. The value 289 00:11:54,399 --> 00:11:59,279 must be surrounded by double quotes as 290 00:11:56,959 --> 00:12:01,440 you can see here. So you can kind of 291 00:11:59,279 --> 00:12:03,920 think of it like this. The name tells us 292 00:12:01,440 --> 00:12:07,200 what we're modifying. The value tells us 293 00:12:03,920 --> 00:12:08,959 what we are modifying it to. So the href 294 00:12:07,200 --> 00:12:12,079 tells us we're modifying the destination 295 00:12:08,959 --> 00:12:14,880 of this link and we're modifying it to 296 00:12:12,079 --> 00:12:17,200 youtube.com. 297 00:12:14,880 --> 00:12:19,680 We can also have multiple attributes on 298 00:12:17,200 --> 00:12:22,639 an element. To add another attribute, we 299 00:12:19,680 --> 00:12:24,079 just separate it with a space like this. 300 00:12:22,639 --> 00:12:26,399 And now we're going to add another 301 00:12:24,079 --> 00:12:29,360 attribute to our link element. And this 302 00:12:26,399 --> 00:12:31,279 one is called target. 303 00:12:29,360 --> 00:12:33,200 So the target attribute determines 304 00:12:31,279 --> 00:12:36,320 whether this link opens in the current 305 00:12:33,200 --> 00:12:38,320 page or in a new tab. So by default, if 306 00:12:36,320 --> 00:12:43,240 we don't have a target attribute, it 307 00:12:38,320 --> 00:12:43,240 opens in the current page like this. 308 00:12:44,320 --> 00:12:49,600 But if we set the target attribute to 309 00:12:46,480 --> 00:12:52,000 underscore blank, now this link element 310 00:12:49,600 --> 00:12:54,720 will open in a new tab. So let's go to 311 00:12:52,000 --> 00:12:56,880 our web page and refresh and click this 312 00:12:54,720 --> 00:12:59,440 link. YouTube will now open in a new 313 00:12:56,880 --> 00:13:02,079 tab. 314 00:12:59,440 --> 00:13:03,680 So by using attributes, we can modify 315 00:13:02,079 --> 00:13:06,720 different parts of this element's 316 00:13:03,680 --> 00:13:09,200 behavior. The href attribute modifies 317 00:13:06,720 --> 00:13:11,440 where this link goes and the target 318 00:13:09,200 --> 00:13:13,440 attribute modifies whether this link 319 00:13:11,440 --> 00:13:16,480 opens in a new tab or in the current 320 00:13:13,440 --> 00:13:19,040 page. Keep in mind that the href and 321 00:13:16,480 --> 00:13:21,519 target attribute only work on the link 322 00:13:19,040 --> 00:13:23,040 element. The button and the paragraph 323 00:13:21,519 --> 00:13:24,880 elements have their own set of 324 00:13:23,040 --> 00:13:26,480 attributes that we can modify and we're 325 00:13:24,880 --> 00:13:28,480 going to learn these later on in the 326 00:13:26,480 --> 00:13:30,480 course. But for now, I just wanted to 327 00:13:28,480 --> 00:13:35,839 introduce you to the idea of using 328 00:13:30,480 --> 00:13:37,200 attributes to modify our HTML elements. 329 00:13:35,839 --> 00:13:39,279 The last thing we're going to learn in 330 00:13:37,200 --> 00:13:42,079 this lesson is some weird quirks of the 331 00:13:39,279 --> 00:13:44,399 HTML syntax. So, something that a lot of 332 00:13:42,079 --> 00:13:46,880 beginners have trouble with is that in 333 00:13:44,399 --> 00:13:49,440 HTML, if you have multiple spaces like 334 00:13:46,880 --> 00:13:52,240 this, for example, if we save this file 335 00:13:49,440 --> 00:13:54,800 and we reload, you'll notice that all of 336 00:13:52,240 --> 00:13:56,639 these spaces just appear as one space on 337 00:13:54,800 --> 00:13:59,279 the website. And that's because 338 00:13:56,639 --> 00:14:02,399 according to the syntax, extra spaces 339 00:13:59,279 --> 00:14:04,079 are essentially ignored. 340 00:14:02,399 --> 00:14:06,399 So beginners usually have trouble with 341 00:14:04,079 --> 00:14:08,800 this because for example if they want to 342 00:14:06,399 --> 00:14:12,079 add space between this button and this 343 00:14:08,800 --> 00:14:14,480 link they would start adding spaces in 344 00:14:12,079 --> 00:14:16,560 front of the link thinking that it will 345 00:14:14,480 --> 00:14:19,760 move it away from the button. So if we 346 00:14:16,560 --> 00:14:21,360 save this and we refresh nothing happens 347 00:14:19,760 --> 00:14:25,760 and that's because all of these spaces 348 00:14:21,360 --> 00:14:27,279 are essentially ignored in HTML. 349 00:14:25,760 --> 00:14:29,199 So later in the course we're going to 350 00:14:27,279 --> 00:14:31,760 learn how to deal with these situations 351 00:14:29,199 --> 00:14:33,680 but for now just keep this in mind. 352 00:14:31,760 --> 00:14:35,600 So, let's get rid of these extra spaces 353 00:14:33,680 --> 00:14:37,920 for now. 354 00:14:35,600 --> 00:14:42,160 And another weird quirk of this syntax 355 00:14:37,920 --> 00:14:44,560 rule is that if I put my cursor here and 356 00:14:42,160 --> 00:14:46,959 I press enter to create a new line and I 357 00:14:44,560 --> 00:14:49,360 put my cursor here again, these new 358 00:14:46,959 --> 00:14:53,040 lines also count as spaces. So, the 359 00:14:49,360 --> 00:14:55,440 browser essentially ignores them. 360 00:14:53,040 --> 00:14:56,959 If I save the file and reload, you'll 361 00:14:55,440 --> 00:14:58,959 see that the new line doesn't do 362 00:14:56,959 --> 00:15:01,279 anything. 363 00:14:58,959 --> 00:15:04,480 So this actually makes organizing our 364 00:15:01,279 --> 00:15:06,399 HTML code very flexible. For example, if 365 00:15:04,480 --> 00:15:08,560 I wanted some more space between these 366 00:15:06,399 --> 00:15:11,120 elements so that it's easier to read in 367 00:15:08,560 --> 00:15:13,839 my code, I can just add as much spaces 368 00:15:11,120 --> 00:15:16,079 as I want and it won't get reflected in 369 00:15:13,839 --> 00:15:19,519 the website because extra spaces like 370 00:15:16,079 --> 00:15:22,240 these new lines are just ignored. 371 00:15:19,519 --> 00:15:25,279 A lot of people like to put the content 372 00:15:22,240 --> 00:15:28,240 of the element on its own line like this 373 00:15:25,279 --> 00:15:31,440 so that the tags basically align with 374 00:15:28,240 --> 00:15:33,519 each other in the same column. And same 375 00:15:31,440 --> 00:15:36,160 thing for here. You'll notice that this 376 00:15:33,519 --> 00:15:38,880 line is really long. We can actually add 377 00:15:36,160 --> 00:15:41,600 new lines here to make our code easier 378 00:15:38,880 --> 00:15:44,240 to read. So when we organize our code 379 00:15:41,600 --> 00:15:46,720 like this, we generally indent or add 380 00:15:44,240 --> 00:15:48,399 spaces in front of these lines. This 381 00:15:46,720 --> 00:15:50,320 helps us clearly tell the difference 382 00:15:48,399 --> 00:15:52,399 between the element's tags and its 383 00:15:50,320 --> 00:15:54,800 contents. If we didn't have this 384 00:15:52,399 --> 00:15:56,880 indenting, then it's pretty hard to tell 385 00:15:54,800 --> 00:15:59,120 where this element starts and where it 386 00:15:56,880 --> 00:16:02,240 ends, especially when we have a lot of 387 00:15:59,120 --> 00:16:03,839 code. Now, your indents might look a 388 00:16:02,240 --> 00:16:05,920 little different from mine. It might 389 00:16:03,839 --> 00:16:08,800 look something like this, where you have 390 00:16:05,920 --> 00:16:11,839 more spaces than I do. This happens 391 00:16:08,800 --> 00:16:15,120 because by default, VS Code uses four 392 00:16:11,839 --> 00:16:18,800 spaces per indent. Generally in HTML and 393 00:16:15,120 --> 00:16:20,399 CSS, we use two spaces per indent. To 394 00:16:18,800 --> 00:16:22,639 update this, we're going to go down to 395 00:16:20,399 --> 00:16:25,199 this bottom toolbar and click this 396 00:16:22,639 --> 00:16:28,000 section. And then we're going to click 397 00:16:25,199 --> 00:16:31,360 indent using spaces. And we'll change 398 00:16:28,000 --> 00:16:33,680 this from four to two. So now this file 399 00:16:31,360 --> 00:16:36,320 is going to use two spaces per indent. 400 00:16:33,680 --> 00:16:40,360 So we can get rid of this and press tab 401 00:16:36,320 --> 00:16:40,360 to have proper indenting. 402 00:16:40,399 --> 00:16:44,639 Now, that only affects it for the 403 00:16:42,160 --> 00:16:46,560 current file. We can change it for every 404 00:16:44,639 --> 00:16:49,279 file going forward by going to the 405 00:16:46,560 --> 00:16:52,240 bottom left here and clicking this icon 406 00:16:49,279 --> 00:16:54,480 and then going into settings. 407 00:16:52,240 --> 00:16:56,639 And in here, we're going to search for 408 00:16:54,480 --> 00:16:58,399 tab size. 409 00:16:56,639 --> 00:17:03,759 And we're going to scroll down and we'll 410 00:16:58,399 --> 00:17:05,199 change the tab size from 4 to two. 411 00:17:03,759 --> 00:17:08,799 All right. So, we just learned the 412 00:17:05,199 --> 00:17:11,679 basics of HTML, how to write HTML code 413 00:17:08,799 --> 00:17:13,600 and then turn that into a website. We 414 00:17:11,679 --> 00:17:16,160 also learned how to write HTML 415 00:17:13,600 --> 00:17:19,199 attributes which modify the behavior of 416 00:17:16,160 --> 00:17:20,799 an element. And we learned about syntax, 417 00:17:19,199 --> 00:17:25,039 which are the rules that we had to 418 00:17:20,799 --> 00:17:26,799 follow when writing our code. 419 00:17:25,039 --> 00:17:28,720 Here are some exercises that you can try 420 00:17:26,799 --> 00:17:31,039 on your own to practice what we learned 421 00:17:28,720 --> 00:17:33,440 in this lesson. Feel free to pause the 422 00:17:31,039 --> 00:17:35,120 video here if you need to. You can find 423 00:17:33,440 --> 00:17:38,080 these solutions as well as more 424 00:17:35,120 --> 00:17:42,280 exercises on my website supersimple.dev. 425 00:17:38,080 --> 00:17:42,280 The link is below the video. 426 00:17:50,880 --> 00:17:56,080 In this lesson, we're going to learn CSS 427 00:17:53,120 --> 00:17:58,559 or cascading stylesheets. Based on the 428 00:17:56,080 --> 00:18:00,720 name, it's used to style our web page. 429 00:17:58,559 --> 00:18:04,000 So it's used to change the appearance of 430 00:18:00,720 --> 00:18:05,840 our HTML elements. 431 00:18:04,000 --> 00:18:07,840 So I've actually prepared a project that 432 00:18:05,840 --> 00:18:11,760 we can do in this lesson. So we're going 433 00:18:07,840 --> 00:18:14,559 to open this project by going to super 434 00:18:11,760 --> 00:18:17,559 simple.dev/ex 435 00:18:14,559 --> 00:18:17,559 exercises/buttons. 436 00:18:20,480 --> 00:18:24,240 So on this web page, I have some really 437 00:18:22,720 --> 00:18:26,720 nice looking buttons from famous 438 00:18:24,240 --> 00:18:29,440 websites, namely YouTube and Twitter, 439 00:18:26,720 --> 00:18:32,000 that we can copy and practice our CSS 440 00:18:29,440 --> 00:18:34,000 with. So we're going to go into our code 441 00:18:32,000 --> 00:18:37,039 and we're actually going to create a new 442 00:18:34,000 --> 00:18:39,200 file for this exercise. So let's create 443 00:18:37,039 --> 00:18:42,200 a new file and let's call it 444 00:18:39,200 --> 00:18:42,200 buttons.html. 445 00:18:43,919 --> 00:18:48,640 And we're going to open our new HTML 446 00:18:46,080 --> 00:18:50,799 file in our browser. So, let's open the 447 00:18:48,640 --> 00:18:53,600 folder that contains our code. We're 448 00:18:50,799 --> 00:18:56,600 going to rightclick, open with Google 449 00:18:53,600 --> 00:18:56,600 Chrome. 450 00:18:56,640 --> 00:19:01,520 And now I'm going to set this up by 451 00:18:58,960 --> 00:19:03,600 moving our reference design to the 452 00:19:01,520 --> 00:19:07,280 bottom like this so that it's easier for 453 00:19:03,600 --> 00:19:08,480 us to copy it with CSS. 454 00:19:07,280 --> 00:19:13,120 I'm just going to move that to the 455 00:19:08,480 --> 00:19:15,200 corner and then we can work here. 456 00:19:13,120 --> 00:19:17,600 So, first let's work on creating the 457 00:19:15,200 --> 00:19:19,120 subscribe button. So just like we 458 00:19:17,600 --> 00:19:21,760 learned before, we're going to create a 459 00:19:19,120 --> 00:19:26,080 button using HTML. 460 00:19:21,760 --> 00:19:27,440 So less than button greater than. And 461 00:19:26,080 --> 00:19:31,799 then inside our button, we're going to 462 00:19:27,440 --> 00:19:31,799 have the text subscribe. 463 00:19:32,320 --> 00:19:38,080 And now let's save and refresh our page. 464 00:19:35,280 --> 00:19:39,600 And now we have our button. 465 00:19:38,080 --> 00:19:41,360 Next, we're going to start changing the 466 00:19:39,600 --> 00:19:43,120 appearance of this button so that it 467 00:19:41,360 --> 00:19:45,520 looks like the subscribe button from 468 00:19:43,120 --> 00:19:46,880 YouTube. 469 00:19:45,520 --> 00:19:49,280 Let's go into our code and we're going 470 00:19:46,880 --> 00:19:52,960 to start writing some CSS to change the 471 00:19:49,280 --> 00:19:55,200 appearance of this HTML element. 472 00:19:52,960 --> 00:20:00,160 So to write CSS, we have to create a new 473 00:19:55,200 --> 00:20:02,400 element called a style element. 474 00:20:00,160 --> 00:20:04,960 So this style element is unique in that 475 00:20:02,400 --> 00:20:07,600 it doesn't appear visibly on the page. 476 00:20:04,960 --> 00:20:09,760 So for example, if we save our file and 477 00:20:07,600 --> 00:20:11,360 then we reload the page, the style 478 00:20:09,760 --> 00:20:13,679 element doesn't actually create 479 00:20:11,360 --> 00:20:15,840 anything. 480 00:20:13,679 --> 00:20:18,320 So the purpose of this element is that 481 00:20:15,840 --> 00:20:20,480 inside this element we can write CSS 482 00:20:18,320 --> 00:20:22,799 code which modifies the appearance of 483 00:20:20,480 --> 00:20:24,880 other elements. 484 00:20:22,799 --> 00:20:29,600 For example, let's write our first bit 485 00:20:24,880 --> 00:20:31,760 of CSS code. We're going to type button 486 00:20:29,600 --> 00:20:34,480 open squiggly bracket close squiggly 487 00:20:31,760 --> 00:20:36,480 bracket. 488 00:20:34,480 --> 00:20:38,159 And then inside these brackets, we're 489 00:20:36,480 --> 00:20:40,559 basically going to give instructions to 490 00:20:38,159 --> 00:20:43,760 the computer on how to modify the 491 00:20:40,559 --> 00:20:48,960 appearance. For example, we can set the 492 00:20:43,760 --> 00:20:50,880 background dash color colon red and 493 00:20:48,960 --> 00:20:52,880 semicolon. 494 00:20:50,880 --> 00:20:55,200 So, make sure that you write this out 495 00:20:52,880 --> 00:20:58,480 exactly as I have it here so that we're 496 00:20:55,200 --> 00:21:00,799 following the syntax rules for CSS. So, 497 00:20:58,480 --> 00:21:02,880 let's save this file and refresh our 498 00:21:00,799 --> 00:21:04,880 page. And now you can see that we set 499 00:21:02,880 --> 00:21:06,400 the background color of the button to 500 00:21:04,880 --> 00:21:09,039 red. 501 00:21:06,400 --> 00:21:11,919 So, as you can see, CSS is similar to 502 00:21:09,039 --> 00:21:14,000 HTML. We're simply giving instructions 503 00:21:11,919 --> 00:21:17,440 to the computer and then the computer 504 00:21:14,000 --> 00:21:19,679 follows our instructions step by step. 505 00:21:17,440 --> 00:21:22,240 And just like HTML, we have to follow 506 00:21:19,679 --> 00:21:25,039 certain syntax rules when writing our 507 00:21:22,240 --> 00:21:26,640 CSS so that the computer understands our 508 00:21:25,039 --> 00:21:29,440 code. 509 00:21:26,640 --> 00:21:32,080 So what are the syntax rules for CSS? 510 00:21:29,440 --> 00:21:33,840 How does this code work? 511 00:21:32,080 --> 00:21:36,960 So the word at the front here is called 512 00:21:33,840 --> 00:21:39,200 a CSS selector. It tells the computer 513 00:21:36,960 --> 00:21:42,000 which elements on the page we are 514 00:21:39,200 --> 00:21:43,919 targeting with our CSS code. In this 515 00:21:42,000 --> 00:21:45,600 case, we are targeting all buttons on 516 00:21:43,919 --> 00:21:47,440 the page. And we're going to change the 517 00:21:45,600 --> 00:21:50,400 background color of all buttons on the 518 00:21:47,440 --> 00:21:52,240 page to red. 519 00:21:50,400 --> 00:21:54,960 Now, inside these brackets, there are 520 00:21:52,240 --> 00:21:57,280 other rules that we have to follow. The 521 00:21:54,960 --> 00:22:00,080 text to the left of this colon is called 522 00:21:57,280 --> 00:22:02,960 the CSS property. It tells the computer 523 00:22:00,080 --> 00:22:06,480 what we are changing. To the right of 524 00:22:02,960 --> 00:22:08,159 the colon is the CSS value. It tells the 525 00:22:06,480 --> 00:22:10,559 computer what we're changing the 526 00:22:08,159 --> 00:22:12,799 property to. In this case, we're 527 00:22:10,559 --> 00:22:15,039 changing the property background color 528 00:22:12,799 --> 00:22:17,919 to red. And that's exactly what the 529 00:22:15,039 --> 00:22:20,720 computer did. The colon is here to just 530 00:22:17,919 --> 00:22:23,200 separate the property and the value. And 531 00:22:20,720 --> 00:22:25,280 the semicolon here is just like a period 532 00:22:23,200 --> 00:22:28,640 in English. In English, you end 533 00:22:25,280 --> 00:22:32,159 sentences with a period. In CSS, you end 534 00:22:28,640 --> 00:22:35,440 a style with a semicolon. So that's what 535 00:22:32,159 --> 00:22:37,840 all of this syntax means. 536 00:22:35,440 --> 00:22:40,159 So we can actually add multiple styles 537 00:22:37,840 --> 00:22:41,600 inside these brackets. So let's go ahead 538 00:22:40,159 --> 00:22:44,240 and add another style. We're going to 539 00:22:41,600 --> 00:22:46,799 change the text color to white to match 540 00:22:44,240 --> 00:22:48,960 this design. So the property for 541 00:22:46,799 --> 00:22:51,440 changing the text color, it's called 542 00:22:48,960 --> 00:22:53,200 color. So notice that it's not called 543 00:22:51,440 --> 00:22:55,120 text color. It's just something that we 544 00:22:53,200 --> 00:22:57,840 have to remember. 545 00:22:55,120 --> 00:23:00,159 We're going to change it to white. And 546 00:22:57,840 --> 00:23:03,440 we'll end it with a semicolon. Let's 547 00:23:00,159 --> 00:23:05,280 save. and refresh. And now you can see 548 00:23:03,440 --> 00:23:07,679 that we change the text color of this 549 00:23:05,280 --> 00:23:10,480 button to white. 550 00:23:07,679 --> 00:23:12,559 And that's basically how CSS works. We 551 00:23:10,480 --> 00:23:14,559 tell the computer what we're targeting 552 00:23:12,559 --> 00:23:17,200 and then we give some styles. And the 553 00:23:14,559 --> 00:23:20,000 computer is going to apply these styles 554 00:23:17,200 --> 00:23:22,400 one by one. 555 00:23:20,000 --> 00:23:25,120 So let's do another example. This time 556 00:23:22,400 --> 00:23:26,960 we'll set the border property. So notice 557 00:23:25,120 --> 00:23:28,720 that our button has a border while the 558 00:23:26,960 --> 00:23:31,600 subscribe button here doesn't have a 559 00:23:28,720 --> 00:23:34,559 border. So, we're going to set the 560 00:23:31,600 --> 00:23:37,520 border property 561 00:23:34,559 --> 00:23:39,600 colon to none. 562 00:23:37,520 --> 00:23:42,159 And we're going to save this file and 563 00:23:39,600 --> 00:23:44,480 refresh. And now we just remove the 564 00:23:42,159 --> 00:23:45,760 border. So, if you look at our styles 565 00:23:44,480 --> 00:23:47,360 here, it's actually pretty 566 00:23:45,760 --> 00:23:49,200 straightforward. They're pretty easy to 567 00:23:47,360 --> 00:23:51,919 read. We set the background color to 568 00:23:49,200 --> 00:23:55,360 red, text color to white, and border to 569 00:23:51,919 --> 00:23:56,880 none. So, just like HTML, CSS is pretty 570 00:23:55,360 --> 00:24:00,240 straightforward. We're essentially just 571 00:23:56,880 --> 00:24:03,039 giving the computer instructions. 572 00:24:00,240 --> 00:24:04,720 So the general technique for going from 573 00:24:03,039 --> 00:24:07,200 something that looks like this to 574 00:24:04,720 --> 00:24:10,000 something that looks like this is to 575 00:24:07,200 --> 00:24:11,440 just change the styles one by one. So 576 00:24:10,000 --> 00:24:14,960 we're going to continue changing styles 577 00:24:11,440 --> 00:24:17,039 one by one until we get our design here. 578 00:24:14,960 --> 00:24:19,039 The next style I'm going to change is 579 00:24:17,039 --> 00:24:22,000 the height. So our button is a little 580 00:24:19,039 --> 00:24:24,640 bit short. I'm going to make it taller. 581 00:24:22,000 --> 00:24:28,240 So, I'm going to set the height to 582 00:24:24,640 --> 00:24:31,279 something like 50 px. 583 00:24:28,240 --> 00:24:33,279 The px here represents pixels. Pixels 584 00:24:31,279 --> 00:24:35,520 are a very common unit of measurement in 585 00:24:33,279 --> 00:24:37,679 the digital world. Image sizes are 586 00:24:35,520 --> 00:24:39,919 measured in pixels. Video sizes are 587 00:24:37,679 --> 00:24:42,799 measured in pixels. And your screen size 588 00:24:39,919 --> 00:24:44,240 is also measured in pixels. 589 00:24:42,799 --> 00:24:46,640 In this case, we're going to set the 590 00:24:44,240 --> 00:24:48,400 button height to 50 pixels. And don't 591 00:24:46,640 --> 00:24:50,159 worry too much about knowing what 50 592 00:24:48,400 --> 00:24:52,559 pixels looks like. The more that you 593 00:24:50,159 --> 00:24:54,240 write CSS and work with pixels, the more 594 00:24:52,559 --> 00:24:56,960 you get a sense for how big these 595 00:24:54,240 --> 00:24:59,919 measurements turn out to be. So, for 596 00:24:56,960 --> 00:25:02,559 now, let's save this file and refresh 597 00:24:59,919 --> 00:25:04,880 the page. And now we have a button that 598 00:25:02,559 --> 00:25:06,640 is 50 pixels tall, but it actually looks 599 00:25:04,880 --> 00:25:08,640 like it's a little too tall. So, I'm 600 00:25:06,640 --> 00:25:11,679 going to change the height to something 601 00:25:08,640 --> 00:25:14,400 like 30 pixels. And we're going to 602 00:25:11,679 --> 00:25:16,159 refresh the page again. And I actually 603 00:25:14,400 --> 00:25:20,000 want it to be a little bit taller. So, 604 00:25:16,159 --> 00:25:21,919 I'm going to change it to maybe 36. 605 00:25:20,000 --> 00:25:23,679 I'm going to refresh. 606 00:25:21,919 --> 00:25:26,640 And I think that looks pretty good to 607 00:25:23,679 --> 00:25:28,320 me. So you see that in CSS we do a lot 608 00:25:26,640 --> 00:25:30,559 of trial and error to get our 609 00:25:28,320 --> 00:25:32,559 measurements right. 610 00:25:30,559 --> 00:25:35,520 Now let's keep working step by step to 611 00:25:32,559 --> 00:25:37,919 get to our design. Next we're going to 612 00:25:35,520 --> 00:25:40,159 adjust the width. 613 00:25:37,919 --> 00:25:43,120 So let's change this to something like 614 00:25:40,159 --> 00:25:46,480 100 pixels. Let's see how that looks. 615 00:25:43,120 --> 00:25:48,880 Going to save it. Refresh. 616 00:25:46,480 --> 00:25:50,880 And I think it looks a little bit too 617 00:25:48,880 --> 00:25:54,400 small. So I'm going to increase it just 618 00:25:50,880 --> 00:25:56,640 a little bit. 105. 619 00:25:54,400 --> 00:25:59,039 And refresh. Okay, I think that looks 620 00:25:56,640 --> 00:26:00,080 good enough for me. 621 00:25:59,039 --> 00:26:02,000 Next, we're going to change the 622 00:26:00,080 --> 00:26:05,039 background color because currently our 623 00:26:02,000 --> 00:26:07,039 red is not the same as our design. So VS 624 00:26:05,039 --> 00:26:09,919 Code has a really nice feature, which is 625 00:26:07,039 --> 00:26:12,799 a color picker. So if we hover over this 626 00:26:09,919 --> 00:26:15,039 color box here, it gives us access to a 627 00:26:12,799 --> 00:26:17,039 color picker that we can pick another 628 00:26:15,039 --> 00:26:18,640 color with. So, I'm going to pick 629 00:26:17,039 --> 00:26:20,799 something that's a little closer to what 630 00:26:18,640 --> 00:26:22,799 I see at the bottom. And don't worry, it 631 00:26:20,799 --> 00:26:26,159 doesn't have to be perfect. I'm going to 632 00:26:22,799 --> 00:26:29,840 pick something like 200. 633 00:26:26,159 --> 00:26:31,520 I'm going to save this and refresh. 634 00:26:29,840 --> 00:26:33,679 Okay, so that looks I think that looks 635 00:26:31,520 --> 00:26:36,159 close enough. So, you might be wondering 636 00:26:33,679 --> 00:26:42,039 what this value means. We went from a 637 00:26:36,159 --> 00:26:42,039 color of red to RGB 200. 638 00:26:42,240 --> 00:26:47,520 So this RGB value is another way of 639 00:26:45,120 --> 00:26:49,360 measuring color. It's a more precise way 640 00:26:47,520 --> 00:26:52,400 of measuring color than just using a 641 00:26:49,360 --> 00:26:54,720 word like red or white. So the way that 642 00:26:52,400 --> 00:26:56,880 RGB works is that pretty much every 643 00:26:54,720 --> 00:27:00,159 color can be created using a combination 644 00:26:56,880 --> 00:27:02,799 of red, green, and blue. So that's what 645 00:27:00,159 --> 00:27:05,600 this syntax represents. 646 00:27:02,799 --> 00:27:08,320 The R represents how much red we have in 647 00:27:05,600 --> 00:27:11,760 this color. G represents how much green 648 00:27:08,320 --> 00:27:13,679 and B represents how much blue. 649 00:27:11,760 --> 00:27:16,000 And these three numbers represent how 650 00:27:13,679 --> 00:27:18,880 much red we have, how much green, and 651 00:27:16,000 --> 00:27:23,120 how much blue. The minimum value is zero 652 00:27:18,880 --> 00:27:25,840 and the maximum value is 255. 653 00:27:23,120 --> 00:27:28,640 So if we removed all the red and green 654 00:27:25,840 --> 00:27:31,440 and we just have maximum blue and we 655 00:27:28,640 --> 00:27:32,960 save, that's going to get us a blue 656 00:27:31,440 --> 00:27:35,679 color. 657 00:27:32,960 --> 00:27:38,880 On the other hand, if we have all green 658 00:27:35,679 --> 00:27:41,679 color and we get rid of the blue, 659 00:27:38,880 --> 00:27:43,919 we're going to have a green color. 660 00:27:41,679 --> 00:27:45,840 So, this is basically how RGB works. 661 00:27:43,919 --> 00:27:48,400 It's a combination of red, green, and 662 00:27:45,840 --> 00:27:50,240 blue to create any color that we want. 663 00:27:48,400 --> 00:27:52,480 Now, don't worry too much about knowing 664 00:27:50,240 --> 00:27:54,799 what an RGB value looks like. For 665 00:27:52,480 --> 00:27:57,360 example, if you have a random value like 666 00:27:54,799 --> 00:27:59,760 this, if you gave this to me, I wouldn't 667 00:27:57,360 --> 00:28:01,600 even know what this color was. Usually I 668 00:27:59,760 --> 00:28:03,679 just use the color picker to pick the 669 00:28:01,600 --> 00:28:06,480 color that I want and then it will give 670 00:28:03,679 --> 00:28:10,080 me the RGB value that I need. The only 671 00:28:06,480 --> 00:28:12,559 RGB values I suggest you remember are if 672 00:28:10,080 --> 00:28:17,120 we set all the colors to the maximum 673 00:28:12,559 --> 00:28:20,320 value. So 255, 255, and 255. 674 00:28:17,120 --> 00:28:22,960 This creates white. So we save it and 675 00:28:20,320 --> 00:28:25,600 refresh. That creates white. If we set 676 00:28:22,960 --> 00:28:28,960 all of these three to zero, 677 00:28:25,600 --> 00:28:32,159 that creates black. and we refresh. That 678 00:28:28,960 --> 00:28:34,399 creates a black color. 679 00:28:32,159 --> 00:28:38,240 So now let's go back to what we had 680 00:28:34,399 --> 00:28:41,600 before, which I think was 200. 681 00:28:38,240 --> 00:28:42,880 And we'll save and refresh. 682 00:28:41,600 --> 00:28:44,960 And the next thing we're going to change 683 00:28:42,880 --> 00:28:47,919 is you might not be able to see it, but 684 00:28:44,960 --> 00:28:50,960 if we zoom in here, this button has 685 00:28:47,919 --> 00:28:53,440 rounded corners while our button has 686 00:28:50,960 --> 00:28:56,559 pointy corners. So to make rounded 687 00:28:53,440 --> 00:28:59,200 corners, the CSS property for doing that 688 00:28:56,559 --> 00:29:01,120 is border 689 00:28:59,200 --> 00:29:02,960 dash radius. 690 00:29:01,120 --> 00:29:05,120 And the border radius takes a pixel 691 00:29:02,960 --> 00:29:07,520 measurement. The higher the pixels, the 692 00:29:05,120 --> 00:29:11,840 more round the corners will be. So for 693 00:29:07,520 --> 00:29:14,240 now, let's try colon 2 pixels and save. 694 00:29:11,840 --> 00:29:16,320 Now, if we refresh the page, our button 695 00:29:14,240 --> 00:29:18,640 now has rounded corners just like our 696 00:29:16,320 --> 00:29:20,720 design. So I'm going to zoom back out 697 00:29:18,640 --> 00:29:22,159 and zoom back out. 698 00:29:20,720 --> 00:29:24,559 So, the last thing I'm going to change 699 00:29:22,159 --> 00:29:26,720 is if we hover over this button, you'll 700 00:29:24,559 --> 00:29:29,279 notice that our mouse turns into this 701 00:29:26,720 --> 00:29:30,799 sort of hand. This hand is called a 702 00:29:29,279 --> 00:29:35,200 pointer. 703 00:29:30,799 --> 00:29:36,880 So, we're going to change the cursor. 704 00:29:35,200 --> 00:29:38,880 The mouse, this thing that you point 705 00:29:36,880 --> 00:29:40,559 around is usually called a cursor. And 706 00:29:38,880 --> 00:29:42,960 we're going to change the cursor to a 707 00:29:40,559 --> 00:29:45,919 pointer. 708 00:29:42,960 --> 00:29:48,640 Let's save and refresh. And that's how 709 00:29:45,919 --> 00:29:50,480 you get this hand whenever your mouse is 710 00:29:48,640 --> 00:29:52,480 over this button. 711 00:29:50,480 --> 00:29:55,440 So that's basically how we go from a 712 00:29:52,480 --> 00:29:57,840 basic HTML button to something that 713 00:29:55,440 --> 00:30:00,559 looks more professional. We create the 714 00:29:57,840 --> 00:30:03,600 button with HTML and then we set the 715 00:30:00,559 --> 00:30:05,360 styles one by one. 716 00:30:03,600 --> 00:30:08,000 Now you might be wondering how do I know 717 00:30:05,360 --> 00:30:10,720 all of these CSS properties? How are you 718 00:30:08,000 --> 00:30:12,720 supposed to memorize all of these? So 719 00:30:10,720 --> 00:30:14,960 usually when I don't know the CSS 720 00:30:12,720 --> 00:30:17,120 property for something for example if I 721 00:30:14,960 --> 00:30:20,159 want to create rounded corners I would 722 00:30:17,120 --> 00:30:22,799 go to Google and search something like 723 00:30:20,159 --> 00:30:26,480 CSS and what I want to do. So let's say 724 00:30:22,799 --> 00:30:28,720 I want round corners 725 00:30:26,480 --> 00:30:32,240 and usually the first few links give 726 00:30:28,720 --> 00:30:34,640 some really good suggestions on what the 727 00:30:32,240 --> 00:30:36,880 property is. So here right away we have 728 00:30:34,640 --> 00:30:40,000 the border radius property in the first 729 00:30:36,880 --> 00:30:42,880 link and it gives us some sample code 730 00:30:40,000 --> 00:30:45,440 that we can use. 731 00:30:42,880 --> 00:30:48,159 So that's how I discover all of the CSS 732 00:30:45,440 --> 00:30:50,000 properties. I look at a design and I ask 733 00:30:48,159 --> 00:30:52,240 myself, okay, what do I need to achieve 734 00:30:50,000 --> 00:30:55,039 this design? And then I search for it in 735 00:30:52,240 --> 00:30:56,480 Google. So don't worry, as you use CSS 736 00:30:55,039 --> 00:30:58,159 more and more, you're going to have to 737 00:30:56,480 --> 00:30:59,919 Google things that you don't know and 738 00:30:58,159 --> 00:31:03,200 you'll just get used to the process of 739 00:30:59,919 --> 00:31:05,039 finding answers by searching for them. 740 00:31:03,200 --> 00:31:06,799 But for the purposes of this course, I'm 741 00:31:05,039 --> 00:31:08,960 going to give you a lot of these CSS 742 00:31:06,799 --> 00:31:11,360 properties so that you can get some good 743 00:31:08,960 --> 00:31:12,880 practice with them. 744 00:31:11,360 --> 00:31:16,000 The next step we're going to do is to 745 00:31:12,880 --> 00:31:21,440 copy this join button. So let's create a 746 00:31:16,000 --> 00:31:22,880 new button on our page with HTML. 747 00:31:21,440 --> 00:31:25,200 And this is going to be the join button. 748 00:31:22,880 --> 00:31:28,480 So we're going to put the text join 749 00:31:25,200 --> 00:31:30,159 inside this button. Let's save it and 750 00:31:28,480 --> 00:31:32,080 refresh. 751 00:31:30,159 --> 00:31:34,159 And unfortunately, it looks like our 752 00:31:32,080 --> 00:31:37,440 join button looks like the subscribe 753 00:31:34,159 --> 00:31:40,159 button. And that's because in our CSS, 754 00:31:37,440 --> 00:31:43,600 this word button means that all of these 755 00:31:40,159 --> 00:31:45,279 styles are targeted to all buttons on 756 00:31:43,600 --> 00:31:47,519 the page. 757 00:31:45,279 --> 00:31:50,159 So, how do we get these styles to only 758 00:31:47,519 --> 00:31:52,640 target the subscribe button? So, we're 759 00:31:50,159 --> 00:31:54,799 going to learn a new HTML attribute that 760 00:31:52,640 --> 00:31:56,000 we can use for this. So, remember in the 761 00:31:54,799 --> 00:31:58,559 previous lesson, we learned that 762 00:31:56,000 --> 00:32:00,640 attributes modify the behavior of 763 00:31:58,559 --> 00:32:02,640 elements. In this lesson, we're going to 764 00:32:00,640 --> 00:32:05,519 learn a very useful attribute that is 765 00:32:02,640 --> 00:32:07,840 used a lot in CSS. We're going to go to 766 00:32:05,519 --> 00:32:10,480 the opening tag again and we're going to 767 00:32:07,840 --> 00:32:12,159 add a new attribute called the class 768 00:32:10,480 --> 00:32:14,720 attribute. 769 00:32:12,159 --> 00:32:16,720 So, we're going to type class equals 770 00:32:14,720 --> 00:32:18,559 quotes. 771 00:32:16,720 --> 00:32:22,159 So, the class attribute basically lets 772 00:32:18,559 --> 00:32:26,080 us label HTML elements. For example, 773 00:32:22,159 --> 00:32:29,080 let's label this button the subscribe 774 00:32:26,080 --> 00:32:29,080 button. 775 00:32:29,360 --> 00:32:33,519 And also my code is getting a little 776 00:32:31,120 --> 00:32:35,600 long for this line. So I'm going to put 777 00:32:33,519 --> 00:32:38,320 the text on a new line to make it easier 778 00:32:35,600 --> 00:32:41,440 to read. So remember according to HTML 779 00:32:38,320 --> 00:32:43,919 syntax, these extra spaces don't matter. 780 00:32:41,440 --> 00:32:46,159 They're ignored. 781 00:32:43,919 --> 00:32:48,399 So now that we set the class attribute, 782 00:32:46,159 --> 00:32:51,039 we've essentially set a label to this 783 00:32:48,399 --> 00:32:55,440 button and we can target this label in 784 00:32:51,039 --> 00:32:58,320 our CSS. So to target a class in CSS, we 785 00:32:55,440 --> 00:33:00,480 can start with a dot and then we're 786 00:32:58,320 --> 00:33:03,600 going to type out the class name. So 787 00:33:00,480 --> 00:33:06,159 we're going to type out subscribe dash 788 00:33:03,600 --> 00:33:09,120 button. 789 00:33:06,159 --> 00:33:11,600 So according to CSS syntax, if we start 790 00:33:09,120 --> 00:33:14,480 this code with a dot, that means we're 791 00:33:11,600 --> 00:33:17,679 going to target a class name instead of 792 00:33:14,480 --> 00:33:20,399 an element name like button. So here 793 00:33:17,679 --> 00:33:22,799 we're going to start targeting just any 794 00:33:20,399 --> 00:33:26,799 element that has the class subscribe 795 00:33:22,799 --> 00:33:29,200 button. So if we save and refresh 796 00:33:26,799 --> 00:33:31,360 now you'll see that all of these styles 797 00:33:29,200 --> 00:33:34,480 only apply to elements that have the 798 00:33:31,360 --> 00:33:36,960 class subscribe and our join button does 799 00:33:34,480 --> 00:33:39,200 not have any of these styles. 800 00:33:36,960 --> 00:33:42,159 Now multiple elements can have the same 801 00:33:39,200 --> 00:33:44,480 class. So for example, if I set the 802 00:33:42,159 --> 00:33:47,480 class of the join button to 803 00:33:44,480 --> 00:33:47,480 subscribe-button, 804 00:33:48,000 --> 00:33:51,840 all of these styles will be applied to 805 00:33:49,600 --> 00:33:54,080 any element with the subscribe button 806 00:33:51,840 --> 00:33:56,080 class. That's what this dot means. And 807 00:33:54,080 --> 00:34:00,159 that means these are going to be applied 808 00:33:56,080 --> 00:34:02,960 to this and this. So if we save and 809 00:34:00,159 --> 00:34:05,279 refresh, now the join button has these 810 00:34:02,960 --> 00:34:07,919 styles again because it has a class of 811 00:34:05,279 --> 00:34:09,359 subscribe button. But for our purposes, 812 00:34:07,919 --> 00:34:11,359 we actually want this to have a 813 00:34:09,359 --> 00:34:14,159 different set of styles. So, let's give 814 00:34:11,359 --> 00:34:17,040 a different class to the join button. 815 00:34:14,159 --> 00:34:20,000 We're going to give the class join. 816 00:34:17,040 --> 00:34:22,240 And I'm also going to reformat my code a 817 00:34:20,000 --> 00:34:25,119 little to make it easier to read. So, 818 00:34:22,240 --> 00:34:27,760 let's save and refresh. 819 00:34:25,119 --> 00:34:30,480 And now we're back to where we can start 820 00:34:27,760 --> 00:34:32,320 modifying our join button. 821 00:34:30,480 --> 00:34:34,800 Now, let's start styling our join button 822 00:34:32,320 --> 00:34:37,280 to match our design. So remember the 823 00:34:34,800 --> 00:34:39,839 general strategy is to create the 824 00:34:37,280 --> 00:34:42,240 element with HTML like this and then 825 00:34:39,839 --> 00:34:45,520 style it one by one until you match your 826 00:34:42,240 --> 00:34:47,919 design. So first we're going to target 827 00:34:45,520 --> 00:34:49,919 the class. That's what this dot means. 828 00:34:47,919 --> 00:34:52,320 We're going to target the class join- 829 00:34:49,919 --> 00:34:55,280 button. 830 00:34:52,320 --> 00:35:00,480 Okay. So let's set the background dash 831 00:34:55,280 --> 00:35:02,079 color to white. Let's save it and 832 00:35:00,480 --> 00:35:05,040 refresh. 833 00:35:02,079 --> 00:35:08,480 And next, let's deal with the border. 834 00:35:05,040 --> 00:35:12,880 So, our border is a little bit gray. We 835 00:35:08,480 --> 00:35:16,240 can set it to maybe border dash color 836 00:35:12,880 --> 00:35:19,040 to blue. And let's see how that looks. 837 00:35:16,240 --> 00:35:20,960 Let's save it and refresh. 838 00:35:19,040 --> 00:35:23,440 Okay. So, it looks a little darker than 839 00:35:20,960 --> 00:35:25,280 what we have in our design. Let's go 840 00:35:23,440 --> 00:35:27,280 into our color picker and pick a more 841 00:35:25,280 --> 00:35:29,599 accurate color. So, I'm just going to do 842 00:35:27,280 --> 00:35:31,200 this by eye. Don't worry if it's not 843 00:35:29,599 --> 00:35:33,200 totally accurate. We're just trying to 844 00:35:31,200 --> 00:35:35,599 get something that's close enough. I'm 845 00:35:33,200 --> 00:35:38,640 going to go over here and I'm going to 846 00:35:35,599 --> 00:35:40,320 pick something like maybe something like 847 00:35:38,640 --> 00:35:43,520 this. 848 00:35:40,320 --> 00:35:46,240 Let's save it. Refresh. 849 00:35:43,520 --> 00:35:48,160 And that's a little bit too dark. So, 850 00:35:46,240 --> 00:35:50,079 I'm going to pick something a little bit 851 00:35:48,160 --> 00:35:53,280 lighter. 852 00:35:50,079 --> 00:35:56,160 Save it and refresh. Okay. I think 853 00:35:53,280 --> 00:35:58,160 that's pretty good. But we also notice 854 00:35:56,160 --> 00:36:00,079 that our border is a little weird. So, 855 00:35:58,160 --> 00:36:02,560 on the top it looks like it's a darker. 856 00:36:00,079 --> 00:36:04,240 it's a lighter shade of blue and at the 857 00:36:02,560 --> 00:36:06,640 bottom it's kind of a darker shade of 858 00:36:04,240 --> 00:36:08,560 blue. So to fix that, we're going to set 859 00:36:06,640 --> 00:36:10,079 the border 860 00:36:08,560 --> 00:36:13,920 style 861 00:36:10,079 --> 00:36:17,280 to be a solid color. 862 00:36:13,920 --> 00:36:20,800 Let's save this and refresh. And now we 863 00:36:17,280 --> 00:36:23,520 get a solid color all around. The next 864 00:36:20,800 --> 00:36:25,839 thing we can change is our border looks 865 00:36:23,520 --> 00:36:28,240 a little bit thick compared to the 866 00:36:25,839 --> 00:36:32,079 design. So, we're going to change the 867 00:36:28,240 --> 00:36:33,280 border dash width. So, you'll see that a 868 00:36:32,079 --> 00:36:35,599 lot of these styles are pretty 869 00:36:33,280 --> 00:36:37,040 self-explanatory. 870 00:36:35,599 --> 00:36:39,839 So, we're going to set the border width 871 00:36:37,040 --> 00:36:43,200 to let's say 1 pixel. 872 00:36:39,839 --> 00:36:45,520 Let's save it and refresh. Okay, so that 873 00:36:43,200 --> 00:36:48,079 looks pretty good. 874 00:36:45,520 --> 00:36:49,839 Next, we're going to set the text color. 875 00:36:48,079 --> 00:36:53,200 So, we're going to set the text color to 876 00:36:49,839 --> 00:36:55,359 blue and have it the same as our border. 877 00:36:53,200 --> 00:36:58,880 So remember the property to set text 878 00:36:55,359 --> 00:37:03,599 color is called color colon. And we're 879 00:36:58,880 --> 00:37:06,079 going to copy this color down here. 880 00:37:03,599 --> 00:37:08,640 Save it and refresh. 881 00:37:06,079 --> 00:37:11,599 Okay. So that looks it's a little a 882 00:37:08,640 --> 00:37:13,839 little light, but I think it's okay. 883 00:37:11,599 --> 00:37:18,079 Now we're going to set the height and 884 00:37:13,839 --> 00:37:20,800 the width. So let's set the height to be 885 00:37:18,079 --> 00:37:24,000 something like 36 pixels to match our 886 00:37:20,800 --> 00:37:24,000 subscribe button. 887 00:37:24,800 --> 00:37:31,280 refresh. Okay. And now we're going to 888 00:37:27,280 --> 00:37:33,200 set the width. So, let's try, 889 00:37:31,280 --> 00:37:36,720 I don't know, 60 pixels. Let's see how 890 00:37:33,200 --> 00:37:41,440 that looks. Save and refresh. Okay. I'm 891 00:37:36,720 --> 00:37:44,720 going to set it to maybe 62. 892 00:37:41,440 --> 00:37:46,560 Okay, let's save and refresh. 893 00:37:44,720 --> 00:37:50,640 And again, we're going to set some 894 00:37:46,560 --> 00:37:52,320 rounded corners. So that is border dash 895 00:37:50,640 --> 00:37:54,560 radius 896 00:37:52,320 --> 00:37:57,520 2 pixels. 897 00:37:54,560 --> 00:37:59,760 We're going to save it and refresh. And 898 00:37:57,520 --> 00:38:01,440 now we're almost there to matching this 899 00:37:59,760 --> 00:38:02,880 design. 900 00:38:01,440 --> 00:38:06,240 The last one we're going to set is 901 00:38:02,880 --> 00:38:08,160 cursor pointer to get that nice hand 902 00:38:06,240 --> 00:38:10,480 pointer when we're hovering over the 903 00:38:08,160 --> 00:38:12,160 button. So refresh. Now when we're 904 00:38:10,480 --> 00:38:15,680 hovering over the join button, we have 905 00:38:12,160 --> 00:38:17,200 this nice pointer icon. 906 00:38:15,680 --> 00:38:18,800 So another thing we notice is that 907 00:38:17,200 --> 00:38:20,400 there's a lot of space between these two 908 00:38:18,800 --> 00:38:24,240 buttons and there's not a lot of space 909 00:38:20,400 --> 00:38:26,720 between ours. So in CSS space is called 910 00:38:24,240 --> 00:38:29,839 margin. So to add space we're going to 911 00:38:26,720 --> 00:38:32,400 add some margin. So let's go to the 912 00:38:29,839 --> 00:38:35,359 subscribe button styles and we're going 913 00:38:32,400 --> 00:38:37,599 to add some margin 914 00:38:35,359 --> 00:38:39,359 dash right. 915 00:38:37,599 --> 00:38:42,960 So we're going to add some margin or 916 00:38:39,359 --> 00:38:45,040 some space to the right of this button. 917 00:38:42,960 --> 00:38:46,960 And we're going to set the space to 918 00:38:45,040 --> 00:38:50,640 maybe 8 pixels. Let's see how that 919 00:38:46,960 --> 00:38:52,320 looks. Save and refresh. And that looks 920 00:38:50,640 --> 00:38:55,119 pretty good to me. So now we're done 921 00:38:52,320 --> 00:38:57,040 with the join button. 922 00:38:55,119 --> 00:39:00,000 Lastly, we're going to create this tweet 923 00:38:57,040 --> 00:39:02,400 button. Let's go back into our code. And 924 00:39:00,000 --> 00:39:05,520 remember, our general technique is to 925 00:39:02,400 --> 00:39:08,320 number one create the element with HTML. 926 00:39:05,520 --> 00:39:12,240 And then number two, style it with CSS 927 00:39:08,320 --> 00:39:16,800 one by one. So, we're going to create a 928 00:39:12,240 --> 00:39:18,320 button with a text tweet. 929 00:39:16,800 --> 00:39:20,640 Going to move my editor a little bit to 930 00:39:18,320 --> 00:39:23,599 the right here so we can see it. I'll 931 00:39:20,640 --> 00:39:25,839 move this here as well. 932 00:39:23,599 --> 00:39:27,440 And let's refresh our page. So, now this 933 00:39:25,839 --> 00:39:29,920 button has the same style as a join 934 00:39:27,440 --> 00:39:33,599 button because it has a join button 935 00:39:29,920 --> 00:39:35,599 class and that's being targeted up here. 936 00:39:33,599 --> 00:39:39,119 So instead of the join button, we're 937 00:39:35,599 --> 00:39:41,920 going to give a class or a label of 938 00:39:39,119 --> 00:39:44,160 tweet button. 939 00:39:41,920 --> 00:39:46,800 And now save and refresh. And now we're 940 00:39:44,160 --> 00:39:49,040 back to the default styles. So in our 941 00:39:46,800 --> 00:39:51,440 CSS, we're going to write some code. 942 00:39:49,040 --> 00:39:53,680 We're going to target the class. So we 943 00:39:51,440 --> 00:39:56,960 start with a dot to target a class. 944 00:39:53,680 --> 00:39:59,839 We're going to target the tweet button 945 00:39:56,960 --> 00:40:01,839 class. 946 00:39:59,839 --> 00:40:04,000 So, just like our other buttons, we're 947 00:40:01,839 --> 00:40:07,040 going to adjust the style of this button 948 00:40:04,000 --> 00:40:10,079 one by one until we match our design. 949 00:40:07,040 --> 00:40:12,400 So, let's start off with the background 950 00:40:10,079 --> 00:40:14,720 dash color. 951 00:40:12,400 --> 00:40:17,760 Let's set this to blue to start off 952 00:40:14,720 --> 00:40:19,359 with. Now, I'm going to try my best to 953 00:40:17,760 --> 00:40:22,000 match the Twitter blue that we have 954 00:40:19,359 --> 00:40:23,839 here. So, I'm going to pick something 955 00:40:22,000 --> 00:40:28,000 like this. 956 00:40:23,839 --> 00:40:31,520 And I think that looks pretty good. 957 00:40:28,000 --> 00:40:33,680 Save it and refresh. 958 00:40:31,520 --> 00:40:36,320 Okay, we'll leave it like that for now. 959 00:40:33,680 --> 00:40:39,680 We might adjust it later. Let's change 960 00:40:36,320 --> 00:40:42,320 the color now to white. So that'll 961 00:40:39,680 --> 00:40:47,480 change the text color. 962 00:40:42,320 --> 00:40:47,480 Okay, let's get rid of the border. 963 00:40:48,400 --> 00:40:53,680 Refresh and save. 964 00:40:50,320 --> 00:40:56,880 Let's give it a height 965 00:40:53,680 --> 00:41:00,480 of 36 pixels 966 00:40:56,880 --> 00:41:02,240 to match our other buttons. Okay. And 967 00:41:00,480 --> 00:41:05,200 the color is a little bit off, so I'm 968 00:41:02,240 --> 00:41:09,119 going to adjust it just a bit. Maybe it 969 00:41:05,200 --> 00:41:12,560 should be a little more like this. 970 00:41:09,119 --> 00:41:14,160 Save it. Refresh. Okay, I'm pretty happy 971 00:41:12,560 --> 00:41:16,079 with this. Now, we're going to adjust 972 00:41:14,160 --> 00:41:20,000 the width 973 00:41:16,079 --> 00:41:22,240 to maybe 105 974 00:41:20,000 --> 00:41:23,839 and see how that looks. 975 00:41:22,240 --> 00:41:28,359 Okay, that's a little too much. Let's 976 00:41:23,839 --> 00:41:28,359 adjust it to 80. 977 00:41:28,400 --> 00:41:32,560 Uh, let's adjust it to 70. So, as you 978 00:41:31,119 --> 00:41:35,359 can see, there's a lot of trial and 979 00:41:32,560 --> 00:41:38,640 error when we're working with CSS. Now, 980 00:41:35,359 --> 00:41:40,480 to get this rounded effect, we can set a 981 00:41:38,640 --> 00:41:43,200 border radius. 982 00:41:40,480 --> 00:41:45,520 Let's start with 2 pixels. If we 983 00:41:43,200 --> 00:41:47,280 refresh, we get rounded corners. If we 984 00:41:45,520 --> 00:41:50,560 start increasing the pixels for the 985 00:41:47,280 --> 00:41:53,760 border radius. Let's save and refresh. 986 00:41:50,560 --> 00:41:55,440 It starts getting rounder and rounder. 987 00:41:53,760 --> 00:41:57,680 So, the trick to getting these round 988 00:41:55,440 --> 00:42:01,040 buttons is we have to set the border 989 00:41:57,680 --> 00:42:03,119 radius to half the height or the width, 990 00:42:01,040 --> 00:42:05,760 whichever is lower. So, in this case, 991 00:42:03,119 --> 00:42:08,560 the height is 36. If we set the border 992 00:42:05,760 --> 00:42:11,680 radius to half of that, which is 18. 993 00:42:08,560 --> 00:42:14,000 Save and refresh. That's how we get this 994 00:42:11,680 --> 00:42:18,160 rounded color. The last thing we're 995 00:42:14,000 --> 00:42:20,720 going to do is to bold the text in here. 996 00:42:18,160 --> 00:42:23,040 So in our design, this tweet text here 997 00:42:20,720 --> 00:42:25,520 is very bold. We're going to make our 998 00:42:23,040 --> 00:42:28,319 font bold as well. So to do that, we're 999 00:42:25,520 --> 00:42:31,200 going to set this property called font 1000 00:42:28,319 --> 00:42:33,520 dash weight. I'm going to set it to 1001 00:42:31,200 --> 00:42:35,680 bold. 1002 00:42:33,520 --> 00:42:37,599 Save and refresh. 1003 00:42:35,680 --> 00:42:39,440 Okay, looks pretty good. It looks like 1004 00:42:37,599 --> 00:42:41,839 this font is actually a little bigger 1005 00:42:39,440 --> 00:42:46,960 than ours. So, let's actually set the 1006 00:42:41,839 --> 00:42:49,680 font dash size. Set it to maybe 15. See 1007 00:42:46,960 --> 00:42:52,560 how that looks. 1008 00:42:49,680 --> 00:42:54,560 Save and refresh. Okay, I think that 1009 00:42:52,560 --> 00:42:58,160 looks pretty close. I'm going to change 1010 00:42:54,560 --> 00:43:01,359 the width to maybe 74. 1011 00:42:58,160 --> 00:43:03,040 See how that looks. Okay, so this I 1012 00:43:01,359 --> 00:43:05,200 think this is good enough. Currently, 1013 00:43:03,040 --> 00:43:06,800 we're just trying to copy things by eye. 1014 00:43:05,200 --> 00:43:08,800 Later, I'll show you a technique of how 1015 00:43:06,800 --> 00:43:10,800 to copy these colors and measurements 1016 00:43:08,800 --> 00:43:13,119 exactly, but for now, it's good enough 1017 00:43:10,800 --> 00:43:15,520 to be able to achieve these designs just 1018 00:43:13,119 --> 00:43:17,599 by looking at them. 1019 00:43:15,520 --> 00:43:21,440 So, the last thing for this button is to 1020 00:43:17,599 --> 00:43:24,480 add the cursor pointer. Let's save it 1021 00:43:21,440 --> 00:43:27,040 and refresh. So, if we hover over this 1022 00:43:24,480 --> 00:43:29,359 button, we now get a nice pointer for 1023 00:43:27,040 --> 00:43:31,359 our cursor. So, the last thing I'm going 1024 00:43:29,359 --> 00:43:33,839 to adjust here is the spacing between 1025 00:43:31,359 --> 00:43:36,400 these two buttons. Remember, spacing in 1026 00:43:33,839 --> 00:43:39,520 CSS is called margin. So, we're going to 1027 00:43:36,400 --> 00:43:41,280 add to the join button. Actually, let's 1028 00:43:39,520 --> 00:43:43,520 add it to the tweet button just for 1029 00:43:41,280 --> 00:43:46,480 practice. We're going to add spacing. 1030 00:43:43,520 --> 00:43:50,880 So, we're going to add margin 1031 00:43:46,480 --> 00:43:53,599 to the left colon. And let's make it 8 1032 00:43:50,880 --> 00:43:58,319 pixels like we had it for the subscribe 1033 00:43:53,599 --> 00:44:01,280 button. Let's save it and refresh. And 1034 00:43:58,319 --> 00:44:03,920 there we go. So we took our basic 1035 00:44:01,280 --> 00:44:06,000 buttons and we were able to copy these 1036 00:44:03,920 --> 00:44:07,839 really nice looking designs just by 1037 00:44:06,000 --> 00:44:10,640 looking at them. And the technique that 1038 00:44:07,839 --> 00:44:14,400 we use for doing this is first we create 1039 00:44:10,640 --> 00:44:17,599 the element with HTML and then we style 1040 00:44:14,400 --> 00:44:21,720 it with CSS one by one until it looks 1041 00:44:17,599 --> 00:44:21,720 close enough to our design. 1042 00:44:22,640 --> 00:44:26,880 So here are a bunch of exercises from 1043 00:44:24,720 --> 00:44:28,960 other popular websites that you can try 1044 00:44:26,880 --> 00:44:30,960 out for yourself. This is a good 1045 00:44:28,960 --> 00:44:34,480 challenge for you to be able to look at 1046 00:44:30,960 --> 00:44:38,359 a website by eye and use CSS to copy the 1047 00:44:34,480 --> 00:44:38,359 styles that you see. 1048 00:44:42,079 --> 00:44:45,680 In this lesson, we're going to learn 1049 00:44:43,280 --> 00:44:47,920 some intermediate CSS skills such as how 1050 00:44:45,680 --> 00:44:50,319 to create hovers, transitions, and 1051 00:44:47,920 --> 00:44:52,480 shadows. For most buttons you see on the 1052 00:44:50,319 --> 00:44:55,280 internet, if we hover over them with our 1053 00:44:52,480 --> 00:44:57,040 mouse, they change their style slightly. 1054 00:44:55,280 --> 00:44:59,280 Some of them get darker, some of them 1055 00:44:57,040 --> 00:45:02,480 get lighter. We're going to learn how to 1056 00:44:59,280 --> 00:45:04,079 do that in our code. 1057 00:45:02,480 --> 00:45:06,160 So, we're going to use the same exercise 1058 00:45:04,079 --> 00:45:08,319 as before. As a reminder, you can find 1059 00:45:06,160 --> 00:45:11,319 it at superimple.dev/ex 1060 00:45:08,319 --> 00:45:11,319 exercises/buttons. 1061 00:45:11,520 --> 00:45:16,480 These buttons, when we hover over them, 1062 00:45:13,839 --> 00:45:18,240 they actually change their style. So, 1063 00:45:16,480 --> 00:45:20,880 this is going to help us practice 1064 00:45:18,240 --> 00:45:22,960 learning about hovers. In addition, 1065 00:45:20,880 --> 00:45:25,200 you'll notice that if we hover in and 1066 00:45:22,960 --> 00:45:27,280 out, they change their style smoothly. 1067 00:45:25,200 --> 00:45:29,040 So, we can also learn about transitions. 1068 00:45:27,280 --> 00:45:31,359 And lastly, this tweet button, if we 1069 00:45:29,040 --> 00:45:33,839 hover over it, it casts a little bit of 1070 00:45:31,359 --> 00:45:36,839 a shadow. So, that'll help us practice 1071 00:45:33,839 --> 00:45:36,839 shadows. 1072 00:45:37,200 --> 00:45:42,000 But first, let's work on the hover 1073 00:45:38,880 --> 00:45:44,560 styles for the subscribe button. Let's 1074 00:45:42,000 --> 00:45:47,040 go into our code and find the styles for 1075 00:45:44,560 --> 00:45:49,680 the subscribe button, which is 1076 00:45:47,040 --> 00:45:52,000 everything here. And now to create a 1077 00:45:49,680 --> 00:45:55,599 hover effect, we're going to create a 1078 00:45:52,000 --> 00:45:57,440 new block of CSS. 1079 00:45:55,599 --> 00:45:59,040 We're going to use a dot to target a 1080 00:45:57,440 --> 00:46:03,680 class. So this time we're still 1081 00:45:59,040 --> 00:46:06,400 targeting the subscribe dash button, 1082 00:46:03,680 --> 00:46:10,640 but this time we're going to add colon 1083 00:46:06,400 --> 00:46:13,119 hover open bracket close bracket. 1084 00:46:10,640 --> 00:46:15,200 So inside these are styles that will 1085 00:46:13,119 --> 00:46:17,440 apply only when we hover over the 1086 00:46:15,200 --> 00:46:19,520 button. That's what this colon hover 1087 00:46:17,440 --> 00:46:22,640 means. 1088 00:46:19,520 --> 00:46:26,880 For example, we can set the background 1089 00:46:22,640 --> 00:46:29,760 dash color to green. 1090 00:46:26,880 --> 00:46:31,520 Now, let's save our file and refresh the 1091 00:46:29,760 --> 00:46:33,440 page. 1092 00:46:31,520 --> 00:46:35,680 And when we hover over this button, 1093 00:46:33,440 --> 00:46:37,760 you'll notice that it's green. So, the 1094 00:46:35,680 --> 00:46:40,400 way that this works is that if we are 1095 00:46:37,760 --> 00:46:43,440 not hovering over, all of these styles 1096 00:46:40,400 --> 00:46:45,760 apply. So, the background color is red. 1097 00:46:43,440 --> 00:46:48,480 If we are hovering over the button, 1098 00:46:45,760 --> 00:46:50,240 these styles now apply in addition to 1099 00:46:48,480 --> 00:46:53,440 these styles. So we're essentially 1100 00:46:50,240 --> 00:46:56,160 adding extra styles when we hover. So 1101 00:46:53,440 --> 00:47:00,240 this colon hover is known as a pseudo 1102 00:46:56,160 --> 00:47:02,480 class. It basically adds extra styles in 1103 00:47:00,240 --> 00:47:04,319 a certain situation. So in this case, 1104 00:47:02,480 --> 00:47:05,920 it's going to add extra styles when we 1105 00:47:04,319 --> 00:47:08,079 hover. 1106 00:47:05,920 --> 00:47:10,160 Another example of a pseudo class 1107 00:47:08,079 --> 00:47:14,160 issubscribe 1108 00:47:10,160 --> 00:47:16,800 button colon active. 1109 00:47:14,160 --> 00:47:20,079 So the active pseudo class activates 1110 00:47:16,800 --> 00:47:21,760 when we click on the element. So when we 1111 00:47:20,079 --> 00:47:26,000 click on the button, we can set the 1112 00:47:21,760 --> 00:47:29,119 background color to blue. 1113 00:47:26,000 --> 00:47:31,920 Let's save this and refresh. 1114 00:47:29,119 --> 00:47:33,359 Now when we hover over, we're going to 1115 00:47:31,920 --> 00:47:35,040 apply these styles. So the background 1116 00:47:33,359 --> 00:47:38,400 color is going to be green. And then 1117 00:47:35,040 --> 00:47:40,319 when we click, we're going to apply the 1118 00:47:38,400 --> 00:47:43,359 active styles and then the background 1119 00:47:40,319 --> 00:47:45,920 color is going to be blue. 1120 00:47:43,359 --> 00:47:48,160 So let's look at our design and see what 1121 00:47:45,920 --> 00:47:50,480 kind of hover styles we have. Let's 1122 00:47:48,160 --> 00:47:52,960 refresh. So when we hover over our 1123 00:47:50,480 --> 00:47:56,079 subscribe button, it seems to turn a 1124 00:47:52,960 --> 00:47:59,680 little bit more light. And if we click 1125 00:47:56,079 --> 00:48:02,160 it, it becomes even lighter. So the way 1126 00:47:59,680 --> 00:48:04,160 to make our button lighter is using a 1127 00:48:02,160 --> 00:48:06,240 new property that I'm going to 1128 00:48:04,160 --> 00:48:09,839 introduce. So let's get rid of these for 1129 00:48:06,240 --> 00:48:13,280 now. Let's save and refresh. So we got 1130 00:48:09,839 --> 00:48:16,079 rid of those pseudo class styles. 1131 00:48:13,280 --> 00:48:18,480 We're going to set a CSS property called 1132 00:48:16,079 --> 00:48:21,280 opacity. 1133 00:48:18,480 --> 00:48:24,000 So opacity tells us how see-through an 1134 00:48:21,280 --> 00:48:27,760 HTML element is. It takes a value 1135 00:48:24,000 --> 00:48:30,559 between zero and one. A value of one 1136 00:48:27,760 --> 00:48:34,400 means that this element is completely 1137 00:48:30,559 --> 00:48:35,839 normal. So if we save this and refresh, 1138 00:48:34,400 --> 00:48:38,000 you can see that if we hover over it, 1139 00:48:35,839 --> 00:48:40,160 it's completely normal. And as we 1140 00:48:38,000 --> 00:48:43,280 decrease the opacity, let's decrease it 1141 00:48:40,160 --> 00:48:46,480 to 0.7. 1142 00:48:43,280 --> 00:48:51,119 The elements start to fade. So if we 1143 00:48:46,480 --> 00:48:54,160 decrease it even more to 0.3, 1144 00:48:51,119 --> 00:48:56,800 refresh, now it's even more faded. So 1145 00:48:54,160 --> 00:48:59,200 the opacity is used to fade out an 1146 00:48:56,800 --> 00:49:01,680 element. If we go from one to zero, the 1147 00:48:59,200 --> 00:49:05,440 element is going to fade out. 1148 00:49:01,680 --> 00:49:07,359 So if we set it to zero and refresh, now 1149 00:49:05,440 --> 00:49:10,000 it's basically completely transparent 1150 00:49:07,359 --> 00:49:12,160 and see-through. 1151 00:49:10,000 --> 00:49:13,599 If the opacity goes from zero to one, 1152 00:49:12,160 --> 00:49:17,200 that means the element's going to start 1153 00:49:13,599 --> 00:49:19,280 to fade in. So that's how opacity works. 1154 00:49:17,200 --> 00:49:24,160 For now, if we hover over it, let's set 1155 00:49:19,280 --> 00:49:26,240 the opacity to maybe 0.8. 1156 00:49:24,160 --> 00:49:27,839 So, it's going to be a little bit 1157 00:49:26,240 --> 00:49:30,720 see-through, but not totally 1158 00:49:27,839 --> 00:49:33,599 see-through. So, let's refresh 1159 00:49:30,720 --> 00:49:35,839 and hover over it. Okay, let's look at 1160 00:49:33,599 --> 00:49:38,800 our design. So, that looks pretty close 1161 00:49:35,839 --> 00:49:42,079 to what we have. Next, let's set the 1162 00:49:38,800 --> 00:49:44,720 active styles. So, in our design, if we 1163 00:49:42,079 --> 00:49:46,960 click on this, it gets even lighter. So, 1164 00:49:44,720 --> 00:49:49,200 we're going to set an even lower opacity 1165 00:49:46,960 --> 00:49:51,440 to make our button fade out even more 1166 00:49:49,200 --> 00:49:55,760 when we click on it. 1167 00:49:51,440 --> 00:50:00,400 Let's set it to something like 0 1168 00:49:55,760 --> 00:50:03,200 uh 4 or 0.5, let's say. Save it and 1169 00:50:00,400 --> 00:50:05,839 refresh. Now, when we hover over it, now 1170 00:50:03,200 --> 00:50:08,800 when we click, the button gets lighter 1171 00:50:05,839 --> 00:50:11,760 and we can compare that to our design. 1172 00:50:08,800 --> 00:50:13,119 And that looks pretty good to me. 1173 00:50:11,760 --> 00:50:15,440 Now, we're going to work on the hover 1174 00:50:13,119 --> 00:50:17,839 styles for our join button. So, if we 1175 00:50:15,440 --> 00:50:19,920 look at our design, the colors for this 1176 00:50:17,839 --> 00:50:21,599 join button sort of inverts. So the 1177 00:50:19,920 --> 00:50:24,160 background color and the text color, 1178 00:50:21,599 --> 00:50:26,400 they reverse. So to do that, we're going 1179 00:50:24,160 --> 00:50:29,599 to go into our code 1180 00:50:26,400 --> 00:50:33,680 and again we're going to target the join 1181 00:50:29,599 --> 00:50:37,119 button with a dot join button. And we're 1182 00:50:33,680 --> 00:50:39,280 going to add a pseudo class called colon 1183 00:50:37,119 --> 00:50:41,760 hover. 1184 00:50:39,280 --> 00:50:45,040 And now all the styles inside here will 1185 00:50:41,760 --> 00:50:47,280 apply when we hover over this button. So 1186 00:50:45,040 --> 00:50:49,920 when we hover over it, we want to invert 1187 00:50:47,280 --> 00:50:54,160 the colors. So, we want to set the 1188 00:50:49,920 --> 00:50:57,280 background dash color to our text color, 1189 00:50:54,160 --> 00:51:00,480 which is this. 1190 00:50:57,280 --> 00:51:04,160 Copy and paste. 1191 00:51:00,480 --> 00:51:05,920 And we also want to set the text color 1192 00:51:04,160 --> 00:51:09,280 to our background color. So, we're going 1193 00:51:05,920 --> 00:51:14,000 to switch them up. Let's copy, paste 1194 00:51:09,280 --> 00:51:15,680 here. Save it and refresh. 1195 00:51:14,000 --> 00:51:20,240 And now when we hover over our join 1196 00:51:15,680 --> 00:51:22,079 button, that looks pretty good. 1197 00:51:20,240 --> 00:51:23,839 The next thing is when we click the join 1198 00:51:22,079 --> 00:51:26,240 button, you'll notice that it also fades 1199 00:51:23,839 --> 00:51:29,119 out. So we're going to add an active 1200 00:51:26,240 --> 00:51:32,559 pseudo class to this button as well. So 1201 00:51:29,119 --> 00:51:35,359 target the join button class and add a 1202 00:51:32,559 --> 00:51:38,000 pseudo class called active. 1203 00:51:35,359 --> 00:51:40,079 So these styles will activate when we 1204 00:51:38,000 --> 00:51:44,559 click this element. 1205 00:51:40,079 --> 00:51:50,240 So, let's set the opacity to maybe 0.7 1206 00:51:44,559 --> 00:51:51,839 maybe. Save it. Refresh. Click it. Okay. 1207 00:51:50,240 --> 00:51:55,040 So, I think that looks close enough. So, 1208 00:51:51,839 --> 00:51:57,440 0.7 looks pretty good. 1209 00:51:55,040 --> 00:52:00,640 So, that is how we set hover styles and 1210 00:51:57,440 --> 00:52:01,920 other pseudo classes with our CSS code. 1211 00:52:00,640 --> 00:52:04,240 Next, we're going to learn how to 1212 00:52:01,920 --> 00:52:06,480 transition smoothly between these two 1213 00:52:04,240 --> 00:52:08,800 styles. So, for example, if we go back 1214 00:52:06,480 --> 00:52:10,480 into our project and we hover over this 1215 00:52:08,800 --> 00:52:12,319 button, you'll notice that the 1216 00:52:10,480 --> 00:52:16,200 background color and the text color 1217 00:52:12,319 --> 00:52:16,200 change smoothly. 1218 00:52:16,319 --> 00:52:20,880 But for our colors, it changes almost 1219 00:52:19,200 --> 00:52:23,680 instantly. So, how do we make this 1220 00:52:20,880 --> 00:52:25,440 transition? 1221 00:52:23,680 --> 00:52:28,960 So, to do that, we're going to scroll up 1222 00:52:25,440 --> 00:52:31,280 to our subscribe button first. 1223 00:52:28,960 --> 00:52:33,599 We're going to add a property called 1224 00:52:31,280 --> 00:52:36,240 transition. 1225 00:52:33,599 --> 00:52:38,000 So transition property takes two values. 1226 00:52:36,240 --> 00:52:40,640 The first one is what we want to 1227 00:52:38,000 --> 00:52:43,839 transition. So in our case, we want to 1228 00:52:40,640 --> 00:52:45,760 transition the opacity smoothly. So we 1229 00:52:43,839 --> 00:52:47,680 want to smoothly fade out the button 1230 00:52:45,760 --> 00:52:49,520 when we hover over it instead of 1231 00:52:47,680 --> 00:52:53,680 instantaneously. 1232 00:52:49,520 --> 00:52:56,240 So let's transition the opacity. 1233 00:52:53,680 --> 00:52:59,359 And the second value is how long this 1234 00:52:56,240 --> 00:53:02,720 transition will take. For example, let's 1235 00:52:59,359 --> 00:53:06,480 set it to 1 s, which is 1 second. 1236 00:53:02,720 --> 00:53:09,200 end it with a semicolon and save. 1237 00:53:06,480 --> 00:53:11,200 Let's go back and refresh. And now when 1238 00:53:09,200 --> 00:53:14,400 we hover over our button, you'll notice 1239 00:53:11,200 --> 00:53:15,920 that the opacity changes smoothly. Now 1240 00:53:14,400 --> 00:53:19,040 it might be a little bit hard to see. So 1241 00:53:15,920 --> 00:53:20,880 let's change this to 0.1 to show you the 1242 00:53:19,040 --> 00:53:23,200 effect. 1243 00:53:20,880 --> 00:53:25,680 Refresh. So now you can see that the 1244 00:53:23,200 --> 00:53:28,680 opacity is changing smoothly over 1 1245 00:53:25,680 --> 00:53:28,680 second. 1246 00:53:29,040 --> 00:53:33,440 So, this is how you transition between 1247 00:53:31,440 --> 00:53:35,839 different styles when you're hovering 1248 00:53:33,440 --> 00:53:39,040 over them. Now, let's set it back to 1249 00:53:35,839 --> 00:53:41,599 0.8. And we're going to change 1 second 1250 00:53:39,040 --> 00:53:44,240 because it's a little bit too long. So, 1251 00:53:41,599 --> 00:53:48,400 usually a good transition duration is 1252 00:53:44,240 --> 00:53:50,240 something like 0.15 seconds. 1253 00:53:48,400 --> 00:53:53,040 So, it's pretty fast, but it's not too 1254 00:53:50,240 --> 00:53:55,359 fast, and it's not too slow. Let's go to 1255 00:53:53,040 --> 00:53:57,839 our web page and refresh. Now, when we 1256 00:53:55,359 --> 00:53:59,280 hover over it, we get a nice smooth 1257 00:53:57,839 --> 00:54:01,280 transition. It might be a little bit 1258 00:53:59,280 --> 00:54:03,839 hard to tell, but we do get a nice 1259 00:54:01,280 --> 00:54:06,079 smooth transition 1260 00:54:03,839 --> 00:54:08,559 instead of what we had before, which 1261 00:54:06,079 --> 00:54:10,400 transitioned immediately. Let's work on 1262 00:54:08,559 --> 00:54:13,520 the join button now. So, this one is a 1263 00:54:10,400 --> 00:54:15,839 lot easier to see the difference. 1264 00:54:13,520 --> 00:54:17,200 Let's scroll down to the join button. 1265 00:54:15,839 --> 00:54:20,240 And again, we're going to add a 1266 00:54:17,200 --> 00:54:23,040 transition. So, we're going to add 1267 00:54:20,240 --> 00:54:24,880 transition. 1268 00:54:23,040 --> 00:54:27,839 And we're going to give it two values. 1269 00:54:24,880 --> 00:54:30,640 What we want to transition and how long. 1270 00:54:27,839 --> 00:54:33,359 First, let's transition the background 1271 00:54:30,640 --> 00:54:38,000 dash color. And how long? We're going to 1272 00:54:33,359 --> 00:54:41,359 transition for 1 second as an example. 1273 00:54:38,000 --> 00:54:43,280 Let's save our file and refresh. 1274 00:54:41,359 --> 00:54:45,680 Now, when we hover over the join button, 1275 00:54:43,280 --> 00:54:48,240 the background color changes smoothly 1276 00:54:45,680 --> 00:54:50,800 over 1 second. But you'll notice that 1277 00:54:48,240 --> 00:54:53,839 the text color changes immediately. 1278 00:54:50,800 --> 00:54:55,920 Whereas the text color here also kind of 1279 00:54:53,839 --> 00:54:58,400 transitions. 1280 00:54:55,920 --> 00:55:01,839 So to make the text color transition as 1281 00:54:58,400 --> 00:55:03,440 well, we need to add another property to 1282 00:55:01,839 --> 00:55:05,680 transition. So we can actually 1283 00:55:03,440 --> 00:55:08,800 transition multiple properties. We just 1284 00:55:05,680 --> 00:55:10,800 have to separate it with a comma. So if 1285 00:55:08,800 --> 00:55:13,119 we have a comma here, we can add another 1286 00:55:10,800 --> 00:55:16,000 property to transition. This time I'm 1287 00:55:13,119 --> 00:55:18,240 going to transition the color. And we're 1288 00:55:16,000 --> 00:55:21,200 also going to give it a duration which 1289 00:55:18,240 --> 00:55:24,160 is 1 second. So how long it takes to 1290 00:55:21,200 --> 00:55:26,880 transition this property. 1291 00:55:24,160 --> 00:55:29,119 Save it and refresh. 1292 00:55:26,880 --> 00:55:31,280 Now when we hover over this button, it 1293 00:55:29,119 --> 00:55:35,359 will transition both background color 1294 00:55:31,280 --> 00:55:37,280 and the color smoothly over 1 second. 1295 00:55:35,359 --> 00:55:39,839 And that's basically how transitions 1296 00:55:37,280 --> 00:55:43,359 work. So sometimes you might be tempted 1297 00:55:39,839 --> 00:55:46,800 to put this transition property into the 1298 00:55:43,359 --> 00:55:48,799 hover because you think that we want to 1299 00:55:46,800 --> 00:55:51,440 transition when we hover. So we have to 1300 00:55:48,799 --> 00:55:54,400 put it here. Now the problem with this 1301 00:55:51,440 --> 00:55:56,400 is that if we refresh when we hover over 1302 00:55:54,400 --> 00:55:59,520 the button everything looks good but as 1303 00:55:56,400 --> 00:56:01,839 soon as we hover out these styles change 1304 00:55:59,520 --> 00:56:03,599 immediately and that's because remember 1305 00:56:01,839 --> 00:56:06,799 these styles only apply when we're 1306 00:56:03,599 --> 00:56:08,720 hovering. So if we are hovering then we 1307 00:56:06,799 --> 00:56:11,119 have a transition. But as soon as we 1308 00:56:08,720 --> 00:56:13,280 take off the hover, it's the same thing 1309 00:56:11,119 --> 00:56:15,440 as having no transition at all. So 1310 00:56:13,280 --> 00:56:17,839 that's one common pitfall of the 1311 00:56:15,440 --> 00:56:20,240 transition property. So let's move it 1312 00:56:17,839 --> 00:56:22,160 back here where it should be. So just 1313 00:56:20,240 --> 00:56:27,799 make sure that you put the transition 1314 00:56:22,160 --> 00:56:27,799 always in this sort of base CSS style. 1315 00:56:28,000 --> 00:56:31,920 The last thing we're going to learn in 1316 00:56:29,280 --> 00:56:34,079 this lesson is how to create shadows. If 1317 00:56:31,920 --> 00:56:36,960 we go to our project and we look at our 1318 00:56:34,079 --> 00:56:38,720 design, I'm going to zoom in here. When 1319 00:56:36,960 --> 00:56:40,960 I hover over the tweet button, it 1320 00:56:38,720 --> 00:56:42,319 creates a faint shadow under the button. 1321 00:56:40,960 --> 00:56:46,400 So, we're going to learn how to create 1322 00:56:42,319 --> 00:56:48,960 this. So, let's zoom out for now. 1323 00:56:46,400 --> 00:56:51,599 We're going to go down to the tweet 1324 00:56:48,960 --> 00:56:54,079 button styles. And the shadow is just 1325 00:56:51,599 --> 00:56:59,119 another CSS property. So, the property 1326 00:56:54,079 --> 00:57:02,559 for a shadow is box dash shadow 1327 00:56:59,119 --> 00:57:06,160 colon. Now, box shadow actually takes 1328 00:57:02,559 --> 00:57:09,520 four values. So, I'm going to set the 1329 00:57:06,160 --> 00:57:12,000 values to zero for now. And then we're 1330 00:57:09,520 --> 00:57:15,839 going to change them one by one to see 1331 00:57:12,000 --> 00:57:18,480 how they work. Let's save this and 1332 00:57:15,839 --> 00:57:20,400 refresh. And now we do have a shadow, 1333 00:57:18,480 --> 00:57:23,280 but we can't see it because it's right 1334 00:57:20,400 --> 00:57:25,280 underneath the button. 1335 00:57:23,280 --> 00:57:28,000 So, the first value here determines the 1336 00:57:25,280 --> 00:57:31,119 horizontal position of the shadow. For 1337 00:57:28,000 --> 00:57:34,799 example, I can set it to 10 pixels. And 1338 00:57:31,119 --> 00:57:38,480 if I save, the shadow will appear 10 1339 00:57:34,799 --> 00:57:40,400 pixels to the right. The second value 1340 00:57:38,480 --> 00:57:43,440 sets the vertical position of the 1341 00:57:40,400 --> 00:57:46,720 shadow. For example, if I set it to 10 1342 00:57:43,440 --> 00:57:49,920 pixels in the second value, it will push 1343 00:57:46,720 --> 00:57:52,319 it 10 pixels down. So now you can see we 1344 00:57:49,920 --> 00:57:54,559 actually do have a shadow 10 pixels to 1345 00:57:52,319 --> 00:57:57,920 the right and 10 pixels down from the 1346 00:57:54,559 --> 00:58:01,520 button. Now the third value here is the 1347 00:57:57,920 --> 00:58:04,480 blur. So if we set the blur to maybe 10 1348 00:58:01,520 --> 00:58:08,319 pixels save, 1349 00:58:04,480 --> 00:58:10,559 refresh. Now the shadow becomes blurred. 1350 00:58:08,319 --> 00:58:12,559 And the last value is obviously the 1351 00:58:10,559 --> 00:58:14,160 color. So we can actually change it to 1352 00:58:12,559 --> 00:58:15,599 whatever we want. We're going to 1353 00:58:14,160 --> 00:58:19,839 actually change it to something like 1354 00:58:15,599 --> 00:58:22,880 red. Save it. Refresh. And we get a red 1355 00:58:19,839 --> 00:58:25,839 shadow. So this is basically how shadows 1356 00:58:22,880 --> 00:58:29,760 work. We have a horizontal position, a 1357 00:58:25,839 --> 00:58:31,280 vertical position, blur, and color. So, 1358 00:58:29,760 --> 00:58:32,960 don't worry. The more that you work with 1359 00:58:31,280 --> 00:58:35,920 shadows, the more you'll get familiar 1360 00:58:32,960 --> 00:58:37,839 with what these four values can do. So, 1361 00:58:35,920 --> 00:58:41,040 let's try creating a more realistic 1362 00:58:37,839 --> 00:58:43,440 shadow. Usually, shadows aren't red or 1363 00:58:41,040 --> 00:58:45,440 any color. They're usually kind of a 1364 00:58:43,440 --> 00:58:46,960 darker shade of whatever they're 1365 00:58:45,440 --> 00:58:48,559 covering. 1366 00:58:46,960 --> 00:58:50,240 So, to create a color like that, we're 1367 00:58:48,559 --> 00:58:53,040 going to need a new way of measuring 1368 00:58:50,240 --> 00:58:55,119 color. So, let's get rid of this and 1369 00:58:53,040 --> 00:58:58,119 we're going to use something called 1370 00:58:55,119 --> 00:58:58,119 RGBA. 1371 00:58:58,480 --> 00:59:06,079 RGBA is the same thing as RGB except 1372 00:59:02,799 --> 00:59:08,160 there is an A value. So, this A value 1373 00:59:06,079 --> 00:59:11,119 essentially means the opacity of the 1374 00:59:08,160 --> 00:59:14,640 color, how see-through it is. We can set 1375 00:59:11,119 --> 00:59:18,000 the RGB to 0 0. 1376 00:59:14,640 --> 00:59:20,640 That gets us to black as we learned. And 1377 00:59:18,000 --> 00:59:23,599 then the fourth value is our A value. If 1378 00:59:20,640 --> 00:59:26,880 we set it to one and save, this is going 1379 00:59:23,599 --> 00:59:29,599 to be pure black. But as we decrease the 1380 00:59:26,880 --> 00:59:31,599 a value, the color is going to get more 1381 00:59:29,599 --> 00:59:34,640 and more faded out and more and more 1382 00:59:31,599 --> 00:59:37,640 transparent. So if we decrease it to 1383 00:59:34,640 --> 00:59:37,640 0.6, 1384 00:59:37,680 --> 00:59:44,160 save and refresh. Now this color is 1385 00:59:40,640 --> 00:59:46,799 getting more transparent and faded out. 1386 00:59:44,160 --> 00:59:51,520 So, a pretty natural color for a shadow 1387 00:59:46,799 --> 00:59:53,040 is something pretty faint, like 0.15. 1388 00:59:51,520 --> 00:59:55,280 So, for shadows, we usually don't want 1389 00:59:53,040 --> 00:59:58,240 it to be too noticeable. Shadows are 1390 00:59:55,280 --> 00:59:59,680 best when they're very subtle. 1391 00:59:58,240 --> 01:00:01,520 And now, we kind of want to move the 1392 00:59:59,680 --> 01:00:03,839 shadow a little bit closer to the button 1393 01:00:01,520 --> 01:00:07,119 so it looks a little more natural. So, 1394 01:00:03,839 --> 01:00:09,040 let's actually move it maybe five pixels 1395 01:00:07,119 --> 01:00:12,319 and five pixels. Let's see how that 1396 01:00:09,040 --> 01:00:14,799 looks. Save it and refresh. Okay, I 1397 01:00:12,319 --> 01:00:17,200 think that looks pretty good. So that's 1398 01:00:14,799 --> 01:00:19,839 how we create a natural looking shadow 1399 01:00:17,200 --> 01:00:22,079 with the box shadow property. We have 1400 01:00:19,839 --> 01:00:25,040 four values. The horizontal position, 1401 01:00:22,079 --> 01:00:28,400 vertical position, the blur, and the 1402 01:00:25,040 --> 01:00:30,720 color measured with RGBA. The A value 1403 01:00:28,400 --> 01:00:32,799 means opacity or how see-through this 1404 01:00:30,720 --> 01:00:35,040 color is. 1405 01:00:32,799 --> 01:00:37,119 The final step of this lesson is to only 1406 01:00:35,040 --> 01:00:40,160 make this shadow appear when we hover 1407 01:00:37,119 --> 01:00:43,359 over the button. So for example for here 1408 01:00:40,160 --> 01:00:45,520 if we hover over we can see the shadow. 1409 01:00:43,359 --> 01:00:48,319 If we're not the shadow's gone. So this 1410 01:00:45,520 --> 01:00:50,000 is another style of button that we can 1411 01:00:48,319 --> 01:00:53,599 create. 1412 01:00:50,000 --> 01:00:55,760 So let's use what we learned so far. 1413 01:00:53,599 --> 01:00:57,920 Remember we first use a dot to target 1414 01:00:55,760 --> 01:00:59,520 the class. So we're going to target the 1415 01:00:57,920 --> 01:01:03,440 tweet-button 1416 01:00:59,520 --> 01:01:06,000 class. We're going to add a pseudo class 1417 01:01:03,440 --> 01:01:08,640 here called hover. 1418 01:01:06,000 --> 01:01:12,559 And then we're going to move our shadow 1419 01:01:08,640 --> 01:01:15,440 into the hover pseudo class. Let's cut 1420 01:01:12,559 --> 01:01:18,319 and paste in here. 1421 01:01:15,440 --> 01:01:21,280 So remember the way this works is that 1422 01:01:18,319 --> 01:01:23,280 let's refresh first. If we are not 1423 01:01:21,280 --> 01:01:25,920 hovering over the button, we get all of 1424 01:01:23,280 --> 01:01:27,680 these styles. If we are hovering over 1425 01:01:25,920 --> 01:01:29,920 the button, we're going to get these 1426 01:01:27,680 --> 01:01:32,000 styles, these hover styles, as well as 1427 01:01:29,920 --> 01:01:36,319 all of these. So these styles get added 1428 01:01:32,000 --> 01:01:38,400 on when we hover. So now when we refresh 1429 01:01:36,319 --> 01:01:41,280 and we hover over this button, we're 1430 01:01:38,400 --> 01:01:43,200 going to get a pretty subtle shadow. So 1431 01:01:41,280 --> 01:01:45,680 not perfect, but I think it's close 1432 01:01:43,200 --> 01:01:47,440 enough to what we want. Now the last 1433 01:01:45,680 --> 01:01:49,839 thing we're going to do is to transition 1434 01:01:47,440 --> 01:01:52,480 the shadow. So we can actually 1435 01:01:49,839 --> 01:01:57,839 transition the shadow pretty easily by 1436 01:01:52,480 --> 01:01:59,280 just adding the transition property. 1437 01:01:57,839 --> 01:02:01,760 And we're going to tell it what we want 1438 01:01:59,280 --> 01:02:05,200 to transition and how long. So, you want 1439 01:02:01,760 --> 01:02:07,359 to transition the box dash shadow 1440 01:02:05,200 --> 01:02:10,960 and let's transition it to something 1441 01:02:07,359 --> 01:02:14,160 natural like 0.15 seconds. 1442 01:02:10,960 --> 01:02:16,000 Now, save and refresh. 1443 01:02:14,160 --> 01:02:18,880 Now, when we hover over this button, we 1444 01:02:16,000 --> 01:02:21,440 get a nice transition on the shadow like 1445 01:02:18,880 --> 01:02:22,480 this. 1446 01:02:21,440 --> 01:02:24,640 All right. So, the last thing we're 1447 01:02:22,480 --> 01:02:26,559 going to do is I realized I forgot to 1448 01:02:24,640 --> 01:02:29,280 change the durations here. So let's 1449 01:02:26,559 --> 01:02:31,440 change it to 0.15 1450 01:02:29,280 --> 01:02:34,400 and 0.15. 1451 01:02:31,440 --> 01:02:36,400 Let's save it and refresh. 1452 01:02:34,400 --> 01:02:39,119 So now this looks something like what we 1453 01:02:36,400 --> 01:02:41,200 have in our designs. 1454 01:02:39,119 --> 01:02:43,920 So we just learned some intermediate 1455 01:02:41,200 --> 01:02:46,160 HTML skills such as creating hover 1456 01:02:43,920 --> 01:02:50,599 effects, other pseudo classes, 1457 01:02:46,160 --> 01:02:50,599 transitions, and shadows. 1458 01:02:50,880 --> 01:02:55,359 Here are some more exercises from famous 1459 01:02:53,200 --> 01:02:57,359 websites that you can try to copy. This 1460 01:02:55,359 --> 01:03:00,359 time we're also going to copy the hover 1461 01:02:57,359 --> 01:03:00,359 styles. 1462 01:03:00,640 --> 01:03:07,160 As always, you can find these solutions 1463 01:03:02,160 --> 01:03:07,160 and more exercises below the video. 1464 01:03:12,880 --> 01:03:16,000 In this lesson, we're going to learn 1465 01:03:14,160 --> 01:03:17,760 about one of the most useful tools for 1466 01:03:16,000 --> 01:03:19,760 web development called the Chrome 1467 01:03:17,760 --> 01:03:21,760 DevTools. And we're going to use the Dev 1468 01:03:19,760 --> 01:03:24,559 Tools to get perfect colors for our 1469 01:03:21,760 --> 01:03:26,480 buttons. So, first of all, what are the 1470 01:03:24,559 --> 01:03:28,480 Chrome Dev Tools? So, I find that it's a 1471 01:03:26,480 --> 01:03:30,480 lot easier to demonstrate it than to try 1472 01:03:28,480 --> 01:03:32,480 to explain it. So, let's go to our 1473 01:03:30,480 --> 01:03:34,559 website 1474 01:03:32,480 --> 01:03:36,559 and we're going to rightclick in an 1475 01:03:34,559 --> 01:03:39,839 empty area 1476 01:03:36,559 --> 01:03:43,280 and we're going to click inspect 1477 01:03:39,839 --> 01:03:45,680 and this will open up the dev tools. 1478 01:03:43,280 --> 01:03:48,960 So, the cool thing about this is that we 1479 01:03:45,680 --> 01:03:51,119 can now see all the HTML on our page. If 1480 01:03:48,960 --> 01:03:53,839 we drill down here, we can see all the 1481 01:03:51,119 --> 01:03:57,119 buttons. So, this is a great way to 1482 01:03:53,839 --> 01:03:59,200 visualize the HTML as well as the CSS on 1483 01:03:57,119 --> 01:04:02,319 our page. If I click into one of these 1484 01:03:59,200 --> 01:04:05,200 buttons, I can see all the CSS that is 1485 01:04:02,319 --> 01:04:07,680 applied to this button. So, what's even 1486 01:04:05,200 --> 01:04:09,760 better is that we can open the dev tools 1487 01:04:07,680 --> 01:04:14,160 in any website that we want. So, we can 1488 01:04:09,760 --> 01:04:16,640 actually open it in superimple.dev. 1489 01:04:14,160 --> 01:04:19,839 And you can see all the HTML that is on 1490 01:04:16,640 --> 01:04:21,520 this website as well as all the CSS. So 1491 01:04:19,839 --> 01:04:23,520 this is a really great tool where you 1492 01:04:21,520 --> 01:04:25,760 can open it in any website that you want 1493 01:04:23,520 --> 01:04:28,319 and see the exact styles that they're 1494 01:04:25,760 --> 01:04:30,160 using on that website. 1495 01:04:28,319 --> 01:04:32,880 The next feature I want to show you is 1496 01:04:30,160 --> 01:04:34,720 this pointer icon in the top left. So 1497 01:04:32,880 --> 01:04:37,039 instead of trying to find these buttons 1498 01:04:34,720 --> 01:04:39,359 in all of this HTML, we can actually 1499 01:04:37,039 --> 01:04:41,520 click this pointer icon and it will let 1500 01:04:39,359 --> 01:04:44,319 us hover over any element on the web 1501 01:04:41,520 --> 01:04:46,799 page and show it down here. So if we 1502 01:04:44,319 --> 01:04:49,520 hover over this tweet button and click 1503 01:04:46,799 --> 01:04:51,359 it, it will find the element for us in 1504 01:04:49,520 --> 01:04:53,920 the HTML. 1505 01:04:51,359 --> 01:04:56,160 And now we can look at these styles here 1506 01:04:53,920 --> 01:04:57,680 to see what kind of styles and more 1507 01:04:56,160 --> 01:05:00,160 importantly what kind of background 1508 01:04:57,680 --> 01:05:02,880 color is set on this button so that we 1509 01:05:00,160 --> 01:05:04,880 can get a perfect background color. So 1510 01:05:02,880 --> 01:05:06,960 one thing to note is that this 1511 01:05:04,880 --> 01:05:09,280 background color is actually another way 1512 01:05:06,960 --> 01:05:12,720 of measuring color. So currently we 1513 01:05:09,280 --> 01:05:14,559 learned about RGB. Now we have another 1514 01:05:12,720 --> 01:05:17,359 way of measuring color and this is 1515 01:05:14,559 --> 01:05:20,400 called hex. It's basically the same as 1516 01:05:17,359 --> 01:05:23,200 RGB. The first two characters here one 1517 01:05:20,400 --> 01:05:25,039 and D represent how much red. The second 1518 01:05:23,200 --> 01:05:28,079 two represent how much green and the 1519 01:05:25,039 --> 01:05:29,839 third two represent how much blue. So 1520 01:05:28,079 --> 01:05:33,200 with a little bit of math we can convert 1521 01:05:29,839 --> 01:05:36,480 from hex to RGB. 1522 01:05:33,200 --> 01:05:40,240 So, I just Google a hex to RGB 1523 01:05:36,480 --> 01:05:44,160 calculator and I find any calculator and 1524 01:05:40,240 --> 01:05:47,039 then I use it to convert the hex value. 1525 01:05:44,160 --> 01:05:49,680 So, I'm going to copy this into the 1526 01:05:47,039 --> 01:05:52,240 calculator and then convert it and it 1527 01:05:49,680 --> 01:05:54,960 will give me the RGB value. So, it'll do 1528 01:05:52,240 --> 01:05:56,960 that math for me. So, that's just 1529 01:05:54,960 --> 01:05:59,599 another way of measuring color called 1530 01:05:56,960 --> 01:06:02,720 hex. The next feature I want to show you 1531 01:05:59,599 --> 01:06:04,799 in the dev tools is this computed tab. 1532 01:06:02,720 --> 01:06:07,440 So this tab actually shows us all the 1533 01:06:04,799 --> 01:06:09,839 final styles that are applied to this 1534 01:06:07,440 --> 01:06:12,000 element. So we can actually scroll down 1535 01:06:09,839 --> 01:06:14,880 here and we can find the background 1536 01:06:12,000 --> 01:06:18,480 color and the RGB value. We can also 1537 01:06:14,880 --> 01:06:20,799 find things like the height, the final 1538 01:06:18,480 --> 01:06:22,720 calculated height, the final calculated 1539 01:06:20,799 --> 01:06:25,440 width so that we can get the perfect 1540 01:06:22,720 --> 01:06:28,240 size as well as the perfect background 1541 01:06:25,440 --> 01:06:30,480 color. So, let's actually just use the 1542 01:06:28,240 --> 01:06:33,520 background color here. 1543 01:06:30,480 --> 01:06:35,839 And we're going to copy this and paste 1544 01:06:33,520 --> 01:06:38,720 this into our code. So, we're going to 1545 01:06:35,839 --> 01:06:41,280 get an exact color instead of trying to 1546 01:06:38,720 --> 01:06:44,880 guess it like we were before. So, if I 1547 01:06:41,280 --> 01:06:47,920 copy and paste here, save it, and now I 1548 01:06:44,880 --> 01:06:51,680 refresh. Now, our button has the exact 1549 01:06:47,920 --> 01:06:54,000 same color as what we have here. So, the 1550 01:06:51,680 --> 01:06:56,799 same thing happens for the join button. 1551 01:06:54,000 --> 01:06:58,559 Let's click this icon here and hover 1552 01:06:56,799 --> 01:07:01,760 over the join button to find it in the 1553 01:06:58,559 --> 01:07:04,319 HTML. Click. And now we can see all 1554 01:07:01,760 --> 01:07:06,880 these styles, all the final computed 1555 01:07:04,319 --> 01:07:10,400 styles on the join button. So most 1556 01:07:06,880 --> 01:07:14,480 importantly, we can find the 1557 01:07:10,400 --> 01:07:16,799 border color, which is this. 1558 01:07:14,480 --> 01:07:18,880 Let's go into let's copy it and put it 1559 01:07:16,799 --> 01:07:22,079 into our CSS so that we can get a 1560 01:07:18,880 --> 01:07:25,119 perfect color. end it with a semicolon 1561 01:07:22,079 --> 01:07:30,480 to follow the syntax rules. Okay, copy 1562 01:07:25,119 --> 01:07:34,079 it there and copy it here. 1563 01:07:30,480 --> 01:07:36,400 Now, we're going to save, refresh, 1564 01:07:34,079 --> 01:07:40,400 and now our button color is going to 1565 01:07:36,400 --> 01:07:42,559 match the design exactly. 1566 01:07:40,400 --> 01:07:48,000 So, that's how you use the dev tools to 1567 01:07:42,559 --> 01:07:49,839 get perfect color for our HTML elements. 1568 01:07:48,000 --> 01:07:52,400 Now we're going to learn about the CSS 1569 01:07:49,839 --> 01:07:54,720 box model which basically allows us to 1570 01:07:52,400 --> 01:07:56,960 add space between our elements like this 1571 01:07:54,720 --> 01:07:59,599 as well as add space inside our element 1572 01:07:56,960 --> 01:08:02,319 to make it bigger. The first part of the 1573 01:07:59,599 --> 01:08:05,359 box model is spacing on the outside of 1574 01:08:02,319 --> 01:08:07,039 the element. This is called margin. If 1575 01:08:05,359 --> 01:08:09,280 we look at our code, we already worked 1576 01:08:07,039 --> 01:08:12,240 with margin before. Here we set the 1577 01:08:09,280 --> 01:08:14,079 margin right to 8 pixels. That means 1578 01:08:12,240 --> 01:08:17,199 that we added space on the outside of 1579 01:08:14,079 --> 01:08:19,920 the button on the right of 8 pixels. If 1580 01:08:17,199 --> 01:08:23,520 we change the margin right to 30 pixels, 1581 01:08:19,920 --> 01:08:25,600 for example, and save and refresh, now 1582 01:08:23,520 --> 01:08:28,640 there's 30 pixels of space on the 1583 01:08:25,600 --> 01:08:30,560 outside on the right side of the button. 1584 01:08:28,640 --> 01:08:33,199 So, we can add margin to all four 1585 01:08:30,560 --> 01:08:37,199 directions, top, right, bottom, and 1586 01:08:33,199 --> 01:08:39,199 left. Let's try adding margin to the 1587 01:08:37,199 --> 01:08:42,560 left side of the button. This time we're 1588 01:08:39,199 --> 01:08:46,400 going to add margin left of 20 pixels. 1589 01:08:42,560 --> 01:08:48,480 Save it and refresh. And that adds space 1590 01:08:46,400 --> 01:08:51,199 on the outside of the button on the left 1591 01:08:48,480 --> 01:08:53,839 of 20 pixels. So that's basically how 1592 01:08:51,199 --> 01:08:56,560 margin works. It lets us add spacing on 1593 01:08:53,839 --> 01:08:58,719 the outside of the element. The second 1594 01:08:56,560 --> 01:09:00,880 part of the box model is spacing on the 1595 01:08:58,719 --> 01:09:05,279 inside of the element. So basically all 1596 01:09:00,880 --> 01:09:07,520 the spacing in here around our text. 1597 01:09:05,279 --> 01:09:09,440 So currently, if we look at our code, 1598 01:09:07,520 --> 01:09:11,759 we're setting the height and width of 1599 01:09:09,440 --> 01:09:14,159 our buttons. And this is not actually a 1600 01:09:11,759 --> 01:09:18,000 good idea. I'll show you why. I'm going 1601 01:09:14,159 --> 01:09:20,640 to scroll down to the join button cuz 1602 01:09:18,000 --> 01:09:23,920 it's a little easier to see. And I'm 1603 01:09:20,640 --> 01:09:28,000 going to change the text to join my 1604 01:09:23,920 --> 01:09:29,440 channel. Save it and refresh. And you'll 1605 01:09:28,000 --> 01:09:31,839 notice that the text is actually 1606 01:09:29,440 --> 01:09:35,040 overflowing the button like this. And 1607 01:09:31,839 --> 01:09:37,120 that's because if we scroll up, 1608 01:09:35,040 --> 01:09:38,640 we're setting the height and the width. 1609 01:09:37,120 --> 01:09:41,040 That means that we're forcing the button 1610 01:09:38,640 --> 01:09:43,679 to have a height of 36 pixels and a 1611 01:09:41,040 --> 01:09:46,480 width of 62 pixels. But here, notice 1612 01:09:43,679 --> 01:09:49,600 that our content is too big. So what we 1613 01:09:46,480 --> 01:09:53,279 want to do is to remove these lines and 1614 01:09:49,600 --> 01:09:55,360 save it and refresh the page. And by 1615 01:09:53,279 --> 01:09:58,159 default, our button actually adjust the 1616 01:09:55,360 --> 01:10:00,000 size automatically based on the content. 1617 01:09:58,159 --> 01:10:01,840 So now instead of setting the height and 1618 01:10:00,000 --> 01:10:04,159 the width, we're going to achieve the 1619 01:10:01,840 --> 01:10:07,040 same thing by adding spacing on the 1620 01:10:04,159 --> 01:10:08,719 inside of the button. So the spacing on 1621 01:10:07,040 --> 01:10:10,239 the inside of the button is called 1622 01:10:08,719 --> 01:10:11,920 padding. 1623 01:10:10,239 --> 01:10:15,920 Let's go into our code and give it a 1624 01:10:11,920 --> 01:10:22,320 try. So we're going to add padding dash 1625 01:10:15,920 --> 01:10:23,920 left of 30 pixels. Save it and refresh. 1626 01:10:22,320 --> 01:10:27,040 And you can see that padding adds 1627 01:10:23,920 --> 01:10:28,719 spacing on the inside of the button. And 1628 01:10:27,040 --> 01:10:31,440 just like margin, we can set padding in 1629 01:10:28,719 --> 01:10:35,360 all four directions. So let's try adding 1630 01:10:31,440 --> 01:10:41,120 padding dashtop 1631 01:10:35,360 --> 01:10:42,480 to 20 pixels. Save that and refresh. 1632 01:10:41,120 --> 01:10:46,000 And now you can see that we added 1633 01:10:42,480 --> 01:10:47,760 padding on the top by 20 pixels. 1634 01:10:46,000 --> 01:10:49,440 So we can actually use the Chrome dev 1635 01:10:47,760 --> 01:10:51,520 tools that we learned earlier to 1636 01:10:49,440 --> 01:10:54,400 visualize the margin and padding of our 1637 01:10:51,520 --> 01:10:56,159 elements. Let's go into a blank area of 1638 01:10:54,400 --> 01:10:59,600 our web page and we're going to 1639 01:10:56,159 --> 01:11:02,560 rightclick and inspect and then click 1640 01:10:59,600 --> 01:11:05,760 this top left icon and then click our 1641 01:11:02,560 --> 01:11:07,760 subscribe button. So I'm going to drag 1642 01:11:05,760 --> 01:11:11,960 this down and then we're going to go 1643 01:11:07,760 --> 01:11:11,960 into the computed tab. 1644 01:11:12,000 --> 01:11:16,640 So this section is basically the box 1645 01:11:14,080 --> 01:11:18,640 model. We have our margin which is the 1646 01:11:16,640 --> 01:11:21,199 space on the outside of the element. You 1647 01:11:18,640 --> 01:11:23,440 can see that highlighted in orange. We 1648 01:11:21,199 --> 01:11:25,199 have the border which we learned earlier 1649 01:11:23,440 --> 01:11:27,440 and we have the padding which is the 1650 01:11:25,199 --> 01:11:29,679 space on the inside of the element which 1651 01:11:27,440 --> 01:11:31,679 you can see highlighted in green. 1652 01:11:29,679 --> 01:11:34,400 Buttons by default have a padding of six 1653 01:11:31,679 --> 01:11:37,120 pixels on the left and right and one 1654 01:11:34,400 --> 01:11:39,199 pixel on top and bottom. 1655 01:11:37,120 --> 01:11:41,280 So let's click this top left again and 1656 01:11:39,199 --> 01:11:44,159 go to our join button and click this 1657 01:11:41,280 --> 01:11:46,400 button. In this example we have padding 1658 01:11:44,159 --> 01:11:48,480 on the top of 20 pixels which is what we 1659 01:11:46,400 --> 01:11:50,800 have in our code. We have padding on the 1660 01:11:48,480 --> 01:11:52,800 left of 30 pixels, also what we have in 1661 01:11:50,800 --> 01:11:55,440 our code. And then we have a default 1662 01:11:52,800 --> 01:11:58,239 padding of 6 pixels on the right and 1 1663 01:11:55,440 --> 01:12:00,560 pixel at the bottom. And for this 1664 01:11:58,239 --> 01:12:02,640 button, we have a border of one pixel 1665 01:12:00,560 --> 01:12:05,120 wide, which you can see here in our 1666 01:12:02,640 --> 01:12:07,760 code. 1667 01:12:05,120 --> 01:12:10,400 So all of these combined make up the CSS 1668 01:12:07,760 --> 01:12:12,320 box model. This basically determines how 1669 01:12:10,400 --> 01:12:14,800 much space an element takes up on the 1670 01:12:12,320 --> 01:12:17,800 page and how far it is away from other 1671 01:12:14,800 --> 01:12:17,800 elements. 1672 01:12:17,920 --> 01:12:22,000 So now that we learned the box model, 1673 01:12:19,920 --> 01:12:24,880 we're going to use it to recreate our 1674 01:12:22,000 --> 01:12:27,520 design here. So currently, if we look at 1675 01:12:24,880 --> 01:12:30,239 our code, we're using height and width. 1676 01:12:27,520 --> 01:12:33,360 Let's replace this with the box model. 1677 01:12:30,239 --> 01:12:34,880 Let's get rid of this and save it and 1678 01:12:33,360 --> 01:12:36,719 refresh. 1679 01:12:34,880 --> 01:12:39,199 And now our button's back to what it was 1680 01:12:36,719 --> 01:12:41,040 before. And now we're going to add 1681 01:12:39,199 --> 01:12:45,040 padding to this button so that it 1682 01:12:41,040 --> 01:12:48,080 matches the design at the bottom here. 1683 01:12:45,040 --> 01:12:51,679 So, let's add some padding-ash 1684 01:12:48,080 --> 01:12:53,360 top of 10 pixels. So, we'll add spacing 1685 01:12:51,679 --> 01:12:56,239 on the inside of the button at the top 1686 01:12:53,360 --> 01:12:59,280 here of 10 pixels. We're also going to 1687 01:12:56,239 --> 01:13:02,480 add padding dashbottom 1688 01:12:59,280 --> 01:13:04,000 of 10 pixels. So, let's save that and 1689 01:13:02,480 --> 01:13:06,080 refresh. 1690 01:13:04,000 --> 01:13:09,120 Okay, so now we have space at the top 1691 01:13:06,080 --> 01:13:11,120 and bottom. So, that looks pretty close. 1692 01:13:09,120 --> 01:13:13,760 We're also going to add space on the 1693 01:13:11,120 --> 01:13:18,400 inside on the left and right. So, we're 1694 01:13:13,760 --> 01:13:23,920 going to add padding dash left of 16 1695 01:13:18,400 --> 01:13:28,560 pixels and padding on the right of 16 1696 01:13:23,920 --> 01:13:31,120 pixels. So, let's save that and refresh. 1697 01:13:28,560 --> 01:13:33,199 And I think this looks close enough. So, 1698 01:13:31,120 --> 01:13:35,840 using padding, we added spacing on the 1699 01:13:33,199 --> 01:13:38,800 inside of our button. And the good thing 1700 01:13:35,840 --> 01:13:42,239 about this is that if we change the text 1701 01:13:38,800 --> 01:13:44,800 like this and save it and refresh, the 1702 01:13:42,239 --> 01:13:47,600 button will resize with the text, but it 1703 01:13:44,800 --> 01:13:49,760 will keep the spacing on the inside. So 1704 01:13:47,600 --> 01:13:52,320 using padding is a better alternative to 1705 01:13:49,760 --> 01:13:54,960 height and width. 1706 01:13:52,320 --> 01:13:57,760 So let's save that 1707 01:13:54,960 --> 01:13:59,520 and refresh the page. 1708 01:13:57,760 --> 01:14:01,920 And let's actually move these buttons 1709 01:13:59,520 --> 01:14:04,320 back closer together. So currently, if 1710 01:14:01,920 --> 01:14:07,600 we scroll up, we have margin on the 1711 01:14:04,320 --> 01:14:09,360 right of 30 pixels. So spacing on the 1712 01:14:07,600 --> 01:14:12,159 outside of the button on the right of 30 1713 01:14:09,360 --> 01:14:15,360 pixels. We're going to change it back to 1714 01:14:12,159 --> 01:14:19,840 8 pixels so that it's closer like we 1715 01:14:15,360 --> 01:14:21,760 have in our design. Save it and refresh. 1716 01:14:19,840 --> 01:14:23,040 Okay, so that looks pretty good. Now, 1717 01:14:21,760 --> 01:14:25,360 one thing you'll notice is that our 1718 01:14:23,040 --> 01:14:27,199 buttons are not aligned with each other. 1719 01:14:25,360 --> 01:14:29,120 So the join button is all the way at the 1720 01:14:27,199 --> 01:14:31,120 top while our subscribe button is a 1721 01:14:29,120 --> 01:14:34,000 little bit below. So why is this 1722 01:14:31,120 --> 01:14:37,040 happening? By default, the browser tries 1723 01:14:34,000 --> 01:14:39,920 to align our buttons based on the text. 1724 01:14:37,040 --> 01:14:42,159 So notice that the text is in one line 1725 01:14:39,920 --> 01:14:44,560 like this. So that's the default 1726 01:14:42,159 --> 01:14:46,480 behavior of the browser. This is because 1727 01:14:44,560 --> 01:14:48,000 browsers in the beginning were mostly 1728 01:14:46,480 --> 01:14:50,320 textbased. 1729 01:14:48,000 --> 01:14:52,000 Now, to override this behavior and align 1730 01:14:50,320 --> 01:14:55,520 everything to the top like we had 1731 01:14:52,000 --> 01:14:59,120 before, we can go into our CSS and we're 1732 01:14:55,520 --> 01:15:02,080 going to add a property called vertical 1733 01:14:59,120 --> 01:15:05,120 dash align. And we're going to set this 1734 01:15:02,080 --> 01:15:07,920 to top. So, instead of aligning the 1735 01:15:05,120 --> 01:15:09,360 buttons based on the text like this, 1736 01:15:07,920 --> 01:15:13,600 we're just going to align everything to 1737 01:15:09,360 --> 01:15:16,239 the top. If we save that and refresh, 1738 01:15:13,600 --> 01:15:19,120 now the subscribe button is aligned to 1739 01:15:16,239 --> 01:15:20,719 the top, which is right there. 1740 01:15:19,120 --> 01:15:24,239 Let's do the same thing for the tweet 1741 01:15:20,719 --> 01:15:28,640 button. Going to scroll down and we're 1742 01:15:24,239 --> 01:15:33,360 going to add vertical dash align colon 1743 01:15:28,640 --> 01:15:35,040 top here as well. Save and refresh. 1744 01:15:33,360 --> 01:15:37,040 And now everything's aligned properly 1745 01:15:35,040 --> 01:15:39,280 again. Now let's work on the join 1746 01:15:37,040 --> 01:15:43,199 button. I'm going to scroll down and 1747 01:15:39,280 --> 01:15:45,760 remove this extra text here. 1748 01:15:43,199 --> 01:15:48,159 Save it and refresh. And now we're going 1749 01:15:45,760 --> 01:15:51,280 to go to our CSS for the join button. So 1750 01:15:48,159 --> 01:15:53,760 I'll scroll up to right here and we're 1751 01:15:51,280 --> 01:15:55,199 going to adjust the padding. 1752 01:15:53,760 --> 01:15:56,719 So let's actually just borrow the 1753 01:15:55,199 --> 01:15:58,560 padding from the subscribe button 1754 01:15:56,719 --> 01:16:02,960 because they look pretty similar. So 1755 01:15:58,560 --> 01:16:04,640 I'll scroll up here and copy these 1756 01:16:02,960 --> 01:16:07,360 and just move them down to the join 1757 01:16:04,640 --> 01:16:10,560 button right here. 1758 01:16:07,360 --> 01:16:12,800 Save that and refresh. Okay, so that 1759 01:16:10,560 --> 01:16:14,480 looks pretty good except our join button 1760 01:16:12,800 --> 01:16:16,320 looks a little bit off. It looks a 1761 01:16:14,480 --> 01:16:18,640 little bit taller than our subscribe 1762 01:16:16,320 --> 01:16:20,640 button. And that's because the border 1763 01:16:18,640 --> 01:16:23,120 actually adds a little bit of size to 1764 01:16:20,640 --> 01:16:25,440 this button. So it adds one pixel on the 1765 01:16:23,120 --> 01:16:27,920 top and bottom. That's why this button 1766 01:16:25,440 --> 01:16:29,920 is taller than the subscribe button. So 1767 01:16:27,920 --> 01:16:32,800 to compensate, we're actually going to 1768 01:16:29,920 --> 01:16:35,920 reduce the padding at the top and the 1769 01:16:32,800 --> 01:16:38,880 bottom by one pixel. 1770 01:16:35,920 --> 01:16:41,199 Save it and refresh. 1771 01:16:38,880 --> 01:16:44,080 And now they're the same size. We have 9 1772 01:16:41,199 --> 01:16:46,640 pixels of space on the inside plus the 1773 01:16:44,080 --> 01:16:48,640 one pixel of the border width. And that 1774 01:16:46,640 --> 01:16:51,600 matches the 10 pixels of space on the 1775 01:16:48,640 --> 01:16:53,679 inside of the subscribe button. 1776 01:16:51,600 --> 01:16:56,560 And I'll leave changing the tweet button 1777 01:16:53,679 --> 01:16:59,280 up to you as an exercise. 1778 01:16:56,560 --> 01:17:01,440 So that is the CSS box model. Every 1779 01:16:59,280 --> 01:17:03,840 element can have spacing on the outside 1780 01:17:01,440 --> 01:17:06,560 called margin, space on the inside 1781 01:17:03,840 --> 01:17:08,239 called padding, as well as a border. And 1782 01:17:06,560 --> 01:17:12,920 these properties determine how much 1783 01:17:08,239 --> 01:17:12,920 space an element takes up on the page. 1784 01:17:14,320 --> 01:17:18,159 Here's some exercises of using the box 1785 01:17:16,320 --> 01:17:22,360 model to get yourself more familiar with 1786 01:17:18,159 --> 01:17:22,360 this concept and these properties. 1787 01:17:33,679 --> 01:17:37,360 For most of the course, we've been 1788 01:17:35,120 --> 01:17:39,040 working with buttons. In this lesson, 1789 01:17:37,360 --> 01:17:41,600 we're going to work with text, and we're 1790 01:17:39,040 --> 01:17:43,360 going to learn how to style text. So, 1791 01:17:41,600 --> 01:17:45,679 just like our button lesson, I've 1792 01:17:43,360 --> 01:17:48,000 created an exercise that we can practice 1793 01:17:45,679 --> 01:17:49,920 with text. So, we're going to go to 1794 01:17:48,000 --> 01:17:52,920 supersimple.dev/ex 1795 01:17:49,920 --> 01:17:52,920 exercises/ext. 1796 01:17:54,080 --> 01:17:58,400 And now we have some text from YouTube 1797 01:17:56,560 --> 01:18:01,679 and Apple that we're going to learn how 1798 01:17:58,400 --> 01:18:04,480 to copy. So first of all, let's create a 1799 01:18:01,679 --> 01:18:07,199 new HTML file where we can focus on 1800 01:18:04,480 --> 01:18:10,719 practicing text styles. So I'm going to 1801 01:18:07,199 --> 01:18:14,760 go here and create a new file. And let's 1802 01:18:10,719 --> 01:18:14,760 just call this text.html. 1803 01:18:15,600 --> 01:18:19,520 And now we're going to open this file in 1804 01:18:17,760 --> 01:18:21,440 our browser. 1805 01:18:19,520 --> 01:18:23,040 So open the folder that contains our 1806 01:18:21,440 --> 01:18:28,000 code. 1807 01:18:23,040 --> 01:18:31,760 and rightclick open with Google Chrome. 1808 01:18:28,000 --> 01:18:35,040 I'm actually going to put this up here. 1809 01:18:31,760 --> 01:18:36,960 All right. So, now we're ready to begin. 1810 01:18:35,040 --> 01:18:39,280 If you've ever written a text document 1811 01:18:36,960 --> 01:18:41,760 before using something like Google Docs 1812 01:18:39,280 --> 01:18:44,800 or Microsoft Word, you've probably seen 1813 01:18:41,760 --> 01:18:46,960 something like this. This is a toolbar 1814 01:18:44,800 --> 01:18:49,760 that allows us to change the style of 1815 01:18:46,960 --> 01:18:52,239 our text. We can change the font, the 1816 01:18:49,760 --> 01:18:55,840 text size, we can make it bold, we can 1817 01:18:52,239 --> 01:18:58,560 center it, etc. In CSS, we have a style 1818 01:18:55,840 --> 01:19:00,560 for each of these things. Let's go to 1819 01:18:58,560 --> 01:19:03,199 our code and we're going to first start 1820 01:19:00,560 --> 01:19:06,320 by creating some text on our page. So, 1821 01:19:03,199 --> 01:19:08,159 let's first create a paragraph. 1822 01:19:06,320 --> 01:19:10,800 And then inside our paragraph, let's 1823 01:19:08,159 --> 01:19:13,679 start with the text here. So, I'm going 1824 01:19:10,800 --> 01:19:16,480 to copy and paste this into our 1825 01:19:13,679 --> 01:19:19,120 paragraph. And I'm just going to 1826 01:19:16,480 --> 01:19:22,560 reorganize the code a little bit and 1827 01:19:19,120 --> 01:19:25,440 save. Remember that in HTML these extra 1828 01:19:22,560 --> 01:19:27,920 spaces and new lines don't matter. Now 1829 01:19:25,440 --> 01:19:30,960 refresh the page and we have our first 1830 01:19:27,920 --> 01:19:33,520 paragraph that we can practice with. 1831 01:19:30,960 --> 01:19:37,640 Next, let's create a style element so we 1832 01:19:33,520 --> 01:19:37,640 can write some CSS code. 1833 01:19:37,840 --> 01:19:43,520 Now we'll set a class on this paragraph 1834 01:19:40,320 --> 01:19:48,000 so that we can target it in CSS. 1835 01:19:43,520 --> 01:19:50,000 class equals uh video dashtitle 1836 01:19:48,000 --> 01:19:53,199 because this is a video title that I 1837 01:19:50,000 --> 01:19:56,239 copied from YouTube. So let's save it 1838 01:19:53,199 --> 01:20:00,080 and refresh. And now we can start 1839 01:19:56,239 --> 01:20:01,760 targeting this paragraph in our CSS. So 1840 01:20:00,080 --> 01:20:04,080 remember we're going to start with a dot 1841 01:20:01,760 --> 01:20:07,960 to target a class and we're going to 1842 01:20:04,080 --> 01:20:07,960 target video-title. 1843 01:20:08,239 --> 01:20:14,320 So the first thing we're going to change 1844 01:20:10,080 --> 01:20:19,040 is the font. To change the font, the CSS 1845 01:20:14,320 --> 01:20:21,120 property is font dash family. 1846 01:20:19,040 --> 01:20:23,520 So websites by default use the font 1847 01:20:21,120 --> 01:20:28,880 called Times New Roman. We're going to 1848 01:20:23,520 --> 01:20:31,920 change the font to a font called Ariel. 1849 01:20:28,880 --> 01:20:34,480 Save it and refresh. And now you can see 1850 01:20:31,920 --> 01:20:37,360 we changed the font. Let's go to the 1851 01:20:34,480 --> 01:20:39,280 next one. So this is the font size. And 1852 01:20:37,360 --> 01:20:43,600 we can change the font size using the 1853 01:20:39,280 --> 01:20:47,360 property font dash size. And let's 1854 01:20:43,600 --> 01:20:50,560 change it to something like 30 pixels. 1855 01:20:47,360 --> 01:20:53,760 Save it and refresh. And now we have a 1856 01:20:50,560 --> 01:20:57,040 bigger font. The next example is let's 1857 01:20:53,760 --> 01:21:00,800 make it bold. We're going to go here and 1858 01:20:57,040 --> 01:21:03,840 we're going to set the font dash weight 1859 01:21:00,800 --> 01:21:06,960 to be bold. 1860 01:21:03,840 --> 01:21:10,000 Save it and refresh. And now we have 1861 01:21:06,960 --> 01:21:12,239 bold font. So, as you can see, CSS has 1862 01:21:10,000 --> 01:21:14,000 properties for doing all of these 1863 01:21:12,239 --> 01:21:15,920 things. And for most of these 1864 01:21:14,000 --> 01:21:18,719 properties, it's pretty easy to Google 1865 01:21:15,920 --> 01:21:21,520 them. For example, let's Google for how 1866 01:21:18,719 --> 01:21:23,600 to make a font itallic. So, we'll go to 1867 01:21:21,520 --> 01:21:28,880 Google and we just need to search 1868 01:21:23,600 --> 01:21:31,360 something like CSS text italic. 1869 01:21:28,880 --> 01:21:34,000 And now in the first result, we're going 1870 01:21:31,360 --> 01:21:36,000 to go in here. 1871 01:21:34,000 --> 01:21:39,360 And if you scroll down, you can see this 1872 01:21:36,000 --> 01:21:42,080 CSS font style italic. 1873 01:21:39,360 --> 01:21:44,400 So I'm going to copy this and paste it 1874 01:21:42,080 --> 01:21:47,520 in my code. 1875 01:21:44,400 --> 01:21:50,400 Save it and refresh. And now we have 1876 01:21:47,520 --> 01:21:51,760 itallic text. 1877 01:21:50,400 --> 01:21:54,080 The last one I'm going to show you for 1878 01:21:51,760 --> 01:21:56,560 now is how to center this text. Because 1879 01:21:54,080 --> 01:21:59,280 in our exercise, we have an exercise 1880 01:21:56,560 --> 01:22:01,360 where the text is centered. To center 1881 01:21:59,280 --> 01:22:04,880 text, we're going to go to our code and 1882 01:22:01,360 --> 01:22:07,520 we're going to type text- align. So, 1883 01:22:04,880 --> 01:22:09,360 this is the property for centering text 1884 01:22:07,520 --> 01:22:12,080 or putting it to the left or to the 1885 01:22:09,360 --> 01:22:14,320 right. Now, we're going to give a value 1886 01:22:12,080 --> 01:22:17,440 of center. 1887 01:22:14,320 --> 01:22:19,600 Save it and refresh. And that's how we 1888 01:22:17,440 --> 01:22:21,520 center our text. 1889 01:22:19,600 --> 01:22:23,840 So, that was pretty easy, right? Now, 1890 01:22:21,520 --> 01:22:26,159 let's go ahead and try to copy this 1891 01:22:23,840 --> 01:22:28,400 style in our exercise. 1892 01:22:26,159 --> 01:22:30,960 So if you remember the general strategy 1893 01:22:28,400 --> 01:22:33,600 for creating anything that we see is 1894 01:22:30,960 --> 01:22:36,719 first create the element with HTML and 1895 01:22:33,600 --> 01:22:39,840 then style it with CSS one by one. Let's 1896 01:22:36,719 --> 01:22:42,560 go ahead and do that for this exercise. 1897 01:22:39,840 --> 01:22:45,120 So I'm just going to resize this back 1898 01:22:42,560 --> 01:22:48,560 and we're going to start 1899 01:22:45,120 --> 01:22:51,600 by resetting all of these styles. 1900 01:22:48,560 --> 01:22:53,360 Save it and refresh. 1901 01:22:51,600 --> 01:22:55,840 First I'm going to start with the font 1902 01:22:53,360 --> 01:22:57,920 family. So for this exercise, I actually 1903 01:22:55,840 --> 01:23:00,560 use the font family Ariel just to make 1904 01:22:57,920 --> 01:23:06,639 it easier for us. So we're going to set 1905 01:23:00,560 --> 01:23:09,840 the font dash family to Ariel. 1906 01:23:06,639 --> 01:23:12,480 Save it and refresh. Next, I'm going to 1907 01:23:09,840 --> 01:23:14,960 change the font weight. So this font is 1908 01:23:12,480 --> 01:23:17,600 bold and I want to make my font bold as 1909 01:23:14,960 --> 01:23:19,920 well. So I'm going to add font 1910 01:23:17,600 --> 01:23:21,679 dashweight 1911 01:23:19,920 --> 01:23:24,000 bold. 1912 01:23:21,679 --> 01:23:27,199 Save it and refresh. 1913 01:23:24,000 --> 01:23:30,080 Next, let's change the font size. So, 1914 01:23:27,199 --> 01:23:34,080 I'm going to change this font size to 1915 01:23:30,080 --> 01:23:38,080 something bigger, like maybe 20 pixels. 1916 01:23:34,080 --> 01:23:41,280 Save it and refresh. And it looks a 1917 01:23:38,080 --> 01:23:43,120 little too big compared to the design. 1918 01:23:41,280 --> 01:23:48,560 So, let's tone it down just a little 1919 01:23:43,120 --> 01:23:50,080 bit. Maybe 18 pixels. Save and refresh. 1920 01:23:48,560 --> 01:23:53,120 Okay. So, I think that looks close 1921 01:23:50,080 --> 01:23:55,440 enough. Next, you'll notice that this 1922 01:23:53,120 --> 01:23:58,080 text sort of wraps around to a second 1923 01:23:55,440 --> 01:23:59,840 line while ours doesn't. The way to make 1924 01:23:58,080 --> 01:24:02,719 this happen is we're going to set a 1925 01:23:59,840 --> 01:24:04,400 width on this title. Now, I know that in 1926 01:24:02,719 --> 01:24:07,120 the previous section, we said it's bad 1927 01:24:04,400 --> 01:24:10,159 to set a width, but here it's actually 1928 01:24:07,120 --> 01:24:12,080 what we want because if we set a width, 1929 01:24:10,159 --> 01:24:14,719 we're going to force the text onto a 1930 01:24:12,080 --> 01:24:18,159 second line. So, let's go ahead and set 1931 01:24:14,719 --> 01:24:20,960 a width right now. And I'll set it to 1932 01:24:18,159 --> 01:24:24,560 something like 400 pixels. Let's see how 1933 01:24:20,960 --> 01:24:26,719 that looks. Save it and refresh. Okay, 1934 01:24:24,560 --> 01:24:30,800 so it needs to be less than that. Let's 1935 01:24:26,719 --> 01:24:33,520 do 300 pixels. Save and refresh. Okay, 1936 01:24:30,800 --> 01:24:36,480 so that looks right to me now. And the 1937 01:24:33,520 --> 01:24:38,400 final thing with the title is I notice 1938 01:24:36,480 --> 01:24:41,679 there's more spacing between the lines 1939 01:24:38,400 --> 01:24:44,400 here than what we have. So to adjust the 1940 01:24:41,679 --> 01:24:48,880 spacing between lines, the property is 1941 01:24:44,400 --> 01:24:50,639 called line dash height. So, don't worry 1942 01:24:48,880 --> 01:24:52,560 if it seems like we're learning a lot of 1943 01:24:50,639 --> 01:24:54,719 new properties. The point of this lesson 1944 01:24:52,560 --> 01:24:56,719 is for us to go through some complicated 1945 01:24:54,719 --> 01:24:58,480 examples together, which will prepare 1946 01:24:56,719 --> 01:25:01,360 you for the exercises that you can 1947 01:24:58,480 --> 01:25:03,760 practice on your own. So, for this line 1948 01:25:01,360 --> 01:25:05,360 height, let's try something like 20 1949 01:25:03,760 --> 01:25:08,400 pixels. 1950 01:25:05,360 --> 01:25:10,560 Save it and refresh. Okay, so it looks 1951 01:25:08,400 --> 01:25:15,600 like that didn't work. Let's change it 1952 01:25:10,560 --> 01:25:21,120 to 26, maybe. Save it and refresh. 1953 01:25:15,600 --> 01:25:23,920 Okay, maybe 24. Save and refresh. Okay, 1954 01:25:21,120 --> 01:25:25,440 so I think that looks pretty close. 1955 01:25:23,920 --> 01:25:28,320 Next, let's work on the second 1956 01:25:25,440 --> 01:25:31,040 paragraph. So, we're going to create a 1957 01:25:28,320 --> 01:25:34,880 new paragraph 1958 01:25:31,040 --> 01:25:36,639 3.4 m views. 1959 01:25:34,880 --> 01:25:38,719 And now to create this dot, we're going 1960 01:25:36,639 --> 01:25:42,239 to create something called an HTML 1961 01:25:38,719 --> 01:25:44,000 entity. So, an HTML entity lets us type 1962 01:25:42,239 --> 01:25:47,360 out special characters. for example, 1963 01:25:44,000 --> 01:25:49,840 this dot and this check mark. To get the 1964 01:25:47,360 --> 01:25:54,639 HTML entity for this dot, we're going to 1965 01:25:49,840 --> 01:25:57,760 Google HTML entity 1966 01:25:54,639 --> 01:26:00,159 middle dot. 1967 01:25:57,760 --> 01:26:03,199 And now if we scroll down, this will 1968 01:26:00,159 --> 01:26:06,239 give us some HTML code that we can copy 1969 01:26:03,199 --> 01:26:09,040 into our code. So I'm going to copy this 1970 01:26:06,239 --> 01:26:11,920 and then paste it here. And that's going 1971 01:26:09,040 --> 01:26:16,560 to create a dot on our page. So, if I 1972 01:26:11,920 --> 01:26:18,159 save it and refresh, that's what we get. 1973 01:26:16,560 --> 01:26:21,520 Now, I'm going to type out the rest of 1974 01:26:18,159 --> 01:26:25,040 the text in this paragraph. 1975 01:26:21,520 --> 01:26:27,360 Now, let's save that and refresh. So, 1976 01:26:25,040 --> 01:26:29,520 now remember the general process is we 1977 01:26:27,360 --> 01:26:31,920 created the element with HTML. Now, 1978 01:26:29,520 --> 01:26:34,239 we're going to style it one by one. 1979 01:26:31,920 --> 01:26:39,639 First, let's give this a class so we can 1980 01:26:34,239 --> 01:26:39,639 target it. Let's call this video-stats. 1981 01:26:40,159 --> 01:26:46,159 And now in our CSS, 1982 01:26:42,880 --> 01:26:48,000 we're going to style this text. 1983 01:26:46,159 --> 01:26:49,760 We're going to start with font dash 1984 01:26:48,000 --> 01:26:53,440 family 1985 01:26:49,760 --> 01:26:55,600 aerial. Save and refresh. And then we're 1986 01:26:53,440 --> 01:26:57,360 going to change the font size. So it 1987 01:26:55,600 --> 01:27:00,000 looks like our design is a little bit 1988 01:26:57,360 --> 01:27:04,239 smaller than what we have. Let's change 1989 01:27:00,000 --> 01:27:06,639 the font size to maybe 14 pixels. 1990 01:27:04,239 --> 01:27:09,040 Save and refresh. 1991 01:27:06,639 --> 01:27:12,159 And I think that looks pretty close. 1992 01:27:09,040 --> 01:27:17,280 Next, let's change the color. 1993 01:27:12,159 --> 01:27:19,520 So, let's set a color of maybe gray 1994 01:27:17,280 --> 01:27:21,679 and refresh. 1995 01:27:19,520 --> 01:27:24,960 Okay, so that's a little too light. So, 1996 01:27:21,679 --> 01:27:27,520 to get an exact color, we can rightclick 1997 01:27:24,960 --> 01:27:29,360 in a blank area of the web page, click 1998 01:27:27,520 --> 01:27:31,360 inspect, 1999 01:27:29,360 --> 01:27:33,840 and then we're going to inspect the 2000 01:27:31,360 --> 01:27:35,360 styles of this element. So the trick to 2001 01:27:33,840 --> 01:27:38,560 doing that is we're going to click this 2002 01:27:35,360 --> 01:27:40,880 top left icon, hover over this element 2003 01:27:38,560 --> 01:27:43,840 and click it. And then we can find all 2004 01:27:40,880 --> 01:27:46,159 its styles in the computer tab. 2005 01:27:43,840 --> 01:27:49,920 So if we scroll down, we can get the 2006 01:27:46,159 --> 01:27:53,520 text color. So let's copy this 2007 01:27:49,920 --> 01:27:55,280 and save. 2008 01:27:53,520 --> 01:27:57,679 Refresh. 2009 01:27:55,280 --> 01:27:59,840 And that looks pretty good compared to 2010 01:27:57,679 --> 01:28:01,920 the design. 2011 01:27:59,840 --> 01:28:04,480 Next, let's adjust the spacing between 2012 01:28:01,920 --> 01:28:06,960 these two paragraphs. So, remember from 2013 01:28:04,480 --> 01:28:09,600 the previous lesson, the spacing outside 2014 01:28:06,960 --> 01:28:11,440 of an element is called the margin. But 2015 01:28:09,600 --> 01:28:13,840 if we look at our code, we didn't 2016 01:28:11,440 --> 01:28:15,360 actually set any margin yet. So, why is 2017 01:28:13,840 --> 01:28:18,239 there so much space between these two 2018 01:28:15,360 --> 01:28:20,159 paragraphs? And the reason is if we 2019 01:28:18,239 --> 01:28:23,360 right click in an empty area of the web 2020 01:28:20,159 --> 01:28:27,040 page and click inspect 2021 01:28:23,360 --> 01:28:29,600 and we click this icon and hover over 2022 01:28:27,040 --> 01:28:33,040 this paragraph. This paragraph already 2023 01:28:29,600 --> 01:28:35,760 has margin at the top and bottom. So if 2024 01:28:33,040 --> 01:28:38,480 we click this go to computed, it has 14 2025 01:28:35,760 --> 01:28:41,199 pixels of margin at the top and 14 at 2026 01:28:38,480 --> 01:28:43,360 the bottom. And the same thing for this 2027 01:28:41,199 --> 01:28:45,920 paragraph. And the reason for this is 2028 01:28:43,360 --> 01:28:49,280 because paragraphs by default come with 2029 01:28:45,920 --> 01:28:51,199 margin at the top and at the bottom. So 2030 01:28:49,280 --> 01:28:53,280 that's why there's all this spacing that 2031 01:28:51,199 --> 01:28:55,120 we have here where we didn't set it in 2032 01:28:53,280 --> 01:28:57,360 the CSS. 2033 01:28:55,120 --> 01:28:59,120 So the general process is we're going to 2034 01:28:57,360 --> 01:29:01,679 remove the default spacing and then 2035 01:28:59,120 --> 01:29:03,920 we're going to set our own spacing. So, 2036 01:29:01,679 --> 01:29:06,960 let's go into our code. 2037 01:29:03,920 --> 01:29:09,520 And first, we're going to remove the 2038 01:29:06,960 --> 01:29:12,320 margin-bottom 2039 01:29:09,520 --> 01:29:14,080 of the title. 2040 01:29:12,320 --> 01:29:16,320 Set that to zero. And we're also going 2041 01:29:14,080 --> 01:29:19,920 to remove the margin 2042 01:29:16,320 --> 01:29:22,159 at the top of the second paragraph and 2043 01:29:19,920 --> 01:29:25,040 set it to zero. 2044 01:29:22,159 --> 01:29:26,800 Save that and refresh. And now there's 2045 01:29:25,040 --> 01:29:29,040 no default spacing between these and 2046 01:29:26,800 --> 01:29:32,159 they're really close together. 2047 01:29:29,040 --> 01:29:35,600 Next, we can set a more precise margin 2048 01:29:32,159 --> 01:29:38,000 bottom. So, let's set it to maybe 20 2049 01:29:35,600 --> 01:29:39,920 pixels. Let's see how that looks. Save 2050 01:29:38,000 --> 01:29:42,000 it and refresh. 2051 01:29:39,920 --> 01:29:44,080 Okay, so that's way too much space. 2052 01:29:42,000 --> 01:29:48,560 Let's tone it down to something like 2053 01:29:44,080 --> 01:29:50,480 maybe five. Save and refresh. 2054 01:29:48,560 --> 01:29:52,800 Okay, so I think this looks pretty close 2055 01:29:50,480 --> 01:29:55,679 to the design, actually. Let's move on 2056 01:29:52,800 --> 01:29:58,480 to the next paragraph. We're going to 2057 01:29:55,679 --> 01:30:03,719 move all the way down and create a new 2058 01:29:58,480 --> 01:30:03,719 paragraph element with this text inside. 2059 01:30:04,480 --> 01:30:09,120 And now for this check mark, we're also 2060 01:30:06,239 --> 01:30:11,920 going to use an HTML entity. Now, I know 2061 01:30:09,120 --> 01:30:14,400 that you can actually copy this and put 2062 01:30:11,920 --> 01:30:15,920 it into our code directly, but some 2063 01:30:14,400 --> 01:30:18,800 browsers might not support this, so 2064 01:30:15,920 --> 01:30:20,880 that's why we're using HTML entities. 2065 01:30:18,800 --> 01:30:25,760 We're going to go to Google and we're 2066 01:30:20,880 --> 01:30:27,600 going to search HTML entity check mark 2067 01:30:25,760 --> 01:30:30,239 and I'm going to scroll down and grab 2068 01:30:27,600 --> 01:30:31,520 the HTML entity here. So here we 2069 01:30:30,239 --> 01:30:36,480 actually have three. I'm just going to 2070 01:30:31,520 --> 01:30:40,080 take the first one. Copy, paste, 2071 01:30:36,480 --> 01:30:42,560 save it. Let's go back and refresh. 2072 01:30:40,080 --> 01:30:45,120 Okay, so that looks pretty good. Next, 2073 01:30:42,560 --> 01:30:46,639 let's keep styling these one by one. So, 2074 01:30:45,120 --> 01:30:48,480 I'm going to go a little bit faster here 2075 01:30:46,639 --> 01:30:50,800 because it's basically the same thing 2076 01:30:48,480 --> 01:30:54,560 that we've been doing for the first two. 2077 01:30:50,800 --> 01:30:58,760 Let's call this one video author. 2078 01:30:54,560 --> 01:30:58,760 And then we'll style it up here. 2079 01:30:59,360 --> 01:31:04,960 So, we'll set the font family to Ariel 2080 01:31:02,400 --> 01:31:07,440 like the rest of the paragraphs. Going 2081 01:31:04,960 --> 01:31:09,040 to set the color to the same as this 2082 01:31:07,440 --> 01:31:13,080 paragraph. 2083 01:31:09,040 --> 01:31:13,080 So, copy and paste. 2084 01:31:15,120 --> 01:31:19,679 Okay, that looks pretty good. Oh, yeah. 2085 01:31:17,520 --> 01:31:21,840 We have to set the font size. Looks a 2086 01:31:19,679 --> 01:31:24,719 little too big right now. Set the font 2087 01:31:21,840 --> 01:31:26,800 size to 14 pixels. 2088 01:31:24,719 --> 01:31:30,000 Next, we're going to reset the default 2089 01:31:26,800 --> 01:31:31,920 spacing here. So, we're going to set the 2090 01:31:30,000 --> 01:31:35,360 margin-bottom 2091 01:31:31,920 --> 01:31:39,880 and remove it by setting it to zero. and 2092 01:31:35,360 --> 01:31:39,880 also remove the margin top 2093 01:31:39,920 --> 01:31:44,960 and set it to zero. Save and refresh. 2094 01:31:43,520 --> 01:31:48,400 And now we're going to set a more 2095 01:31:44,960 --> 01:31:51,840 precise margin. So let's try maybe 30 2096 01:31:48,400 --> 01:31:55,679 pixels. See how that looks. Okay, that's 2097 01:31:51,840 --> 01:31:58,159 way too much. Maybe 20 pixels. 2098 01:31:55,679 --> 01:31:59,600 Okay, I think that looks about right. 2099 01:31:58,159 --> 01:32:03,840 Then we're going to do the third 2100 01:31:59,600 --> 01:32:07,199 paragraph. Let's go down here. create 2101 01:32:03,840 --> 01:32:11,040 the element and then style it with CSS. 2102 01:32:07,199 --> 01:32:12,719 Just going to copy and paste this in 2103 01:32:11,040 --> 01:32:17,280 here, 2104 01:32:12,719 --> 01:32:20,159 save and refresh. 2105 01:32:17,280 --> 01:32:22,239 First, let's give a class to the text so 2106 01:32:20,159 --> 01:32:26,199 that we can target it. Let's call this 2107 01:32:22,239 --> 01:32:26,199 video- description. 2108 01:32:28,320 --> 01:32:38,880 Go up here. video- description. 2109 01:32:33,199 --> 01:32:41,880 We want a font family of Ariel, a font 2110 01:32:38,880 --> 01:32:41,880 size 2111 01:32:42,159 --> 01:32:49,480 of 14 pixels, 2112 01:32:45,520 --> 01:32:49,480 and the same color. 2113 01:32:50,639 --> 01:32:56,800 And we save it and refresh. Okay, that 2114 01:32:54,480 --> 01:32:59,280 looks pretty good. And now we want to 2115 01:32:56,800 --> 01:33:02,639 give it a width to make it wrap around 2116 01:32:59,280 --> 01:33:07,199 like this. So let's set the width to the 2117 01:33:02,639 --> 01:33:08,880 same as the title, which is 300. 2118 01:33:07,199 --> 01:33:13,360 Width 2119 01:33:08,880 --> 01:33:16,320 300 pixels. Save and refresh. Okay. So 2120 01:33:13,360 --> 01:33:21,040 it looks like this IO is actually on a 2121 01:33:16,320 --> 01:33:24,400 separate line. Let's make it 280. 2122 01:33:21,040 --> 01:33:26,400 Save and refresh. All right. So, that 2123 01:33:24,400 --> 01:33:28,960 looks pretty good. And I'm also going to 2124 01:33:26,400 --> 01:33:32,440 make it 280 up here just to make sure 2125 01:33:28,960 --> 01:33:32,440 they're the same. 2126 01:33:32,480 --> 01:33:36,159 So, the last thing I'm going to change 2127 01:33:33,760 --> 01:33:38,560 is the height or the space between these 2128 01:33:36,159 --> 01:33:41,679 lines. To do that, we're going to use 2129 01:33:38,560 --> 01:33:44,480 line height. Let's scroll down and then 2130 01:33:41,679 --> 01:33:46,080 add another property called line dash 2131 01:33:44,480 --> 01:33:48,639 height. 2132 01:33:46,080 --> 01:33:53,360 And let's set this to 20 pixels. Let's 2133 01:33:48,639 --> 01:33:57,360 see how that looks. Save and refresh. 2134 01:33:53,360 --> 01:34:00,159 and let's set it to maybe 22 pixels. 2135 01:33:57,360 --> 01:34:02,800 Save and refresh. Okay, so I'm pretty 2136 01:34:00,159 --> 01:34:04,719 happy with this. And lastly, we're going 2137 01:34:02,800 --> 01:34:07,440 to modify the space between these two 2138 01:34:04,719 --> 01:34:10,400 paragraphs. First, we're going to reset 2139 01:34:07,440 --> 01:34:13,280 the default margin. Let's get rid of the 2140 01:34:10,400 --> 01:34:16,960 margin bottom on the first one here and 2141 01:34:13,280 --> 01:34:19,360 the margin top on the second one. So, 2142 01:34:16,960 --> 01:34:23,600 margin- top, we're going to get rid of 2143 01:34:19,360 --> 01:34:25,600 it and set it to zero. Save and refresh. 2144 01:34:23,600 --> 01:34:29,199 And then we're going to set a margin 2145 01:34:25,600 --> 01:34:34,239 bottom. Maybe the same thing as up here. 2146 01:34:29,199 --> 01:34:35,920 20 pixels. Save and refresh. 2147 01:34:34,239 --> 01:34:38,800 All right. So, that looks really good to 2148 01:34:35,920 --> 01:34:40,320 me. We just recreated a really nice 2149 01:34:38,800 --> 01:34:42,560 looking style that you can find on 2150 01:34:40,320 --> 01:34:45,120 youtube.com. And the general process 2151 01:34:42,560 --> 01:34:47,520 that we use is first we created the 2152 01:34:45,120 --> 01:34:51,760 elements with HTML and then we styled 2153 01:34:47,520 --> 01:34:53,440 them with CSS one by one. 2154 01:34:51,760 --> 01:34:55,360 So before we move on to the next 2155 01:34:53,440 --> 01:34:58,000 exercise, I'm going to show you a way to 2156 01:34:55,360 --> 01:35:00,000 clean up our code. So if you notice, all 2157 01:34:58,000 --> 01:35:02,560 of our styles right now have a line 2158 01:35:00,000 --> 01:35:04,639 called font family aerial. Now we can 2159 01:35:02,560 --> 01:35:07,920 actually clean this up and remove the 2160 01:35:04,639 --> 01:35:10,080 duplication by creating a new style. 2161 01:35:07,920 --> 01:35:12,560 This time we're going to target all 2162 01:35:10,080 --> 01:35:14,719 paragraphs on the page. 2163 01:35:12,560 --> 01:35:20,080 And we're going to give all paragraphs 2164 01:35:14,719 --> 01:35:21,679 font dash family colon aerial 2165 01:35:20,080 --> 01:35:23,920 save. 2166 01:35:21,679 --> 01:35:27,040 So this style is going to apply to all 2167 01:35:23,920 --> 01:35:28,960 paragraphs which means all of these. 2168 01:35:27,040 --> 01:35:30,960 That means that we actually don't need 2169 01:35:28,960 --> 01:35:33,679 this line 2170 01:35:30,960 --> 01:35:36,639 in any of these class styles anymore. So 2171 01:35:33,679 --> 01:35:39,760 we can actually remove all of these. Now 2172 01:35:36,639 --> 01:35:42,080 if I save it and I refresh, you can see 2173 01:35:39,760 --> 01:35:43,760 that nothing changes because this is 2174 01:35:42,080 --> 01:35:45,600 doing the same thing as the code that we 2175 01:35:43,760 --> 01:35:47,679 had before. 2176 01:35:45,600 --> 01:35:50,080 So you can also see from this example 2177 01:35:47,679 --> 01:35:53,199 that an element can be targeted by two 2178 01:35:50,080 --> 01:35:55,520 sets of styles. For example, for this 2179 01:35:53,199 --> 01:35:57,760 code here, we're targeting all P 2180 01:35:55,520 --> 01:36:00,320 elements on the page and all elements 2181 01:35:57,760 --> 01:36:03,360 with a class of video-title. 2182 01:36:00,320 --> 01:36:07,040 If we scroll down here, here we have a P 2183 01:36:03,360 --> 01:36:08,960 element that has a class of video-title, 2184 01:36:07,040 --> 01:36:12,000 which means it's going to be targeted by 2185 01:36:08,960 --> 01:36:13,920 both this set of styles and this set of 2186 01:36:12,000 --> 01:36:16,480 styles. So, it's being targeted by 2187 01:36:13,920 --> 01:36:18,400 multiple sets of styles. 2188 01:36:16,480 --> 01:36:21,600 Now, another thing that we can clean up 2189 01:36:18,400 --> 01:36:23,840 is remember how we reset the margins for 2190 01:36:21,600 --> 01:36:26,080 all of our paragraphs? Instead of doing 2191 01:36:23,840 --> 01:36:28,960 it for each one individually, we can 2192 01:36:26,080 --> 01:36:33,840 actually put it all up here. So for 2193 01:36:28,960 --> 01:36:38,400 example, we can set the margin dash top 2194 01:36:33,840 --> 01:36:40,080 to zero and the margin dash bottom to 2195 01:36:38,400 --> 01:36:43,199 zero. 2196 01:36:40,080 --> 01:36:45,600 We save it and we refresh. 2197 01:36:43,199 --> 01:36:47,600 It looks pretty much the same except 2198 01:36:45,600 --> 01:36:49,920 we're now cleaning up all of the default 2199 01:36:47,600 --> 01:36:52,560 styles up here so that we don't have to 2200 01:36:49,920 --> 01:36:54,880 do it in our code at the bottom. So, we 2201 01:36:52,560 --> 01:36:57,199 don't need this anymore 2202 01:36:54,880 --> 01:36:59,360 or this 2203 01:36:57,199 --> 01:37:02,320 or this. 2204 01:36:59,360 --> 01:37:04,639 If we save that and refresh, we still 2205 01:37:02,320 --> 01:37:08,639 get the same thing because we've reset 2206 01:37:04,639 --> 01:37:10,239 all of our styles in this set of styles. 2207 01:37:08,639 --> 01:37:12,800 Now, the last concept I want to show you 2208 01:37:10,239 --> 01:37:16,159 before we move on to the next exercise 2209 01:37:12,800 --> 01:37:19,440 is the fact that in this set of styles, 2210 01:37:16,159 --> 01:37:21,199 we're setting the margin bottom to zero. 2211 01:37:19,440 --> 01:37:23,679 But here we're also setting the margin 2212 01:37:21,199 --> 01:37:26,080 bottom to five pixels and the margin 2213 01:37:23,679 --> 01:37:28,480 bottom to 20 pixels. So how does that 2214 01:37:26,080 --> 01:37:31,119 work? We're setting it to zero here and 2215 01:37:28,480 --> 01:37:33,520 to five and 20 here. Which style does 2216 01:37:31,119 --> 01:37:36,320 the element actually get? And the answer 2217 01:37:33,520 --> 01:37:38,400 is we're getting the style down here. So 2218 01:37:36,320 --> 01:37:40,800 if we refresh, you'll notice that 2219 01:37:38,400 --> 01:37:43,040 there's still 20 pixels of space between 2220 01:37:40,800 --> 01:37:45,040 these two paragraphs. 2221 01:37:43,040 --> 01:37:48,320 Now, you might think that it's because 2222 01:37:45,040 --> 01:37:50,960 this line is at the top and then once we 2223 01:37:48,320 --> 01:37:54,159 get to this line, it overrides anything 2224 01:37:50,960 --> 01:37:58,920 that comes before it. But if we actually 2225 01:37:54,159 --> 01:37:58,920 move this to the top 2226 01:37:58,960 --> 01:38:04,320 and we save and reload, you'll see that 2227 01:38:02,000 --> 01:38:07,360 we still have 20 pixels of margin 2228 01:38:04,320 --> 01:38:10,880 bottom. So why is this happening? This 2229 01:38:07,360 --> 01:38:12,560 is something called CSS specificity. 2230 01:38:10,880 --> 01:38:14,480 If we have multiple lines setting the 2231 01:38:12,560 --> 01:38:16,960 same property, there's actually a 2232 01:38:14,480 --> 01:38:19,440 priority that the browser follows. So in 2233 01:38:16,960 --> 01:38:22,080 this situation, this style has more 2234 01:38:19,440 --> 01:38:24,159 priority than this style. And to 2235 01:38:22,080 --> 01:38:26,480 determine which one has more priority, 2236 01:38:24,159 --> 01:38:29,760 we have to look at this word before the 2237 01:38:26,480 --> 01:38:32,239 brackets. So this word tells us what 2238 01:38:29,760 --> 01:38:34,960 these styles are targeting. This is 2239 01:38:32,239 --> 01:38:38,320 known as a selector. 2240 01:38:34,960 --> 01:38:41,280 This is another selector that targets a 2241 01:38:38,320 --> 01:38:43,920 particular class. Now the selector that 2242 01:38:41,280 --> 01:38:46,400 is the most specific is going to have 2243 01:38:43,920 --> 01:38:49,199 higher priority. So this selector is 2244 01:38:46,400 --> 01:38:51,600 actually more specific than paragraphs. 2245 01:38:49,199 --> 01:38:54,400 So what I mean by specific is that this 2246 01:38:51,600 --> 01:38:57,920 targets all paragraphs on the page and 2247 01:38:54,400 --> 01:38:59,840 this targets a specific class. So not 2248 01:38:57,920 --> 01:39:02,239 all paragraphs are going to have this 2249 01:38:59,840 --> 01:39:05,280 class of video-stats. 2250 01:39:02,239 --> 01:39:08,480 So that's why this is more specific. It 2251 01:39:05,280 --> 01:39:12,320 targets a smaller group of elements than 2252 01:39:08,480 --> 01:39:14,960 this. That's why this line has priority 2253 01:39:12,320 --> 01:39:17,760 over this line. So that's just an 2254 01:39:14,960 --> 01:39:20,800 introduction to CSS specificity. For 2255 01:39:17,760 --> 01:39:23,920 now, just know that a class name like 2256 01:39:20,800 --> 01:39:26,960 this has more priority than an element 2257 01:39:23,920 --> 01:39:29,040 name like this. So I'm going to move 2258 01:39:26,960 --> 01:39:31,679 this code back 2259 01:39:29,040 --> 01:39:33,920 and we'll continue with the rest of this 2260 01:39:31,679 --> 01:39:36,560 exercise. 2261 01:39:33,920 --> 01:39:39,119 Next, we're going to copy this text from 2262 01:39:36,560 --> 01:39:40,639 Apple. So you can see that there is a 2263 01:39:39,119 --> 01:39:43,040 background color and the text is 2264 01:39:40,639 --> 01:39:46,080 centered. And also if I hover over this 2265 01:39:43,040 --> 01:39:49,760 part of the text, we get a pointer on 2266 01:39:46,080 --> 01:39:53,040 our mouse and we have an underline text. 2267 01:39:49,760 --> 01:39:54,800 So let's see how we can do this. 2268 01:39:53,040 --> 01:39:57,360 First we'll create the element and then 2269 01:39:54,800 --> 01:39:59,280 we'll style it one by one. So we'll go 2270 01:39:57,360 --> 01:40:01,920 down here and we're going to create a 2271 01:39:59,280 --> 01:40:04,639 new paragraph 2272 01:40:01,920 --> 01:40:10,080 and let's copy this text into that 2273 01:40:04,639 --> 01:40:13,760 paragraph. Let's copy and paste. Oops. 2274 01:40:10,080 --> 01:40:16,320 Okay. Save it and refresh. Okay. So, 2275 01:40:13,760 --> 01:40:18,800 that looks good. So, usually if you have 2276 01:40:16,320 --> 01:40:21,199 a greater than or less than symbol, you 2277 01:40:18,800 --> 01:40:22,960 want to create it with an HTML entity 2278 01:40:21,199 --> 01:40:26,639 because the browser could confuse these 2279 01:40:22,960 --> 01:40:30,880 symbols with an HTML tag. So, I'm going 2280 01:40:26,639 --> 01:40:33,920 to search for the HTML entity for 2281 01:40:30,880 --> 01:40:36,480 greater than. 2282 01:40:33,920 --> 01:40:38,159 So, this is the symbol that we want. I'm 2283 01:40:36,480 --> 01:40:41,400 just going to copy and paste this into 2284 01:40:38,159 --> 01:40:41,400 our code. 2285 01:40:42,000 --> 01:40:47,600 Save it and refresh. 2286 01:40:45,040 --> 01:40:49,600 Next, let's actually add some space at 2287 01:40:47,600 --> 01:40:52,400 the bottom of this paragraph so that we 2288 01:40:49,600 --> 01:40:54,960 can see our new paragraph clearly. So, 2289 01:40:52,400 --> 01:40:59,360 we're going to go here 2290 01:40:54,960 --> 01:41:00,880 and just add some margin to the bottom 2291 01:40:59,360 --> 01:41:02,480 cuz it's a little bit too cluttered 2292 01:41:00,880 --> 01:41:05,280 right now. 2293 01:41:02,480 --> 01:41:07,280 All right. So, that looks pretty good. 2294 01:41:05,280 --> 01:41:09,679 We're going to start by adding a class 2295 01:41:07,280 --> 01:41:14,639 to our paragraph so we can target it in 2296 01:41:09,679 --> 01:41:16,639 our CSS. Class equals maybe apple-ash 2297 01:41:14,639 --> 01:41:20,000 text. 2298 01:41:16,639 --> 01:41:21,840 Save it and refresh. 2299 01:41:20,000 --> 01:41:23,360 And 2300 01:41:21,840 --> 01:41:26,080 apple 2301 01:41:23,360 --> 01:41:28,320 text. 2302 01:41:26,080 --> 01:41:32,560 Okay. And first I'm actually also going 2303 01:41:28,320 --> 01:41:34,960 to give some spacing at the bottom so 2304 01:41:32,560 --> 01:41:38,560 it's easier for us to see our actual 2305 01:41:34,960 --> 01:41:40,320 code. So 50 pixels at the bottom. Save 2306 01:41:38,560 --> 01:41:42,159 and refresh. 2307 01:41:40,320 --> 01:41:45,040 And now it's a little easier to see what 2308 01:41:42,159 --> 01:41:47,280 we're working with. So next I'm going to 2309 01:41:45,040 --> 01:41:49,360 change the font size. One thing you'll 2310 01:41:47,280 --> 01:41:52,480 notice is that the font family is 2311 01:41:49,360 --> 01:41:54,800 already AIAL. If we scroll back up, we 2312 01:41:52,480 --> 01:41:57,040 have this set of styles that target all 2313 01:41:54,800 --> 01:41:59,920 paragraph elements. So, it's already set 2314 01:41:57,040 --> 01:42:01,760 our font family to Ariel. Let's scroll 2315 01:41:59,920 --> 01:42:04,719 back down 2316 01:42:01,760 --> 01:42:06,639 and let's adjust the font size. So, this 2317 01:42:04,719 --> 01:42:10,560 one looks a little bit smaller. So, 2318 01:42:06,639 --> 01:42:15,360 let's set it to maybe 14 pixels. Let's 2319 01:42:10,560 --> 01:42:17,280 see how that looks. Save it and refresh. 2320 01:42:15,360 --> 01:42:20,320 Okay. So, I think that looks pretty 2321 01:42:17,280 --> 01:42:23,119 similar to the design. 2322 01:42:20,320 --> 01:42:25,840 And now the next step is let's set a 2323 01:42:23,119 --> 01:42:27,760 background color of red. Now, the trick 2324 01:42:25,840 --> 01:42:30,239 for getting the background color is 2325 01:42:27,760 --> 01:42:33,040 we're going to rightclick in an empty 2326 01:42:30,239 --> 01:42:35,920 area, inspect, 2327 01:42:33,040 --> 01:42:38,880 click this icon, and click the element 2328 01:42:35,920 --> 01:42:41,840 we want to copy styles for, and then go 2329 01:42:38,880 --> 01:42:43,920 to the computer tab and scroll down. 2330 01:42:41,840 --> 01:42:46,239 Now, we have the background color. I'm 2331 01:42:43,920 --> 01:42:48,880 just going to copy this 2332 01:42:46,239 --> 01:42:52,800 and paste it in here. So, background 2333 01:42:48,880 --> 01:42:57,520 dash color. We're going to paste that. 2334 01:42:52,800 --> 01:43:00,400 Save and refresh. Okay. Next, we're 2335 01:42:57,520 --> 01:43:03,199 going to do the text color. So, let's 2336 01:43:00,400 --> 01:43:06,199 set the text color to white. 2337 01:43:03,199 --> 01:43:06,199 color-white. 2338 01:43:06,400 --> 01:43:11,040 Save and refresh. 2339 01:43:09,040 --> 01:43:13,920 And now, if we look at our design, this 2340 01:43:11,040 --> 01:43:16,080 text is actually centered on the page. 2341 01:43:13,920 --> 01:43:19,840 So remember the property for centering 2342 01:43:16,080 --> 01:43:21,760 text is text dash align 2343 01:43:19,840 --> 01:43:24,960 center. 2344 01:43:21,760 --> 01:43:28,239 Save and refresh. Okay. And the last 2345 01:43:24,960 --> 01:43:30,880 thing is there's some spacing at the top 2346 01:43:28,239 --> 01:43:32,960 and the bottom here. So here we actually 2347 01:43:30,880 --> 01:43:34,880 want to add spacing inside our 2348 01:43:32,960 --> 01:43:37,280 paragraph. And remember from the 2349 01:43:34,880 --> 01:43:40,159 previous lesson, spacing on the inside 2350 01:43:37,280 --> 01:43:43,440 of an element is called padding. We're 2351 01:43:40,159 --> 01:43:47,280 going to add some padding to the top. 2352 01:43:43,440 --> 01:43:49,520 Maybe 10 pixels. And then padding to the 2353 01:43:47,280 --> 01:43:52,239 bottom. 2354 01:43:49,520 --> 01:43:56,320 And 10 pixels. Let's see how that looks. 2355 01:43:52,239 --> 01:43:58,400 Save and refresh. Okay. So, I think we 2356 01:43:56,320 --> 01:44:02,639 could add a little bit more padding. So, 2357 01:43:58,400 --> 01:44:05,440 let's change it to maybe 18 pixels. 2358 01:44:02,639 --> 01:44:07,679 Save and refresh. All right. So, I think 2359 01:44:05,440 --> 01:44:09,280 this looks close enough. Now, the last 2360 01:44:07,679 --> 01:44:11,840 thing we're going to work on is this 2361 01:44:09,280 --> 01:44:14,960 text here that becomes underlined when 2362 01:44:11,840 --> 01:44:17,360 we hover over it. First, let's learn how 2363 01:44:14,960 --> 01:44:19,520 to create underline text. We're going to 2364 01:44:17,360 --> 01:44:22,480 practice our Googling skills and we're 2365 01:44:19,520 --> 01:44:26,400 just going to search for CSS text 2366 01:44:22,480 --> 01:44:29,040 underline. So, keep it simple. 2367 01:44:26,400 --> 01:44:31,840 And then in the first link, we have the 2368 01:44:29,040 --> 01:44:34,080 text decoration property. If we scroll 2369 01:44:31,840 --> 01:44:36,400 down, we have an overline, line through, 2370 01:44:34,080 --> 01:44:38,800 and underline. 2371 01:44:36,400 --> 01:44:41,840 So, let's grab this piece of code. I'm 2372 01:44:38,800 --> 01:44:45,920 going to just copy it in here. 2373 01:44:41,840 --> 01:44:48,080 Save and refresh. Now, unfortunately, 2374 01:44:45,920 --> 01:44:50,560 this property actually affects the 2375 01:44:48,080 --> 01:44:53,119 entire paragraph, but we want it to only 2376 01:44:50,560 --> 01:44:55,119 affect this part of the text. So, how do 2377 01:44:53,119 --> 01:44:58,560 we do that? We're going to need to learn 2378 01:44:55,119 --> 01:45:00,639 something called a text element. So, a 2379 01:44:58,560 --> 01:45:03,280 text element is an element that is 2380 01:45:00,639 --> 01:45:06,800 inside a line of text. So, let's do an 2381 01:45:03,280 --> 01:45:07,920 example just to see how it works. 2382 01:45:06,800 --> 01:45:09,760 We're going to go to the bottom and 2383 01:45:07,920 --> 01:45:12,000 we're going to create a new paragraph to 2384 01:45:09,760 --> 01:45:16,719 practice with. And let's actually just 2385 01:45:12,000 --> 01:45:19,280 copy this text and put it in there. 2386 01:45:16,719 --> 01:45:21,600 Save and refresh. And now we're going to 2387 01:45:19,280 --> 01:45:24,080 create some text elements on this 2388 01:45:21,600 --> 01:45:27,280 paragraph. So the first text element I'm 2389 01:45:24,080 --> 01:45:29,520 going to show you is called the strong 2390 01:45:27,280 --> 01:45:33,119 element. 2391 01:45:29,520 --> 01:45:36,000 So now let's copy maybe this text and 2392 01:45:33,119 --> 01:45:41,199 then put it in there 2393 01:45:36,000 --> 01:45:43,920 and save and refresh. 2394 01:45:41,199 --> 01:45:45,679 So the strong element here creates this 2395 01:45:43,920 --> 01:45:48,080 bolded text that you see on the web 2396 01:45:45,679 --> 01:45:50,560 page. So the thing to know about text 2397 01:45:48,080 --> 01:45:52,800 elements is that they essentially exist 2398 01:45:50,560 --> 01:45:55,760 inside a line of text and then they 2399 01:45:52,800 --> 01:45:58,480 modify that part of the text. So they're 2400 01:45:55,760 --> 01:46:01,360 not modifying the whole thing. 2401 01:45:58,480 --> 01:46:03,920 Another text element we can create is 2402 01:46:01,360 --> 01:46:06,960 the U element. 2403 01:46:03,920 --> 01:46:09,600 So this one creates some text that is 2404 01:46:06,960 --> 01:46:14,000 underlined. So if we move this text into 2405 01:46:09,600 --> 01:46:16,719 here, save it and refresh, 2406 01:46:14,000 --> 01:46:19,280 we now get an underlined text element. 2407 01:46:16,719 --> 01:46:21,840 So that is how we style specific parts 2408 01:46:19,280 --> 01:46:23,600 of a line of text. 2409 01:46:21,840 --> 01:46:27,199 The final text element I want to show 2410 01:46:23,600 --> 01:46:29,840 you is called the span. So let's create 2411 01:46:27,199 --> 01:46:33,040 a span element. 2412 01:46:29,840 --> 01:46:37,360 And we're going to put this text inside. 2413 01:46:33,040 --> 01:46:40,480 So cut and paste. 2414 01:46:37,360 --> 01:46:44,080 save it and refresh. 2415 01:46:40,480 --> 01:46:45,920 Okay, so the span element is here, but 2416 01:46:44,080 --> 01:46:48,719 you'll notice that nothing changed. And 2417 01:46:45,920 --> 01:46:51,199 that's because the span element is the 2418 01:46:48,719 --> 01:46:54,000 most generic text element. It has no 2419 01:46:51,199 --> 01:46:57,679 styles. So the span is really useful 2420 01:46:54,000 --> 01:47:00,080 because we can actually give it a class 2421 01:46:57,679 --> 01:47:03,119 and we can style it ourselves and give 2422 01:47:00,080 --> 01:47:05,679 it any style we want. Now, we could add 2423 01:47:03,119 --> 01:47:07,440 the class attribute to these other text 2424 01:47:05,679 --> 01:47:09,440 elements like the strong and the U 2425 01:47:07,440 --> 01:47:12,000 element. But notice that these text 2426 01:47:09,440 --> 01:47:13,920 elements come with a default style, and 2427 01:47:12,000 --> 01:47:15,760 that may not be what we want, especially 2428 01:47:13,920 --> 01:47:17,679 in this situation where we don't 2429 01:47:15,760 --> 01:47:20,560 actually want a style until we hover 2430 01:47:17,679 --> 01:47:23,440 over it. So, that's why we use the span 2431 01:47:20,560 --> 01:47:25,440 text element. It lets us modify a 2432 01:47:23,440 --> 01:47:27,600 specific part of the text without 2433 01:47:25,440 --> 01:47:29,199 affecting the whole thing. And it's the 2434 01:47:27,600 --> 01:47:32,080 most flexible and we can style it 2435 01:47:29,199 --> 01:47:36,239 however we want. So if we give it a 2436 01:47:32,080 --> 01:47:38,880 class of span example 2437 01:47:36,239 --> 01:47:43,719 and then go to our CSS and then we 2438 01:47:38,880 --> 01:47:43,719 target span example, 2439 01:47:44,320 --> 01:47:50,560 we can give it any styles that we want. 2440 01:47:46,719 --> 01:47:54,080 For example, we can set a color of red. 2441 01:47:50,560 --> 01:47:56,560 Now if we save this and refresh, the 2442 01:47:54,080 --> 01:47:57,920 span now turns this part of the text 2443 01:47:56,560 --> 01:47:59,520 red. 2444 01:47:57,920 --> 01:48:04,440 The other cool thing is that everything 2445 01:47:59,520 --> 01:48:04,440 we know about CSS still applies. 2446 01:48:04,639 --> 01:48:12,480 So we can target span example colon 2447 01:48:09,199 --> 01:48:15,840 hover. And these styles will only apply 2448 01:48:12,480 --> 01:48:18,560 when we hover over the span. So in this 2449 01:48:15,840 --> 01:48:21,840 case, let's underline it because that's 2450 01:48:18,560 --> 01:48:23,440 what we want. So if we do text dash 2451 01:48:21,840 --> 01:48:27,760 decoration 2452 01:48:23,440 --> 01:48:29,760 and underline just like up here, save it 2453 01:48:27,760 --> 01:48:33,360 and refresh. 2454 01:48:29,760 --> 01:48:35,760 Now this span has a color of red here. 2455 01:48:33,360 --> 01:48:39,040 And when we hover over it, the style 2456 01:48:35,760 --> 01:48:41,280 apply and it's going to get underlined. 2457 01:48:39,040 --> 01:48:44,639 Let's use what we learned here to finish 2458 01:48:41,280 --> 01:48:46,719 up our example. 2459 01:48:44,639 --> 01:48:48,239 We're going to first remove this line 2460 01:48:46,719 --> 01:48:49,440 because we don't want to underline the 2461 01:48:48,239 --> 01:48:51,840 whole thing. 2462 01:48:49,440 --> 01:48:54,480 Let's refresh. And we want to create a 2463 01:48:51,840 --> 01:48:57,679 span so that we only target this part of 2464 01:48:54,480 --> 01:48:59,440 the text. Let's go back down. I'm going 2465 01:48:57,679 --> 01:49:02,480 to resize it a little bit just so that 2466 01:48:59,440 --> 01:49:04,880 we can see. 2467 01:49:02,480 --> 01:49:08,560 Okay. So, we're going to scroll down to 2468 01:49:04,880 --> 01:49:13,040 here. We're going to wrap this 2469 01:49:08,560 --> 01:49:15,600 in a span. Just going to move this into 2470 01:49:13,040 --> 01:49:17,360 here. 2471 01:49:15,600 --> 01:49:19,840 Save. 2472 01:49:17,360 --> 01:49:22,560 Refresh. 2473 01:49:19,840 --> 01:49:24,560 And now we're going to style this span. 2474 01:49:22,560 --> 01:49:26,639 So remember, we're going to give it a 2475 01:49:24,560 --> 01:49:31,600 class so that we can target it in our 2476 01:49:26,639 --> 01:49:36,159 CSS. Let's call this the shop link. 2477 01:49:31,600 --> 01:49:41,400 Save it. And let's go here and we're 2478 01:49:36,159 --> 01:49:41,400 going to style it now. So shop-link. 2479 01:49:41,440 --> 01:49:47,119 So remember the style for this is that 2480 01:49:43,440 --> 01:49:48,560 the mouse turns into this pointer. 2481 01:49:47,119 --> 01:49:52,320 So to do that, we're going to use the 2482 01:49:48,560 --> 01:49:55,520 property cursor dash pointer. 2483 01:49:52,320 --> 01:49:58,639 Save and refresh. So now when we hover 2484 01:49:55,520 --> 01:50:00,159 over it, our mouse is a pointer. 2485 01:49:58,639 --> 01:50:02,480 And the last thing is that we want it to 2486 01:50:00,159 --> 01:50:06,719 be underlined when we hover over it. So 2487 01:50:02,480 --> 01:50:07,920 let's create a hover style shop-link. 2488 01:50:06,719 --> 01:50:12,480 And we're going to give this pseudo 2489 01:50:07,920 --> 01:50:13,840 class colon hover. 2490 01:50:12,480 --> 01:50:17,520 And we're going to underline it with 2491 01:50:13,840 --> 01:50:20,520 text decoration 2492 01:50:17,520 --> 01:50:20,520 underline. 2493 01:50:20,639 --> 01:50:27,199 Save it and refresh. And now when we 2494 01:50:24,400 --> 01:50:29,199 hover over this, it's going to turn our 2495 01:50:27,199 --> 01:50:31,199 mouse into a pointer and it's going to 2496 01:50:29,199 --> 01:50:35,280 underline it. So we've achieved the 2497 01:50:31,199 --> 01:50:36,719 exact same styles as our design. 2498 01:50:35,280 --> 01:50:38,719 So there's one last thing I'm going to 2499 01:50:36,719 --> 01:50:40,960 show you in this lesson. Let's go back 2500 01:50:38,719 --> 01:50:43,280 into our code. We're going to scroll all 2501 01:50:40,960 --> 01:50:46,639 the way to the bottom. And recall that 2502 01:50:43,280 --> 01:50:49,360 in HTML, if we have multiple spaces like 2503 01:50:46,639 --> 01:50:53,040 this, it will combine them all into one 2504 01:50:49,360 --> 01:50:55,360 space. So, if I save this and refresh, 2505 01:50:53,040 --> 01:50:57,280 you'll see that only one space shows up 2506 01:50:55,360 --> 01:50:59,679 here. So, I'm going to show you how to 2507 01:50:57,280 --> 01:51:01,840 get over this problem. Basically, 2508 01:50:59,679 --> 01:51:05,040 instead of typing out multiple spaces in 2509 01:51:01,840 --> 01:51:08,080 our HTML, all we have to do is set a 2510 01:51:05,040 --> 01:51:10,080 margin left on this text element. So, 2511 01:51:08,080 --> 01:51:12,400 we're going to set a margin left on this 2512 01:51:10,080 --> 01:51:14,719 element and it's going to add spaces on 2513 01:51:12,400 --> 01:51:18,400 the left. 2514 01:51:14,719 --> 01:51:23,119 So, as an example, let's scroll up 2515 01:51:18,400 --> 01:51:26,800 and we're going to add margin-left 2516 01:51:23,119 --> 01:51:30,159 to our span element here. And let's do 2517 01:51:26,800 --> 01:51:32,960 something like 12 pixels. Save it and 2518 01:51:30,159 --> 01:51:36,159 refresh. And now we have spacing between 2519 01:51:32,960 --> 01:51:38,639 our words. So this is how we achieve 2520 01:51:36,159 --> 01:51:42,320 multiple spaces between our words even 2521 01:51:38,639 --> 01:51:44,159 though HTML combines them. So that is 2522 01:51:42,320 --> 01:51:47,679 how we create really professional 2523 01:51:44,159 --> 01:51:50,239 looking text like this and like this. We 2524 01:51:47,679 --> 01:51:53,599 first create the element with HTML and 2525 01:51:50,239 --> 01:51:55,679 then we style it one by one with CSS. 2526 01:51:53,599 --> 01:51:58,239 And if we want to style only just a part 2527 01:51:55,679 --> 01:52:02,199 of the text, we have to use a text 2528 01:51:58,239 --> 01:52:02,199 element like a span. 2529 01:52:20,960 --> 01:52:24,960 In this lesson, we're going to learn the 2530 01:52:22,480 --> 01:52:26,480 proper structure of HTML, and that's 2531 01:52:24,960 --> 01:52:28,880 going to give us access to all the 2532 01:52:26,480 --> 01:52:30,880 features of HTML. 2533 01:52:28,880 --> 01:52:33,119 So, up until this point, we've actually 2534 01:52:30,880 --> 01:52:36,080 haven't been following that structure. 2535 01:52:33,119 --> 01:52:38,080 For example, if we look at our code, we 2536 01:52:36,080 --> 01:52:40,800 scroll down, we can see that we're 2537 01:52:38,080 --> 01:52:43,280 creating elements directly like this. If 2538 01:52:40,800 --> 01:52:47,119 we go to our website, however, and we 2539 01:52:43,280 --> 01:52:50,480 rightclick and inspect, and we look at 2540 01:52:47,119 --> 01:52:53,280 our HTML, we can see that we have some 2541 01:52:50,480 --> 01:52:56,400 elements here called the HTML element, 2542 01:52:53,280 --> 01:52:58,239 the head element, and the body element. 2543 01:52:56,400 --> 01:53:00,800 So, this is a structure that we're 2544 01:52:58,239 --> 01:53:03,119 actually supposed to have in our HTML 2545 01:53:00,800 --> 01:53:05,119 file. And because we don't have it, the 2546 01:53:03,119 --> 01:53:07,840 browser is automatically creating this 2547 01:53:05,119 --> 01:53:09,360 for us. So, this was fine in the 2548 01:53:07,840 --> 01:53:11,440 previous lessons because we're just 2549 01:53:09,360 --> 01:53:13,440 learning, but it's actually best to have 2550 01:53:11,440 --> 01:53:16,320 this structure in our code because we're 2551 01:53:13,440 --> 01:53:18,080 actually missing some useful features. 2552 01:53:16,320 --> 01:53:21,119 So, let's go ahead and learn what the 2553 01:53:18,080 --> 01:53:22,719 structure is and add it to our code. So, 2554 01:53:21,119 --> 01:53:26,080 we're going to go back to all of our 2555 01:53:22,719 --> 01:53:28,719 code and add in this structure. 2556 01:53:26,080 --> 01:53:32,480 Let's go back to our very first HTML 2557 01:53:28,719 --> 01:53:34,159 file. And at the top, I'm going to add 2558 01:53:32,480 --> 01:53:37,599 some spaces. And we're going to learn 2559 01:53:34,159 --> 01:53:40,000 what the proper structure is. Every HTML 2560 01:53:37,599 --> 01:53:45,199 file is going to start with less than 2561 01:53:40,000 --> 01:53:47,119 exclamation doc type space HTML greater 2562 01:53:45,199 --> 01:53:50,159 than. So, you just have to type this 2563 01:53:47,119 --> 01:53:52,400 line out exactly as I have it here. This 2564 01:53:50,159 --> 01:53:54,239 is not really an element. It's just a 2565 01:53:52,400 --> 01:53:56,639 special line that has a meaning to the 2566 01:53:54,239 --> 01:53:59,280 browser. This tells the browser to use a 2567 01:53:56,639 --> 01:54:01,199 modern version of HTML. If we don't have 2568 01:53:59,280 --> 01:54:04,560 this, it sort of falls back to an older 2569 01:54:01,199 --> 01:54:06,159 version that has less features. 2570 01:54:04,560 --> 01:54:09,760 The next part of the structure is to 2571 01:54:06,159 --> 01:54:12,080 create an HTML element. 2572 01:54:09,760 --> 01:54:13,840 So, this says there's a web page inside 2573 01:54:12,080 --> 01:54:16,159 this element. There's not much meaning 2574 01:54:13,840 --> 01:54:18,560 to it. We just have to have this at the 2575 01:54:16,159 --> 01:54:21,360 top and the closing tag at the bottom of 2576 01:54:18,560 --> 01:54:23,440 every HTML file. 2577 01:54:21,360 --> 01:54:24,960 Next, we're going to create this head 2578 01:54:23,440 --> 01:54:29,280 element. 2579 01:54:24,960 --> 01:54:34,000 So head and closing tag and we're going 2580 01:54:29,280 --> 01:54:36,960 to create the body element. So body 2581 01:54:34,000 --> 01:54:39,119 and closing tag. 2582 01:54:36,960 --> 01:54:41,920 So this is the proper structure of all 2583 01:54:39,119 --> 01:54:45,679 of our HTML files. And this is how we're 2584 01:54:41,920 --> 01:54:47,360 supposed to start and end our files. 2585 01:54:45,679 --> 01:54:50,320 So here you can see that we have an 2586 01:54:47,360 --> 01:54:53,280 element inside another element. This is 2587 01:54:50,320 --> 01:54:55,520 called nesting. So, not only can we have 2588 01:54:53,280 --> 01:54:58,320 text inside an element, we can have 2589 01:54:55,520 --> 01:54:59,920 other elements inside elements. We've 2590 01:54:58,320 --> 01:55:02,560 actually already seen an example of this 2591 01:54:59,920 --> 01:55:05,760 in the previous lesson. We put a text 2592 01:55:02,560 --> 01:55:07,760 element like a span inside a paragraph 2593 01:55:05,760 --> 01:55:09,280 and that allows us to have some text in 2594 01:55:07,760 --> 01:55:11,840 the paragraph that was styled 2595 01:55:09,280 --> 01:55:15,040 differently. Here we have our second 2596 01:55:11,840 --> 01:55:19,199 example of nesting. We have a head and a 2597 01:55:15,040 --> 01:55:20,400 body element inside an HTML element. So 2598 01:55:19,199 --> 01:55:22,480 this doesn't actually do anything 2599 01:55:20,400 --> 01:55:24,719 visually unlike our previous example, 2600 01:55:22,480 --> 01:55:27,520 but it's part of the HTML syntax rules 2601 01:55:24,719 --> 01:55:30,960 that we have to follow. Every file has 2602 01:55:27,520 --> 01:55:34,320 one and only one HTML element. And this 2603 01:55:30,960 --> 01:55:36,880 element represents the entire web page. 2604 01:55:34,320 --> 01:55:39,280 And the HTML element is designed for 2605 01:55:36,880 --> 01:55:42,719 nesting. It's designed to contain one 2606 01:55:39,280 --> 01:55:44,800 head element and one body element. And 2607 01:55:42,719 --> 01:55:47,199 then everything on our web page is 2608 01:55:44,800 --> 01:55:49,360 supposed to go either inside the head or 2609 01:55:47,199 --> 01:55:51,920 inside the body. So both of these 2610 01:55:49,360 --> 01:55:55,440 elements are also designed for nesting 2611 01:55:51,920 --> 01:55:57,679 or to have elements inside. 2612 01:55:55,440 --> 01:55:59,520 The body element here is supposed to 2613 01:55:57,679 --> 01:56:02,159 contain all the elements that are 2614 01:55:59,520 --> 01:56:04,400 visible on the page. So let's actually 2615 01:56:02,159 --> 01:56:06,560 open this website. We're going to go 2616 01:56:04,400 --> 01:56:09,360 into our folder that contains our code 2617 01:56:06,560 --> 01:56:10,880 and we're going to rightclick open with 2618 01:56:09,360 --> 01:56:13,040 Chrome. 2619 01:56:10,880 --> 01:56:15,199 So on this website you can see that the 2620 01:56:13,040 --> 01:56:18,000 paragraph is visible, the button and the 2621 01:56:15,199 --> 01:56:20,639 link is visible. So all of this is 2622 01:56:18,000 --> 01:56:22,239 visible on the website. So it should go 2623 01:56:20,639 --> 01:56:25,960 into 2624 01:56:22,239 --> 01:56:25,960 this body section. 2625 01:56:27,040 --> 01:56:31,280 Inside the head element are all the 2626 01:56:29,119 --> 01:56:33,920 elements that are not visible on the 2627 01:56:31,280 --> 01:56:35,679 page. So here's an example of such an 2628 01:56:33,920 --> 01:56:39,119 element. We're going to create an 2629 01:56:35,679 --> 01:56:42,080 element called title. 2630 01:56:39,119 --> 01:56:44,080 So the text inside the title here is 2631 01:56:42,080 --> 01:56:47,440 going to change the text in the tab 2632 01:56:44,080 --> 01:56:52,080 here. So for example, 2633 01:56:47,440 --> 01:56:53,760 if I use the text first website, 2634 01:56:52,080 --> 01:56:56,639 that's going to show up in the tab. So 2635 01:56:53,760 --> 01:56:59,280 if I save and refresh, that's where the 2636 01:56:56,639 --> 01:57:00,880 title element shows up. But notice that 2637 01:56:59,280 --> 01:57:02,800 this title element doesn't actually show 2638 01:57:00,880 --> 01:57:05,520 up on the page. And that's why it 2639 01:57:02,800 --> 01:57:07,440 belongs in the head section. 2640 01:57:05,520 --> 01:57:09,760 So the title is the first feature that 2641 01:57:07,440 --> 01:57:11,280 we get from following this structure. 2642 01:57:09,760 --> 01:57:13,440 The second feature that we get that's 2643 01:57:11,280 --> 01:57:16,239 really useful is the ability to 2644 01:57:13,440 --> 01:57:19,360 automatically reload our web page 2645 01:57:16,239 --> 01:57:21,119 whenever we change our code. So you may 2646 01:57:19,360 --> 01:57:23,040 have noticed that every time we change 2647 01:57:21,119 --> 01:57:25,280 our code, 2648 01:57:23,040 --> 01:57:28,080 we have to go to our website and then 2649 01:57:25,280 --> 01:57:30,000 refresh the page to see our new code. 2650 01:57:28,080 --> 01:57:32,000 Now we can actually avoid this by 2651 01:57:30,000 --> 01:57:35,119 following this structure and then 2652 01:57:32,000 --> 01:57:37,679 installing a VS Code extension. So, 2653 01:57:35,119 --> 01:57:40,239 let's go to this extension area here. 2654 01:57:37,679 --> 01:57:42,960 And we're going to install the extension 2655 01:57:40,239 --> 01:57:46,880 live server. 2656 01:57:42,960 --> 01:57:49,199 I'm going to install this. 2657 01:57:46,880 --> 01:57:51,119 And now we can use the live server to 2658 01:57:49,199 --> 01:57:54,239 reload our page automatically whenever 2659 01:57:51,119 --> 01:57:56,239 our code changes. To open this website 2660 01:57:54,239 --> 01:57:58,000 in a live server, we're going to 2661 01:57:56,239 --> 01:58:00,320 rightclick 2662 01:57:58,000 --> 01:58:03,320 and we're going to click open with live 2663 01:58:00,320 --> 01:58:03,320 server. 2664 01:58:03,599 --> 01:58:08,320 And now we've opened this website and it 2665 01:58:05,679 --> 01:58:10,000 will automatically refresh whenever we 2666 01:58:08,320 --> 01:58:12,560 change our code. So if I change the code 2667 01:58:10,000 --> 01:58:14,639 like this and I save, 2668 01:58:12,560 --> 01:58:17,920 now it automatically refreshes without 2669 01:58:14,639 --> 01:58:19,760 having us to go back and forth. 2670 01:58:17,920 --> 01:58:22,320 So that's a really useful feature to 2671 01:58:19,760 --> 01:58:23,760 speed up our development. Now let's get 2672 01:58:22,320 --> 01:58:26,400 some more practice and we're going to 2673 01:58:23,760 --> 01:58:28,960 convert both of these HTML files to use 2674 01:58:26,400 --> 01:58:31,520 the proper structure. First, I'm going 2675 01:58:28,960 --> 01:58:35,360 to actually just delete all the extra 2676 01:58:31,520 --> 01:58:37,920 tabs here. And now, let's work on the 2677 01:58:35,360 --> 01:58:39,920 buttons file. 2678 01:58:37,920 --> 01:58:42,080 Now, the live server doesn't really work 2679 01:58:39,920 --> 01:58:44,000 if we don't have that proper HTML 2680 01:58:42,080 --> 01:58:46,400 structure in our code. So, let's add 2681 01:58:44,000 --> 01:58:47,679 that structure first. 2682 01:58:46,400 --> 01:58:49,360 I'm going to go up here and we're going 2683 01:58:47,679 --> 01:58:53,360 to create the structure. So remember, we 2684 01:58:49,360 --> 01:58:55,520 start with a doc type 2685 01:58:53,360 --> 01:58:57,599 space HTML 2686 01:58:55,520 --> 01:59:00,599 and then we're going to create an HTML 2687 01:58:57,599 --> 01:59:00,599 element 2688 01:59:00,960 --> 01:59:04,719 and then inside we're going to create a 2689 01:59:02,800 --> 01:59:09,639 head 2690 01:59:04,719 --> 01:59:09,639 and we're going to create a body element 2691 01:59:09,679 --> 01:59:13,679 and remember the body contains 2692 01:59:11,440 --> 01:59:16,639 everything that is visible on the page. 2693 01:59:13,679 --> 01:59:18,639 So if we scroll down, 2694 01:59:16,639 --> 01:59:21,360 these three buttons are visible on the 2695 01:59:18,639 --> 01:59:24,920 page. So we're going to move these into 2696 01:59:21,360 --> 01:59:24,920 the body element. 2697 01:59:26,239 --> 01:59:31,119 And now they're in the right place. Now 2698 01:59:28,639 --> 01:59:33,040 for this style element, remember that we 2699 01:59:31,119 --> 01:59:35,440 said the style element doesn't actually 2700 01:59:33,040 --> 01:59:37,599 create anything visible on the page, but 2701 01:59:35,440 --> 01:59:40,320 it could change the style of other 2702 01:59:37,599 --> 01:59:42,000 elements. So, this is a good example of 2703 01:59:40,320 --> 01:59:43,840 something that should go in the head 2704 01:59:42,000 --> 01:59:46,239 element because it doesn't show up 2705 01:59:43,840 --> 01:59:48,800 visibly on the page. So, we're going to 2706 01:59:46,239 --> 01:59:52,119 copy all of this and put it into the 2707 01:59:48,800 --> 01:59:52,119 head element. 2708 01:59:52,480 --> 01:59:57,760 Going to go up and we're going to save 2709 01:59:54,960 --> 02:00:00,000 this in here. So, now all of our CSS 2710 01:59:57,760 --> 02:00:02,159 code is in the right place. And now that 2711 02:00:00,000 --> 02:00:04,880 we have the proper structure, we can 2712 02:00:02,159 --> 02:00:08,480 open this with our live server just to 2713 02:00:04,880 --> 02:00:11,199 make sure everything looks good. 2714 02:00:08,480 --> 02:00:12,800 Let's go here and add a title like we 2715 02:00:11,199 --> 02:00:14,480 learned. 2716 02:00:12,800 --> 02:00:17,040 And this is going to change the text at 2717 02:00:14,480 --> 02:00:20,080 the top of the tab. So, let's call this 2718 02:00:17,040 --> 02:00:21,920 buttons practice. 2719 02:00:20,080 --> 02:00:24,639 Save it. And you'll notice that it 2720 02:00:21,920 --> 02:00:25,760 automatically reloads. 2721 02:00:24,639 --> 02:00:27,679 Now, we're going to learn another 2722 02:00:25,760 --> 02:00:30,320 feature that we get from following this 2723 02:00:27,679 --> 02:00:32,880 structure. If we look at our code, we 2724 02:00:30,320 --> 02:00:35,520 have all of our CSS code together along 2725 02:00:32,880 --> 02:00:37,440 with our HTML code. Now, this gets 2726 02:00:35,520 --> 02:00:39,679 confusing because we have a lot of lines 2727 02:00:37,440 --> 02:00:42,239 of code and we're mixing two different 2728 02:00:39,679 --> 02:00:44,719 languages. To solve this problem, we can 2729 02:00:42,239 --> 02:00:48,800 move all of our CSS into a different 2730 02:00:44,719 --> 02:00:51,040 file. So, let's copy all of this. And 2731 02:00:48,800 --> 02:00:54,159 we're going to create a new file to just 2732 02:00:51,040 --> 02:00:57,920 contain our CSS. We're going to go here 2733 02:00:54,159 --> 02:01:00,920 and create a new file. And let's call it 2734 02:00:57,920 --> 02:01:00,920 buttons.css. 2735 02:01:01,520 --> 02:01:06,800 Make sure your file ends in CSS to tell 2736 02:01:04,400 --> 02:01:09,280 the computer that this file contains CSS 2737 02:01:06,800 --> 02:01:11,760 code. 2738 02:01:09,280 --> 02:01:15,560 And now we're going to move our code 2739 02:01:11,760 --> 02:01:15,560 into that file 2740 02:01:15,920 --> 02:01:21,199 and save 2741 02:01:18,480 --> 02:01:22,639 and save here. 2742 02:01:21,199 --> 02:01:24,480 Now, you'll notice that we lost all of 2743 02:01:22,639 --> 02:01:27,840 our styles, and that's because we now 2744 02:01:24,480 --> 02:01:30,480 need to load this new CSS file into our 2745 02:01:27,840 --> 02:01:35,199 HTML. To do that, we're going to learn a 2746 02:01:30,480 --> 02:01:37,440 new element called the link element. 2747 02:01:35,199 --> 02:01:39,920 So the link is sort of a special element 2748 02:01:37,440 --> 02:01:42,320 because it doesn't require a closing tag 2749 02:01:39,920 --> 02:01:45,440 like we've seen so far. Elements like 2750 02:01:42,320 --> 02:01:47,520 these are called void elements. So if we 2751 02:01:45,440 --> 02:01:52,719 search for Google 2752 02:01:47,520 --> 02:01:55,040 and we search void elements HTML, 2753 02:01:52,719 --> 02:01:57,440 this will give us a list of elements 2754 02:01:55,040 --> 02:01:59,440 that don't need a closing tag. So these 2755 02:01:57,440 --> 02:02:02,080 are the exceptions to the rule that 2756 02:01:59,440 --> 02:02:03,679 everything has to have a closing tag. So 2757 02:02:02,080 --> 02:02:05,840 don't worry too much about memorizing 2758 02:02:03,679 --> 02:02:08,320 all of these. You'll get more used to it 2759 02:02:05,840 --> 02:02:10,239 the more that you write HTML. And I'll 2760 02:02:08,320 --> 02:02:12,400 introduce void elements to you one by 2761 02:02:10,239 --> 02:02:14,400 one. So here we're going to learn our 2762 02:02:12,400 --> 02:02:17,599 first void element which doesn't need a 2763 02:02:14,400 --> 02:02:21,760 closing tag. But this element takes two 2764 02:02:17,599 --> 02:02:24,320 attributes. The first one is called reel 2765 02:02:21,760 --> 02:02:27,199 which stands for relation. So what kind 2766 02:02:24,320 --> 02:02:29,920 of thing are we linking in? In this 2767 02:02:27,199 --> 02:02:31,840 case, we're going to link in a style 2768 02:02:29,920 --> 02:02:33,520 sheet 2769 02:02:31,840 --> 02:02:36,880 and then we have to tell it another 2770 02:02:33,520 --> 02:02:39,440 attribute which is href. 2771 02:02:36,880 --> 02:02:42,800 So this tells a link what file we're 2772 02:02:39,440 --> 02:02:45,760 going to link into this file. So here 2773 02:02:42,800 --> 02:02:48,719 we're going to link our CSS file into 2774 02:02:45,760 --> 02:02:50,560 our HTML. So we're going to link 2775 02:02:48,719 --> 02:02:52,880 buttons.css. 2776 02:02:50,560 --> 02:02:54,800 Okay. Now let's go back to our page. You 2777 02:02:52,880 --> 02:02:57,040 notice we don't have our styles. And now 2778 02:02:54,800 --> 02:02:59,599 when I save this, 2779 02:02:57,040 --> 02:03:01,920 we get all of our styles back. And 2780 02:02:59,599 --> 02:03:04,560 that's because we're loading all the CSS 2781 02:03:01,920 --> 02:03:07,280 code found in buttons.css, 2782 02:03:04,560 --> 02:03:10,560 which is all the code we had before into 2783 02:03:07,280 --> 02:03:13,119 our HTML. So this is another way to load 2784 02:03:10,560 --> 02:03:15,840 CSS without having to write it all in 2785 02:03:13,119 --> 02:03:18,080 our HTML file. Now, the big benefit of 2786 02:03:15,840 --> 02:03:21,119 this is that each file contains less 2787 02:03:18,080 --> 02:03:23,920 code and each file contains one type of 2788 02:03:21,119 --> 02:03:27,040 code. So in this file we only have HTML 2789 02:03:23,920 --> 02:03:29,760 code and in this file we only have CSS 2790 02:03:27,040 --> 02:03:31,679 code. So it makes the files smaller and 2791 02:03:29,760 --> 02:03:34,639 more focused and that's going to help us 2792 02:03:31,679 --> 02:03:36,560 develop easier. 2793 02:03:34,639 --> 02:03:40,239 Now before we move on I do want to talk 2794 02:03:36,560 --> 02:03:42,960 about the href attribute. So the way 2795 02:03:40,239 --> 02:03:45,440 that the computer finds this file is 2796 02:03:42,960 --> 02:03:48,159 that it's going to search right beside 2797 02:03:45,440 --> 02:03:50,400 our HTML file. So, it's going to search 2798 02:03:48,159 --> 02:03:52,560 right beside the file that this code is 2799 02:03:50,400 --> 02:03:54,320 in. So, it's going to look for a file 2800 02:03:52,560 --> 02:03:56,480 called buttons.css. 2801 02:03:54,320 --> 02:03:58,000 It finds it and it loads it into our 2802 02:03:56,480 --> 02:04:00,880 HTML. 2803 02:03:58,000 --> 02:04:03,920 But if this file was in a folder, let's 2804 02:04:00,880 --> 02:04:06,000 create a new folder. Let's call this 2805 02:04:03,920 --> 02:04:08,239 styles. 2806 02:04:06,000 --> 02:04:10,800 Let's put the CSS file in our new 2807 02:04:08,239 --> 02:04:13,119 folder. 2808 02:04:10,800 --> 02:04:15,840 And now you notice that the styles are 2809 02:04:13,119 --> 02:04:18,880 gone. And that's because this link can't 2810 02:04:15,840 --> 02:04:20,320 find buttons.css anymore. What it's 2811 02:04:18,880 --> 02:04:22,800 trying to do is it's trying to look for 2812 02:04:20,320 --> 02:04:26,000 a file called buttons.css beside our 2813 02:04:22,800 --> 02:04:27,679 HTML. And there's nothing there. 2814 02:04:26,000 --> 02:04:30,000 So to link a file that's inside a 2815 02:04:27,679 --> 02:04:32,320 folder, you first have to give the name 2816 02:04:30,000 --> 02:04:36,639 of the folder that's beside the HTML 2817 02:04:32,320 --> 02:04:39,520 file. In this case, it's styles. 2818 02:04:36,639 --> 02:04:42,719 Next, we have to type a slash. So this 2819 02:04:39,520 --> 02:04:45,760 slash means we're going into the styles 2820 02:04:42,719 --> 02:04:47,760 folder and then inside we're going to 2821 02:04:45,760 --> 02:04:50,239 find the buttons.css. 2822 02:04:47,760 --> 02:04:52,400 So this is something called file paths 2823 02:04:50,239 --> 02:04:55,280 and this is basically how we locate 2824 02:04:52,400 --> 02:04:58,000 different files within our HTML code. So 2825 02:04:55,280 --> 02:05:00,800 let's save this. And now we're able to 2826 02:04:58,000 --> 02:05:02,719 successfully link our CSS file. So 2827 02:05:00,800 --> 02:05:04,800 that's a little bit about how file paths 2828 02:05:02,719 --> 02:05:06,960 work. We're going to need to use this 2829 02:05:04,800 --> 02:05:09,520 later on in this course when we recreate 2830 02:05:06,960 --> 02:05:11,520 YouTube.com. 2831 02:05:09,520 --> 02:05:14,080 Now let's get some more practice and 2832 02:05:11,520 --> 02:05:18,639 we're going to convert our final file 2833 02:05:14,080 --> 02:05:21,360 into the proper HTML structure. 2834 02:05:18,639 --> 02:05:23,280 So let's create the structure first 2835 02:05:21,360 --> 02:05:24,800 because we can't use live server just 2836 02:05:23,280 --> 02:05:27,599 yet. 2837 02:05:24,800 --> 02:05:31,199 We're going to write a doc type space 2838 02:05:27,599 --> 02:05:34,000 HTML at the top and then we're going to 2839 02:05:31,199 --> 02:05:35,840 have an HTML element 2840 02:05:34,000 --> 02:05:38,000 and then inside we're going to have a 2841 02:05:35,840 --> 02:05:39,599 head element 2842 02:05:38,000 --> 02:05:41,840 and then we're going to have a body 2843 02:05:39,599 --> 02:05:43,440 element. 2844 02:05:41,840 --> 02:05:45,840 Now everything that is visible is going 2845 02:05:43,440 --> 02:05:48,560 to go inside the body. So if we scroll 2846 02:05:45,840 --> 02:05:51,599 down all of our paragraphs are going to 2847 02:05:48,560 --> 02:05:55,040 go inside the body. 2848 02:05:51,599 --> 02:05:57,679 cut and paste. 2849 02:05:55,040 --> 02:06:00,800 Save it. And now anything that's not 2850 02:05:57,679 --> 02:06:03,119 visible is going to go inside the head. 2851 02:06:00,800 --> 02:06:05,280 So if we scroll down, the style element 2852 02:06:03,119 --> 02:06:08,639 is not visible on the page. So it's 2853 02:06:05,280 --> 02:06:10,960 going to go inside the head element. 2854 02:06:08,639 --> 02:06:14,360 Cut 2855 02:06:10,960 --> 02:06:14,360 and paste. 2856 02:06:14,880 --> 02:06:20,159 All right. So now we have a proper HTML 2857 02:06:17,679 --> 02:06:22,320 structure. We're going to open this with 2858 02:06:20,159 --> 02:06:24,560 live server. 2859 02:06:22,320 --> 02:06:26,800 Move it to the left here. Everything 2860 02:06:24,560 --> 02:06:28,880 looks good. And we're going to do some 2861 02:06:26,800 --> 02:06:32,560 more practice. We're going to set the 2862 02:06:28,880 --> 02:06:36,079 title again just to get more repetition. 2863 02:06:32,560 --> 02:06:37,920 Let's call this text practice. 2864 02:06:36,079 --> 02:06:40,159 Save it. And you'll notice that the 2865 02:06:37,920 --> 02:06:43,920 title is set up here. And we're going to 2866 02:06:40,159 --> 02:06:46,639 move all of this into a CSS file. So, 2867 02:06:43,920 --> 02:06:50,280 let's create a new file 2868 02:06:46,639 --> 02:06:50,280 called text.css. 2869 02:06:51,040 --> 02:06:57,760 And we're going to move all of the CSS 2870 02:06:54,000 --> 02:07:02,560 code into there. So, let's 2871 02:06:57,760 --> 02:07:05,599 cut and paste it into here. 2872 02:07:02,560 --> 02:07:09,360 Next, we're going to link the CSS file 2873 02:07:05,599 --> 02:07:13,119 in this HTML file. So, let's create a 2874 02:07:09,360 --> 02:07:14,800 link element. It needs two attributes. 2875 02:07:13,119 --> 02:07:18,119 reel 2876 02:07:14,800 --> 02:07:18,119 and href. 2877 02:07:18,960 --> 02:07:26,079 So, we're going to link a stylesheet 2878 02:07:23,119 --> 02:07:30,000 and the file is located right beside the 2879 02:07:26,079 --> 02:07:32,079 HTML file. So, all we need to do is link 2880 02:07:30,000 --> 02:07:35,440 text.css. 2881 02:07:32,079 --> 02:07:38,000 Save it and refresh. And now it's back 2882 02:07:35,440 --> 02:07:41,440 to where we were again. Let's practice 2883 02:07:38,000 --> 02:07:43,840 moving this into a folder. 2884 02:07:41,440 --> 02:07:46,400 Now, we're unable to find text.css 2885 02:07:43,840 --> 02:07:49,520 beside our HTML file, but there is a 2886 02:07:46,400 --> 02:07:51,840 styles folder. So, we're going to look 2887 02:07:49,520 --> 02:07:54,560 inside the styles folder. Going to use a 2888 02:07:51,840 --> 02:07:58,320 slash to go inside and we're going to 2889 02:07:54,560 --> 02:08:03,040 link this text.css file. And that is how 2890 02:07:58,320 --> 02:08:04,400 we use file paths to link CSS files. 2891 02:08:03,040 --> 02:08:06,960 The last feature we're going to look at 2892 02:08:04,400 --> 02:08:09,280 that we get from this structure is the 2893 02:08:06,960 --> 02:08:12,159 ability to add new fonts onto our 2894 02:08:09,280 --> 02:08:14,880 website. So websites have a set of fonts 2895 02:08:12,159 --> 02:08:17,280 by default that we can use. For example, 2896 02:08:14,880 --> 02:08:19,360 one of them is called Aerial. Another 2897 02:08:17,280 --> 02:08:21,440 one that we've seen is called Times New 2898 02:08:19,360 --> 02:08:24,560 Roman. That's basically the font that we 2899 02:08:21,440 --> 02:08:26,719 get on a fresh website. Now, in addition 2900 02:08:24,560 --> 02:08:29,280 to these default fonts, we can actually 2901 02:08:26,719 --> 02:08:30,800 load new fonts from the internet. And 2902 02:08:29,280 --> 02:08:33,599 we're going to learn how to do that 2903 02:08:30,800 --> 02:08:36,639 within this structure. So, let's go to 2904 02:08:33,599 --> 02:08:38,560 our web page. And Google actually 2905 02:08:36,639 --> 02:08:40,960 provides a lot of really great free 2906 02:08:38,560 --> 02:08:43,440 fonts that we can use. So, we're going 2907 02:08:40,960 --> 02:08:47,599 to open a new tab and we're going to 2908 02:08:43,440 --> 02:08:49,840 search for Google Fonts 2909 02:08:47,599 --> 02:08:52,880 and we're going to go into this first 2910 02:08:49,840 --> 02:08:54,719 link. Now, this website might look a 2911 02:08:52,880 --> 02:08:57,199 little different for you, but the 2912 02:08:54,719 --> 02:08:59,040 general process is the same. First, 2913 02:08:57,199 --> 02:09:01,679 we're going to search for a font that we 2914 02:08:59,040 --> 02:09:03,920 like. So, a good font to use here is 2915 02:09:01,679 --> 02:09:06,800 Robboto. And this is the font that we're 2916 02:09:03,920 --> 02:09:09,599 going to use for our final project. 2917 02:09:06,800 --> 02:09:10,960 We're going to pick this font. And then 2918 02:09:09,599 --> 02:09:13,679 inside here, we're going to pick the 2919 02:09:10,960 --> 02:09:16,880 styles that we want. So, for example, 2920 02:09:13,679 --> 02:09:19,840 I'm going to pick the regular style. 2921 02:09:16,880 --> 02:09:21,840 And I'm also going to pick the bold 2922 02:09:19,840 --> 02:09:25,679 style here. 2923 02:09:21,840 --> 02:09:27,760 So, I'm going to pick the bold style. 2924 02:09:25,679 --> 02:09:30,239 And then I'm going to go to the basket 2925 02:09:27,760 --> 02:09:32,639 of fonts that I selected. And then 2926 02:09:30,239 --> 02:09:35,199 Google is going to give me the code that 2927 02:09:32,639 --> 02:09:38,079 I need to load these fonts. 2928 02:09:35,199 --> 02:09:41,520 All we need to do is copy this code 2929 02:09:38,079 --> 02:09:44,159 exactly and then put it in our head 2930 02:09:41,520 --> 02:09:46,480 section of our HTML. So we're going to 2931 02:09:44,159 --> 02:09:48,800 put it in our structure in this head 2932 02:09:46,480 --> 02:09:51,440 section. 2933 02:09:48,800 --> 02:09:54,320 And now we've loaded a new font that we 2934 02:09:51,440 --> 02:09:56,239 can use on our website. So now let's go 2935 02:09:54,320 --> 02:09:58,239 back to our website and we're going to 2936 02:09:56,239 --> 02:10:00,239 use this new font. 2937 02:09:58,239 --> 02:10:03,760 So remember that currently we set our 2938 02:10:00,239 --> 02:10:06,239 fonts to Ariel. This time we loaded the 2939 02:10:03,760 --> 02:10:08,960 font called Roboto and that's what we're 2940 02:10:06,239 --> 02:10:11,760 going to use. So let's change Ariel here 2941 02:10:08,960 --> 02:10:13,840 to Roboto. 2942 02:10:11,760 --> 02:10:16,840 Now when I save the font is going to 2943 02:10:13,840 --> 02:10:16,840 change. 2944 02:10:17,280 --> 02:10:21,520 And there you go. It might not look that 2945 02:10:19,760 --> 02:10:25,280 much different because Roboto is very 2946 02:10:21,520 --> 02:10:28,239 similar to Ariel. But if we inspect 2947 02:10:25,280 --> 02:10:31,199 and we click on this element and go to 2948 02:10:28,239 --> 02:10:33,520 the computer tab, we'll see that the 2949 02:10:31,199 --> 02:10:36,800 font family has now been changed to 2950 02:10:33,520 --> 02:10:39,599 Roboto. So this is how we can load a 2951 02:10:36,800 --> 02:10:41,440 huge selection of fonts from Google onto 2952 02:10:39,599 --> 02:10:43,840 our web page and use them on our 2953 02:10:41,440 --> 02:10:46,159 website. So those are the features that 2954 02:10:43,840 --> 02:10:48,239 we get from following this HTML 2955 02:10:46,159 --> 02:10:50,880 structure. Every website that we create 2956 02:10:48,239 --> 02:10:53,840 from now on will always have an HTML 2957 02:10:50,880 --> 02:10:57,239 tag, a head and a body, and a doc type 2958 02:10:53,840 --> 02:10:57,239 at the top. 2959 02:11:11,360 --> 02:11:14,639 Now we're ready to work on the final 2960 02:11:13,119 --> 02:11:16,880 project of this course, 2961 02:11:14,639 --> 02:11:19,040 recreatingyoutube.com. 2962 02:11:16,880 --> 02:11:20,880 Just like before, I've created a page on 2963 02:11:19,040 --> 02:11:23,760 my website that'll show us what the 2964 02:11:20,880 --> 02:11:25,679 final project looks like. So, first 2965 02:11:23,760 --> 02:11:27,040 we're going to close all of our browser 2966 02:11:25,679 --> 02:11:29,679 tabs cuz we're going to start over 2967 02:11:27,040 --> 02:11:32,960 again. And then we're going to open a 2968 02:11:29,679 --> 02:11:35,960 new page and we're going to go to 2969 02:11:32,960 --> 02:11:35,960 supersimple.dev/ex 2970 02:11:37,280 --> 02:11:40,280 exercises. 2971 02:11:41,599 --> 02:11:45,679 So on this page, you can see what our 2972 02:11:43,360 --> 02:11:47,440 final project will look like. So we're 2973 02:11:45,679 --> 02:11:50,560 going to learn how to recreate 2974 02:11:47,440 --> 02:11:52,719 YouTube.com that you see here. 2975 02:11:50,560 --> 02:11:54,880 So first, let's set up our project in 2976 02:11:52,719 --> 02:11:59,280 our code editor. 2977 02:11:54,880 --> 02:12:01,199 So let's go into here and let's actually 2978 02:11:59,280 --> 02:12:03,599 create a folder that's going to contain 2979 02:12:01,199 --> 02:12:05,360 all of our previous code. So the final 2980 02:12:03,599 --> 02:12:06,960 project is going to contain a lot of 2981 02:12:05,360 --> 02:12:09,920 code, so we don't want to get it 2982 02:12:06,960 --> 02:12:13,880 confused with the previous lessons. So, 2983 02:12:09,920 --> 02:12:13,880 let's call this intro-2-html. 2984 02:12:15,760 --> 02:12:20,800 And we're going to put everything inside 2985 02:12:18,000 --> 02:12:23,760 this folder. 2986 02:12:20,800 --> 02:12:29,280 Going to put this in here 2987 02:12:23,760 --> 02:12:31,520 and these HTML files in here as well. 2988 02:12:29,280 --> 02:12:34,159 Next, we're going to create a new HTML 2989 02:12:31,520 --> 02:12:39,159 file for our final project. So, let's 2990 02:12:34,159 --> 02:12:39,159 create a file called YouTube.html. 2991 02:12:39,599 --> 02:12:43,599 And I actually put it inside this 2992 02:12:41,520 --> 02:12:46,880 folder. I'm going to take it out by 2993 02:12:43,599 --> 02:12:49,920 dragging it down here. 2994 02:12:46,880 --> 02:12:51,920 So now we have an intro to HTML folder 2995 02:12:49,920 --> 02:12:55,880 and our YouTube.html 2996 02:12:51,920 --> 02:12:55,880 and we're ready to get started. 2997 02:12:56,320 --> 02:13:00,239 First, we're going to set up the proper 2998 02:12:57,920 --> 02:13:02,239 structure of HTML that we learned in the 2999 02:13:00,239 --> 02:13:05,440 previous lesson. So, we're going to 3000 02:13:02,239 --> 02:13:09,040 start off with a less than exclamation 3001 02:13:05,440 --> 02:13:11,119 doc type and HTML. 3002 02:13:09,040 --> 02:13:13,360 And then we're going to create an HTML 3003 02:13:11,119 --> 02:13:16,239 element that's going to contain our 3004 02:13:13,360 --> 02:13:19,520 entire web page. And inside here, we're 3005 02:13:16,239 --> 02:13:21,360 going to have a head element. 3006 02:13:19,520 --> 02:13:24,360 And we're also going to have a body 3007 02:13:21,360 --> 02:13:24,360 element. 3008 02:13:25,280 --> 02:13:31,719 And now that we have this structure, we 3009 02:13:26,880 --> 02:13:31,719 can open it with live server. 3010 02:13:32,239 --> 02:13:36,400 And now we have our blank page. So this 3011 02:13:34,320 --> 02:13:39,040 page is going to automatically reload 3012 02:13:36,400 --> 02:13:40,719 when we change our code. 3013 02:13:39,040 --> 02:13:43,599 Now before we can work on the final 3014 02:13:40,719 --> 02:13:46,079 project, we need to learn two more HTML 3015 02:13:43,599 --> 02:13:49,840 elements. How to load images onto our 3016 02:13:46,079 --> 02:13:51,679 website and how to create a search box. 3017 02:13:49,840 --> 02:13:53,280 So let's start with loading images 3018 02:13:51,679 --> 02:13:54,880 first. 3019 02:13:53,280 --> 02:13:56,480 So I'm going to show you how you can 3020 02:13:54,880 --> 02:13:59,040 download these thumbnails from my 3021 02:13:56,480 --> 02:14:02,079 website. We're going to rightclick in a 3022 02:13:59,040 --> 02:14:04,159 blank area and inspect. 3023 02:14:02,079 --> 02:14:08,639 And now if we click this icon in the top 3024 02:14:04,159 --> 02:14:11,440 left and hover over an image and click 3025 02:14:08,639 --> 02:14:13,679 it. And you might need to drag this down 3026 02:14:11,440 --> 02:14:16,320 to see the HTML. 3027 02:14:13,679 --> 02:14:18,960 We can find the image in the HTML. And 3028 02:14:16,320 --> 02:14:21,440 here is the URL for the image. So we can 3029 02:14:18,960 --> 02:14:23,920 actually click this 3030 02:14:21,440 --> 02:14:27,520 and it will open the image in a new tab. 3031 02:14:23,920 --> 02:14:30,000 and we can controll S to save it. So 3032 02:14:27,520 --> 02:14:32,480 make sure we save this image in the 3033 02:14:30,000 --> 02:14:35,360 folder that contains all of our code. So 3034 02:14:32,480 --> 02:14:38,239 that's this folder for me. I'm going to 3035 02:14:35,360 --> 02:14:40,719 save it. And now in my code editor, I 3036 02:14:38,239 --> 02:14:43,280 can see the image. Next, we're going to 3037 02:14:40,719 --> 02:14:45,520 create an HTML element to load this onto 3038 02:14:43,280 --> 02:14:47,840 our page. So I'm going to go back to my 3039 02:14:45,520 --> 02:14:50,320 page here. And then we're going to go 3040 02:14:47,840 --> 02:14:54,800 into the body and create the image 3041 02:14:50,320 --> 02:14:57,599 element which is less than img greater 3042 02:14:54,800 --> 02:15:00,560 than. Now the image element is unique 3043 02:14:57,599 --> 02:15:02,400 because it's another void element. So we 3044 02:15:00,560 --> 02:15:04,400 mentioned void elements briefly in the 3045 02:15:02,400 --> 02:15:06,800 previous lesson. It's an element that 3046 02:15:04,400 --> 02:15:09,760 doesn't require a closing tag. So this 3047 02:15:06,800 --> 02:15:12,480 is one of those exceptions to the rule. 3048 02:15:09,760 --> 02:15:15,280 So the image element takes one attribute 3049 02:15:12,480 --> 02:15:17,360 called src. 3050 02:15:15,280 --> 02:15:20,079 Now this attribute tells a computer 3051 02:15:17,360 --> 02:15:22,000 which image to display on the website. 3052 02:15:20,079 --> 02:15:26,079 So for us that image is the one we 3053 02:15:22,000 --> 02:15:28,000 downloaded called thumbnail 1.p. 3054 02:15:26,079 --> 02:15:31,000 So we're going to display 3055 02:15:28,000 --> 02:15:31,000 thumbnail-webp. 3056 02:15:31,760 --> 02:15:37,040 And when I save it, the image is now 3057 02:15:34,159 --> 02:15:40,159 loaded onto our website. 3058 02:15:37,040 --> 02:15:43,199 So this source attribute works the same 3059 02:15:40,159 --> 02:15:45,199 way as the link attribute that we saw 3060 02:15:43,199 --> 02:15:47,840 earlier. 3061 02:15:45,199 --> 02:15:51,360 It follows the rules of file paths to 3062 02:15:47,840 --> 02:15:54,719 locate our file. So, just as a reminder, 3063 02:15:51,360 --> 02:15:56,639 if we type thumbnail 1.bp here, it's 3064 02:15:54,719 --> 02:16:00,000 going to look for a file named thumbnail 3065 02:15:56,639 --> 02:16:01,520 1.bp right beside our HTML file. It's 3066 02:16:00,000 --> 02:16:03,840 going to find it and then load it onto 3067 02:16:01,520 --> 02:16:06,239 our website. But now, we're actually 3068 02:16:03,840 --> 02:16:07,920 going to create a folder because we have 3069 02:16:06,239 --> 02:16:10,159 multiple thumbnails and we want to 3070 02:16:07,920 --> 02:16:13,040 organize them. We're going to create a 3071 02:16:10,159 --> 02:16:14,560 folder called thumbnails. 3072 02:16:13,040 --> 02:16:17,040 and we're going to drag this into that 3073 02:16:14,560 --> 02:16:19,760 folder. 3074 02:16:17,040 --> 02:16:22,800 So now for this source attribute, we 3075 02:16:19,760 --> 02:16:25,599 don't have a file beside our HTML called 3076 02:16:22,800 --> 02:16:27,440 thumbnail 1.p. And then you see this 3077 02:16:25,599 --> 02:16:30,000 error here. So this means that there is 3078 02:16:27,440 --> 02:16:32,319 an error loading an image. Now to find 3079 02:16:30,000 --> 02:16:35,359 it in the thumbnails file, we're going 3080 02:16:32,319 --> 02:16:38,000 to type thumbnails/ 3081 02:16:35,359 --> 02:16:40,000 thumbnail 1.p. 3082 02:16:38,000 --> 02:16:41,840 So, first it's going to look for a file 3083 02:16:40,000 --> 02:16:44,880 or folder called thumbnails beside the 3084 02:16:41,840 --> 02:16:47,439 HTML file. It finds this one and then 3085 02:16:44,880 --> 02:16:50,960 the slash here means to go inside the 3086 02:16:47,439 --> 02:16:53,679 folder and then find this file inside 3087 02:16:50,960 --> 02:16:55,840 that folder which is here. 3088 02:16:53,679 --> 02:16:57,359 So, that's how we load images onto our 3089 02:16:55,840 --> 02:16:58,960 page. 3090 02:16:57,359 --> 02:17:01,280 Now, we're going to learn how to style 3091 02:16:58,960 --> 02:17:04,719 our image elements. So, let's go into 3092 02:17:01,280 --> 02:17:07,519 our head section here and create a style 3093 02:17:04,719 --> 02:17:09,280 element. 3094 02:17:07,519 --> 02:17:11,760 Now before we do that, I forgot to do 3095 02:17:09,280 --> 02:17:14,719 something which is let's create a title 3096 02:17:11,760 --> 02:17:16,960 for our page. So we can call this 3097 02:17:14,719 --> 02:17:19,679 YouTube.com 3098 02:17:16,960 --> 02:17:22,160 clone. And if we save this, the title 3099 02:17:19,679 --> 02:17:25,519 will show up in the tabs. All right. So 3100 02:17:22,160 --> 02:17:27,599 let's learn how to style our image. 3101 02:17:25,519 --> 02:17:30,719 So as always, we're going to give it a 3102 02:17:27,599 --> 02:17:33,519 class attribute and let's just call this 3103 02:17:30,719 --> 02:17:40,040 thumbnail. And now we can target this 3104 02:17:33,519 --> 02:17:40,040 class in our CSS. So, dot thumbnail. 3105 02:17:40,240 --> 02:17:45,200 Now, all of the CSS properties that we 3106 02:17:42,319 --> 02:17:46,800 learned so far apply to the image. Some 3107 02:17:45,200 --> 02:17:49,679 of them make sense and some of them 3108 02:17:46,800 --> 02:17:52,080 don't. So, one property that obviously 3109 02:17:49,679 --> 02:17:55,519 doesn't make sense is something like 3110 02:17:52,080 --> 02:17:56,960 font dash size. 3111 02:17:55,519 --> 02:17:59,439 So, if I save it, you'll see nothing 3112 02:17:56,960 --> 02:18:02,000 changes because there is no text inside 3113 02:17:59,439 --> 02:18:04,080 this element. It's an image. So, even 3114 02:18:02,000 --> 02:18:05,760 though this works, it doesn't really 3115 02:18:04,080 --> 02:18:07,679 change anything. 3116 02:18:05,760 --> 02:18:10,639 Now, a property that does make sense for 3117 02:18:07,679 --> 02:18:12,800 an image is width. 3118 02:18:10,639 --> 02:18:15,760 So, this will set the width of this 3119 02:18:12,800 --> 02:18:18,399 image. Let's make it smaller to match 3120 02:18:15,760 --> 02:18:22,559 what we have here. So, let's make the 3121 02:18:18,399 --> 02:18:24,479 width something like 300 pixels. 3122 02:18:22,559 --> 02:18:27,200 Now, we save it. And now the width of 3123 02:18:24,479 --> 02:18:29,280 this image is 300 pixels. So, one thing 3124 02:18:27,200 --> 02:18:32,240 you might notice is that when we set the 3125 02:18:29,280 --> 02:18:36,319 width of an image, the height also 3126 02:18:32,240 --> 02:18:38,719 changes. So before we had this, 3127 02:18:36,319 --> 02:18:40,880 notice that the image was a lot taller. 3128 02:18:38,719 --> 02:18:43,679 But as soon as we set the width, the 3129 02:18:40,880 --> 02:18:46,160 height also adjusts. So that's one 3130 02:18:43,679 --> 02:18:48,639 behavior of images that we should know. 3131 02:18:46,160 --> 02:18:50,880 When we set the width, the height will 3132 02:18:48,639 --> 02:18:53,120 also adjust so that the image has the 3133 02:18:50,880 --> 02:18:54,880 same dimensions. What I mean by 3134 02:18:53,120 --> 02:18:58,080 dimensions is that it keeps the same 3135 02:18:54,880 --> 02:19:00,559 shape. So, for example, if I set the 3136 02:18:58,080 --> 02:19:03,200 height as well, this is going to cause 3137 02:19:00,559 --> 02:19:05,359 the image to lose its shape or lose its 3138 02:19:03,200 --> 02:19:08,319 dimensions. Let's set the height to 3139 02:19:05,359 --> 02:19:10,639 something like 600 pixels. 3140 02:19:08,319 --> 02:19:13,519 Save it. And now you'll see that the 3141 02:19:10,639 --> 02:19:16,240 image is 600 pixels tall, but it's lost 3142 02:19:13,519 --> 02:19:19,040 its shape and now it's become stretched. 3143 02:19:16,240 --> 02:19:20,960 So, that behavior of an image sort of 3144 02:19:19,040 --> 02:19:23,679 keeps us safe. So, it keeps the image 3145 02:19:20,960 --> 02:19:28,240 looking nice. Now, if we really wanted 3146 02:19:23,679 --> 02:19:31,439 an image that was exactly 300 pixels by 3147 02:19:28,240 --> 02:19:33,200 300 pixels, what can we do? So, this 3148 02:19:31,439 --> 02:19:36,319 image, as you can see, is getting 3149 02:19:33,200 --> 02:19:38,160 stretched out. So, in addition to all 3150 02:19:36,319 --> 02:19:40,800 the CSS properties that we've learned so 3151 02:19:38,160 --> 02:19:42,639 far, the image element has its own 3152 02:19:40,800 --> 02:19:47,120 properties that are specific to an 3153 02:19:42,639 --> 02:19:49,280 image. So, one of these is called object 3154 02:19:47,120 --> 02:19:52,160 fit. 3155 02:19:49,280 --> 02:19:54,800 So this determines what happens if this 3156 02:19:52,160 --> 02:19:58,319 size doesn't match the images dimensions 3157 02:19:54,800 --> 02:20:01,439 or the images shape. So for example, I 3158 02:19:58,319 --> 02:20:04,240 can set a value of cover. 3159 02:20:01,439 --> 02:20:07,439 So this tells the image to cover this 3160 02:20:04,240 --> 02:20:09,760 300x300 area, but it's also going to 3161 02:20:07,439 --> 02:20:11,920 keep its shape. So this area might not 3162 02:20:09,760 --> 02:20:13,920 be big enough to show the whole image, 3163 02:20:11,920 --> 02:20:17,200 which may or may not be okay depending 3164 02:20:13,920 --> 02:20:19,280 on what we want to do. Now we can adjust 3165 02:20:17,200 --> 02:20:23,120 which part of the image that we see 3166 02:20:19,280 --> 02:20:25,680 using another property called object 3167 02:20:23,120 --> 02:20:27,680 dash position. 3168 02:20:25,680 --> 02:20:30,240 So currently we're looking at the center 3169 02:20:27,680 --> 02:20:33,200 of the image. We can set the object 3170 02:20:30,240 --> 02:20:35,359 position to left to view the left side 3171 02:20:33,200 --> 02:20:38,000 of the image or we can also set it to 3172 02:20:35,359 --> 02:20:40,160 the right to view the right side of the 3173 02:20:38,000 --> 02:20:42,960 image in the case that the image doesn't 3174 02:20:40,160 --> 02:20:45,359 fit in our area. 3175 02:20:42,960 --> 02:20:48,399 Another value we can give to object fit 3176 02:20:45,359 --> 02:20:51,359 is contain. 3177 02:20:48,399 --> 02:20:54,240 So if we save this, the entire image is 3178 02:20:51,359 --> 02:20:57,680 going to shrink until it is contained in 3179 02:20:54,240 --> 02:20:59,600 this 300 by300 area. So I'm going to set 3180 02:20:57,680 --> 02:21:01,680 a border so that we can see what this is 3181 02:20:59,600 --> 02:21:03,359 doing. Going to set a border of 2 3182 02:21:01,680 --> 02:21:06,399 pixels, 3183 02:21:03,359 --> 02:21:09,439 border width of 2 pixels, 3184 02:21:06,399 --> 02:21:12,560 border style of solid, 3185 02:21:09,439 --> 02:21:15,040 border color of red. 3186 02:21:12,560 --> 02:21:18,479 So here the border shows us our 300 3187 02:21:15,040 --> 02:21:20,880 by300 area and contain makes the image 3188 02:21:18,479 --> 02:21:22,880 shrink until it is contained in the 3189 02:21:20,880 --> 02:21:25,200 area. But that means that it might not 3190 02:21:22,880 --> 02:21:27,760 be able to cover the entire area if it's 3191 02:21:25,200 --> 02:21:30,319 not the right shape. So in this case the 3192 02:21:27,760 --> 02:21:32,240 object position can move the image to 3193 02:21:30,319 --> 02:21:35,600 the top 3194 02:21:32,240 --> 02:21:38,160 or to the bottom. 3195 02:21:35,600 --> 02:21:39,920 So that's basically how images work. As 3196 02:21:38,160 --> 02:21:41,840 you can see, a lot of the CSS properties 3197 02:21:39,920 --> 02:21:44,720 that we learned before, like width and 3198 02:21:41,840 --> 02:21:46,800 height and border can be applied to the 3199 02:21:44,720 --> 02:21:49,920 image element. And the image element 3200 02:21:46,800 --> 02:21:53,120 also has some of its own properties that 3201 02:21:49,920 --> 02:21:54,880 determine how the image is displayed. 3202 02:21:53,120 --> 02:21:57,359 So, for now, let's create something 3203 02:21:54,880 --> 02:22:00,720 that's kind of like our final website. 3204 02:21:57,359 --> 02:22:03,120 So, I'm going to set the image width to 3205 02:22:00,720 --> 02:22:05,200 300. And I'm not going to set a height 3206 02:22:03,120 --> 02:22:07,520 so that the image doesn't stretch and we 3207 02:22:05,200 --> 02:22:10,479 don't have to do all this stuff. And I 3208 02:22:07,520 --> 02:22:12,160 can actually just remove all of this. So 3209 02:22:10,479 --> 02:22:15,040 the only thing I'm doing is telling the 3210 02:22:12,160 --> 02:22:17,200 image to shrink down to a width of 300 3211 02:22:15,040 --> 02:22:19,840 and to shrink the height as well so that 3212 02:22:17,200 --> 02:22:21,200 the image keeps its shape. 3213 02:22:19,840 --> 02:22:24,640 So we're going to stick with this for 3214 02:22:21,200 --> 02:22:27,200 now. And this is going to correspond to 3215 02:22:24,640 --> 02:22:28,319 this part of our final project. And 3216 02:22:27,200 --> 02:22:32,080 we're going to start learning how to 3217 02:22:28,319 --> 02:22:33,600 build out the entire video preview. 3218 02:22:32,080 --> 02:22:35,359 The next element we're going to learn in 3219 02:22:33,600 --> 02:22:38,000 this lesson is how to create search 3220 02:22:35,359 --> 02:22:40,160 boxes like the one you see up here. So, 3221 02:22:38,000 --> 02:22:42,000 let's go back into our website and we'll 3222 02:22:40,160 --> 02:22:43,760 learn the code for creating a search 3223 02:22:42,000 --> 02:22:47,359 box. 3224 02:22:43,760 --> 02:22:51,520 The HTML for creating a text box is less 3225 02:22:47,359 --> 02:22:54,080 than input greater than. So, the input 3226 02:22:51,520 --> 02:22:56,240 element is a void element just like the 3227 02:22:54,080 --> 02:22:59,280 image element. It doesn't require a 3228 02:22:56,240 --> 02:23:01,359 closing tag. So, the input element has 3229 02:22:59,280 --> 02:23:04,640 several attributes that we can give it. 3230 02:23:01,359 --> 02:23:07,439 One of them is called the type. So if we 3231 02:23:04,640 --> 02:23:10,640 set the type equals text, it's going to 3232 02:23:07,439 --> 02:23:13,280 give us a text box. I'm going to save 3233 02:23:10,640 --> 02:23:17,359 this. And now in our HTML, you can see 3234 02:23:13,280 --> 02:23:19,120 we have a text box. 3235 02:23:17,359 --> 02:23:22,640 Another type that we can give to this 3236 02:23:19,120 --> 02:23:26,399 input is called checkbox. So if I save 3237 02:23:22,640 --> 02:23:28,479 this, now we have a checkbox. 3238 02:23:26,399 --> 02:23:30,640 So, for our purposes, we're going to set 3239 02:23:28,479 --> 02:23:33,520 the type to a text box because we want 3240 02:23:30,640 --> 02:23:35,760 to create the YouTube search box up 3241 02:23:33,520 --> 02:23:38,080 here. 3242 02:23:35,760 --> 02:23:40,160 So, you also notice that this text box 3243 02:23:38,080 --> 02:23:43,200 has the word search in it. And when I 3244 02:23:40,160 --> 02:23:45,280 start typing, that search word is gone. 3245 02:23:43,200 --> 02:23:47,200 So, this is sort of like a label for the 3246 02:23:45,280 --> 02:23:49,520 user telling them what to put into this 3247 02:23:47,200 --> 02:23:52,240 text box. And this is known as a 3248 02:23:49,520 --> 02:23:53,680 placeholder. So, if we go back to our 3249 02:23:52,240 --> 02:23:56,880 website, we're going to add a 3250 02:23:53,680 --> 02:23:58,560 placeholder to our new text box. To do 3251 02:23:56,880 --> 02:24:02,720 that, we're just going to give the 3252 02:23:58,560 --> 02:24:06,319 attribute placeholder. 3253 02:24:02,720 --> 02:24:08,800 And let's set the placeholder as search. 3254 02:24:06,319 --> 02:24:11,200 We save it. Now, we have a placeholder 3255 02:24:08,800 --> 02:24:13,439 that disappears when we start typing. 3256 02:24:11,200 --> 02:24:16,880 So, that's how we create what we see on 3257 02:24:13,439 --> 02:24:19,120 YouTube. So for the text box, all of the 3258 02:24:16,880 --> 02:24:21,600 CSS properties that we learned so far 3259 02:24:19,120 --> 02:24:23,920 can be used on the text box. So let's 3260 02:24:21,600 --> 02:24:26,640 look at some examples. 3261 02:24:23,920 --> 02:24:29,359 Let's add a class attribute first like 3262 02:24:26,640 --> 02:24:32,160 always so that we can target it. Let's 3263 02:24:29,359 --> 02:24:34,720 call it search-bar. 3264 02:24:32,160 --> 02:24:39,359 And then inside our CSS, we're going to 3265 02:24:34,720 --> 02:24:41,920 target dot search bar class. And then 3266 02:24:39,359 --> 02:24:44,720 inside we can set our usual CSS 3267 02:24:41,920 --> 02:24:48,240 properties. So for example in this case 3268 02:24:44,720 --> 02:24:52,160 we can set a font dash size and let's 3269 02:24:48,240 --> 02:24:54,240 set it to 20 pixels. Save it and reload. 3270 02:24:52,160 --> 02:24:56,080 And now you can see that the font size 3271 02:24:54,240 --> 02:24:58,399 has changed. 3272 02:24:56,080 --> 02:25:02,160 Another thing we can change is margin or 3273 02:24:58,399 --> 02:25:07,359 the spacing. So let's add some margin 3274 02:25:02,160 --> 02:25:10,080 to the left of 12 pixels. Save it. And 3275 02:25:07,359 --> 02:25:11,520 now we have some spacing on the left. So 3276 02:25:10,080 --> 02:25:14,160 basically everything that we've learned 3277 02:25:11,520 --> 02:25:17,680 so far about CSS properties we can use 3278 02:25:14,160 --> 02:25:19,680 on the search box. 3279 02:25:17,680 --> 02:25:21,280 For now, let's remove these example 3280 02:25:19,680 --> 02:25:23,040 styles. And we're going to style the 3281 02:25:21,280 --> 02:25:27,160 search box to look like our final 3282 02:25:23,040 --> 02:25:27,160 project later in this course. 3283 02:25:45,920 --> 02:25:49,439 In this lesson, we're going to learn one 3284 02:25:47,439 --> 02:25:51,520 of the most important CSS properties 3285 02:25:49,439 --> 02:25:53,120 called the display property. And we're 3286 02:25:51,520 --> 02:25:55,520 going to use this to start building out 3287 02:25:53,120 --> 02:25:57,359 our final project. We're going to start 3288 02:25:55,520 --> 02:25:59,200 off by taking a look at our final 3289 02:25:57,359 --> 02:26:01,840 project. And we're going to start 3290 02:25:59,200 --> 02:26:03,439 building out the text here. So, we're 3291 02:26:01,840 --> 02:26:07,840 going to create paragraphs for these 3292 02:26:03,439 --> 02:26:11,359 text. So, let's go into our code and 3293 02:26:07,840 --> 02:26:13,520 we're going to create three paragraphs. 3294 02:26:11,359 --> 02:26:19,160 So, here's one of them. And we can copy 3295 02:26:13,520 --> 02:26:19,160 the text. So, copy and paste. 3296 02:26:22,720 --> 02:26:28,160 So, here's another paragraph, 3297 02:26:25,200 --> 02:26:32,280 and we're going to copy this 3298 02:26:28,160 --> 02:26:32,280 and paste it in our code. 3299 02:26:32,399 --> 02:26:36,280 And here's the final paragraph. 3300 02:26:40,640 --> 02:26:45,680 And we'll save. So here I'm actually 3301 02:26:43,600 --> 02:26:48,080 going to use the HTML entity again 3302 02:26:45,680 --> 02:26:49,439 instead of this special character. So to 3303 02:26:48,080 --> 02:26:52,800 save us some time, I'm just going to 3304 02:26:49,439 --> 02:26:54,560 type it out here. 3305 02:26:52,800 --> 02:26:57,359 Now I'm going to save this and go back 3306 02:26:54,560 --> 02:26:59,760 to my web page. And now we have the text 3307 02:26:57,359 --> 02:27:02,160 that we're going to use. But you might 3308 02:26:59,760 --> 02:27:05,439 notice something weird. How come this 3309 02:27:02,160 --> 02:27:07,680 text box is beside our image? If we look 3310 02:27:05,439 --> 02:27:09,920 at our paragraphs, they are on top of 3311 02:27:07,680 --> 02:27:12,479 each other. So one after another on each 3312 02:27:09,920 --> 02:27:15,520 line. How come text boxes and images 3313 02:27:12,479 --> 02:27:18,399 appear on the same line? So, this is due 3314 02:27:15,520 --> 02:27:20,560 to the display property in CSS and we're 3315 02:27:18,399 --> 02:27:23,040 going to learn what that is right now. 3316 02:27:20,560 --> 02:27:25,359 In HTML, there are three types of 3317 02:27:23,040 --> 02:27:28,479 elements. The first type of element is 3318 02:27:25,359 --> 02:27:31,359 called a block element. A block element 3319 02:27:28,479 --> 02:27:34,800 takes up the entire line. So, a 3320 02:27:31,359 --> 02:27:37,280 paragraph by default is a block element. 3321 02:27:34,800 --> 02:27:39,680 We can see that in our dev tools by 3322 02:27:37,280 --> 02:27:41,680 right-clicking in the browser and then 3323 02:27:39,680 --> 02:27:43,840 clicking inspect 3324 02:27:41,680 --> 02:27:46,960 and then clicking this icon in the top 3325 02:27:43,840 --> 02:27:49,280 left right here and then hovering over 3326 02:27:46,960 --> 02:27:51,840 our paragraph. So you can see that even 3327 02:27:49,280 --> 02:27:54,560 though the text goes to here, the 3328 02:27:51,840 --> 02:27:57,200 paragraph extends to the end of the line 3329 02:27:54,560 --> 02:27:59,600 because the paragraph by default is a 3330 02:27:57,200 --> 02:28:01,600 block element. Block elements take up 3331 02:27:59,600 --> 02:28:03,680 the entire line. 3332 02:28:01,600 --> 02:28:05,680 So let's go into our code and I'm going 3333 02:28:03,680 --> 02:28:08,000 to demonstrate another property of block 3334 02:28:05,680 --> 02:28:10,399 elements. 3335 02:28:08,000 --> 02:28:13,520 If we set a class on the paragraph and 3336 02:28:10,399 --> 02:28:16,240 we style it. So let's set a class of 3337 02:28:13,520 --> 02:28:18,880 video dash title. 3338 02:28:16,240 --> 02:28:24,399 Let's save it. And we're going to style 3339 02:28:18,880 --> 02:28:26,319 it and let's give it a width of 300 3340 02:28:24,399 --> 02:28:29,840 pixels. 3341 02:28:26,319 --> 02:28:32,720 Save and refresh. And now this paragraph 3342 02:28:29,840 --> 02:28:34,080 is only 300 pixels. So it's not 3343 02:28:32,720 --> 02:28:36,720 stretching to the end of the line 3344 02:28:34,080 --> 02:28:38,800 anymore. Let's verify that using the dev 3345 02:28:36,720 --> 02:28:41,040 tools by clicking this top left and then 3346 02:28:38,800 --> 02:28:43,520 hovering over. So you see that the 3347 02:28:41,040 --> 02:28:46,800 paragraph itself only takes a width of 3348 02:28:43,520 --> 02:28:49,920 300 like we set in our CSS, but it still 3349 02:28:46,800 --> 02:28:53,120 takes up the entire line denoted by the 3350 02:28:49,920 --> 02:28:55,760 orange part on the right here. If we 3351 02:28:53,120 --> 02:28:58,240 click on this paragraph and we go to the 3352 02:28:55,760 --> 02:29:00,720 computed tab, notice that there is no 3353 02:28:58,240 --> 02:29:03,600 margin on the right side, but we still 3354 02:29:00,720 --> 02:29:05,920 have a ton of orange area on the right. 3355 02:29:03,600 --> 02:29:07,920 So, this is how block elements work. 3356 02:29:05,920 --> 02:29:09,840 Regardless of how much space they 3357 02:29:07,920 --> 02:29:12,319 actually take up, they take up the 3358 02:29:09,840 --> 02:29:15,120 entire line. So, they're forced to be on 3359 02:29:12,319 --> 02:29:17,359 their own line, like this paragraph and 3360 02:29:15,120 --> 02:29:19,680 these two paragraphs. 3361 02:29:17,359 --> 02:29:22,000 So, that's what a block element means. 3362 02:29:19,680 --> 02:29:24,560 The second type of element is an inline 3363 02:29:22,000 --> 02:29:27,040 block element. An inline block element 3364 02:29:24,560 --> 02:29:30,319 only takes up as much space as it needs 3365 02:29:27,040 --> 02:29:32,960 to and doesn't take up the entire line. 3366 02:29:30,319 --> 02:29:36,640 An example of an inline block element is 3367 02:29:32,960 --> 02:29:38,399 the image element and the input element. 3368 02:29:36,640 --> 02:29:39,920 They only take up as much space as they 3369 02:29:38,399 --> 02:29:42,000 need to and they don't take up the 3370 02:29:39,920 --> 02:29:44,800 entire line. So another element could 3371 02:29:42,000 --> 02:29:47,120 appear beside them like we see here. So 3372 02:29:44,800 --> 02:29:49,600 that's the inline block element. The 3373 02:29:47,120 --> 02:29:51,920 third type of basic HTML element is 3374 02:29:49,600 --> 02:29:53,680 called the inline element. Inline 3375 02:29:51,920 --> 02:29:56,160 elements are basically just text 3376 02:29:53,680 --> 02:29:58,880 elements. They appear within a line of 3377 02:29:56,160 --> 02:30:02,080 text. So if you remember, we briefly 3378 02:29:58,880 --> 02:30:04,560 introduced the element strong. 3379 02:30:02,080 --> 02:30:06,240 So this element appears within a line of 3380 02:30:04,560 --> 02:30:08,319 text 3381 02:30:06,240 --> 02:30:10,640 like this. 3382 02:30:08,319 --> 02:30:13,359 So this element makes a part of the text 3383 02:30:10,640 --> 02:30:15,920 bold and it appears within a line of 3384 02:30:13,359 --> 02:30:19,280 text. So those are the three basic types 3385 02:30:15,920 --> 02:30:21,600 of HTML elements. A block element which 3386 02:30:19,280 --> 02:30:23,600 takes up the entire line, an inline 3387 02:30:21,600 --> 02:30:26,080 block element which only takes up as 3388 02:30:23,600 --> 02:30:28,479 much space as it needs to and an inline 3389 02:30:26,080 --> 02:30:31,359 element which appears within a line of 3390 02:30:28,479 --> 02:30:33,520 text. Now the most interesting of these 3391 02:30:31,359 --> 02:30:35,680 three are the block elements and the 3392 02:30:33,520 --> 02:30:37,200 inline block elements because they 3393 02:30:35,680 --> 02:30:39,120 determine how these elements are 3394 02:30:37,200 --> 02:30:41,920 displayed on the page whether beside 3395 02:30:39,120 --> 02:30:44,160 each other or above and below. 3396 02:30:41,920 --> 02:30:46,800 In addition, we can use a CSS property 3397 02:30:44,160 --> 02:30:49,439 called display to easily switch between 3398 02:30:46,800 --> 02:30:52,479 block and inline block. So let's see how 3399 02:30:49,439 --> 02:30:54,720 that would work. So first let's start by 3400 02:30:52,479 --> 02:30:56,000 switching from block to inline block. 3401 02:30:54,720 --> 02:30:58,640 We're going to switch both of these 3402 02:30:56,000 --> 02:31:00,720 paragraphs to inline block elements. 3403 02:30:58,640 --> 02:31:03,920 Let's go into our code and we're going 3404 02:31:00,720 --> 02:31:09,040 to give this a class. Let's call this 3405 02:31:03,920 --> 02:31:11,120 video- aauthor and let's call this video 3406 02:31:09,040 --> 02:31:13,520 dash stats. 3407 02:31:11,120 --> 02:31:16,000 and we're going to style these classes. 3408 02:31:13,520 --> 02:31:20,800 So, we're going to style the video dash 3409 02:31:16,000 --> 02:31:22,720 author as well as the video 3410 02:31:20,800 --> 02:31:24,399 stats. 3411 02:31:22,720 --> 02:31:25,920 And we're going to set both of these to 3412 02:31:24,399 --> 02:31:28,800 display 3413 02:31:25,920 --> 02:31:31,520 inline dashblock. 3414 02:31:28,800 --> 02:31:33,760 And this one as well, display 3415 02:31:31,520 --> 02:31:35,200 inline dashblock. 3416 02:31:33,760 --> 02:31:38,080 I'm going to introduce a little bit of 3417 02:31:35,200 --> 02:31:40,720 CSS syntax here. If we have two sets of 3418 02:31:38,080 --> 02:31:43,359 CSS styles that are the same, we can 3419 02:31:40,720 --> 02:31:47,200 actually use a different syntax by 3420 02:31:43,359 --> 02:31:49,120 adding a comma here. So this comma means 3421 02:31:47,200 --> 02:31:52,000 that we're going to target both the 3422 02:31:49,120 --> 02:31:54,720 video author class and the video stats 3423 02:31:52,000 --> 02:31:57,200 class with this set of styles. So this 3424 02:31:54,720 --> 02:31:59,439 is how we target multiple things in CSS 3425 02:31:57,200 --> 02:32:01,200 with a comma. 3426 02:31:59,439 --> 02:32:03,359 So as you can see, these two elements 3427 02:32:01,200 --> 02:32:05,680 now appear beside each other. They're 3428 02:32:03,359 --> 02:32:08,399 both inline block elements and only take 3429 02:32:05,680 --> 02:32:10,800 up as much space as they need to. If we 3430 02:32:08,399 --> 02:32:12,960 click the top left in the dev tools and 3431 02:32:10,800 --> 02:32:15,680 hover over this, you'll notice that this 3432 02:32:12,960 --> 02:32:17,760 paragraph is now only taking up as much 3433 02:32:15,680 --> 02:32:20,160 space as the text. And the same thing 3434 02:32:17,760 --> 02:32:21,520 for this paragraph. 3435 02:32:20,160 --> 02:32:23,439 So, as you can see, even though 3436 02:32:21,520 --> 02:32:25,760 paragraphs by default are block 3437 02:32:23,439 --> 02:32:27,920 elements, we can change them very easily 3438 02:32:25,760 --> 02:32:30,000 to inline block with the display 3439 02:32:27,920 --> 02:32:32,399 property so that we can put them beside 3440 02:32:30,000 --> 02:32:34,080 each other. Next, we're going to try the 3441 02:32:32,399 --> 02:32:36,640 opposite direction. We're going to go 3442 02:32:34,080 --> 02:32:39,280 from an inline block element to a block 3443 02:32:36,640 --> 02:32:42,479 element, and we're going to put these 3444 02:32:39,280 --> 02:32:44,399 two on separate lines. So, let's go into 3445 02:32:42,479 --> 02:32:46,960 our code, and we're going to style the 3446 02:32:44,399 --> 02:32:49,760 thumbnail class. So, I'm going to scroll 3447 02:32:46,960 --> 02:32:52,160 up here, and I'm going to convert this 3448 02:32:49,760 --> 02:32:54,800 to display 3449 02:32:52,160 --> 02:32:56,479 block. And now it will turn the image 3450 02:32:54,800 --> 02:32:58,319 into a display block. And this will 3451 02:32:56,479 --> 02:33:01,600 cause the image to take up the entire 3452 02:32:58,319 --> 02:33:05,520 line, pushing the text box down to the 3453 02:33:01,600 --> 02:33:07,280 next line. If I save it now, you can see 3454 02:33:05,520 --> 02:33:08,960 that this image is taking up the entire 3455 02:33:07,280 --> 02:33:10,960 line. We're going to verify this by 3456 02:33:08,960 --> 02:33:13,760 clicking the top left and then hovering 3457 02:33:10,960 --> 02:33:15,920 over this image. So using this property, 3458 02:33:13,760 --> 02:33:18,240 we can control whether an element 3459 02:33:15,920 --> 02:33:20,080 appears on the same line or on a 3460 02:33:18,240 --> 02:33:23,439 different line. And that's what we're 3461 02:33:20,080 --> 02:33:25,520 going to do to copy this design. The 3462 02:33:23,439 --> 02:33:28,399 search bar is at the top. We have an 3463 02:33:25,520 --> 02:33:30,240 image and then three paragraphs each on 3464 02:33:28,399 --> 02:33:32,960 a different line. So we're going to use 3465 02:33:30,240 --> 02:33:36,080 a display property to achieve this. 3466 02:33:32,960 --> 02:33:41,200 Let's go into our code and first let's 3467 02:33:36,080 --> 02:33:44,240 put the search box at the top. 3468 02:33:41,200 --> 02:33:46,240 Going to save it. And since our image is 3469 02:33:44,240 --> 02:33:48,399 already display block, it's going to 3470 02:33:46,240 --> 02:33:51,200 take up the entire line. So it's forced 3471 02:33:48,399 --> 02:33:52,880 to take up a line below the search box. 3472 02:33:51,200 --> 02:33:54,880 So, I think this is pretty good. As long 3473 02:33:52,880 --> 02:33:56,960 as these search box is up there, then 3474 02:33:54,880 --> 02:34:00,160 we're good to go. Next, we're going to 3475 02:33:56,960 --> 02:34:02,319 turn these back into display block 3476 02:34:00,160 --> 02:34:05,520 because we want these on separate lines 3477 02:34:02,319 --> 02:34:08,000 like our design here. So, to do that, 3478 02:34:05,520 --> 02:34:10,479 we're going to go into our code and we 3479 02:34:08,000 --> 02:34:12,800 could change this to display block, but 3480 02:34:10,479 --> 02:34:15,040 remember that paragraphs by default are 3481 02:34:12,800 --> 02:34:17,520 display block. So, we can just get rid 3482 02:34:15,040 --> 02:34:19,840 of this code. 3483 02:34:17,520 --> 02:34:22,319 Save it. And now our elements are 3484 02:34:19,840 --> 02:34:24,880 appearing at least in the same structure 3485 02:34:22,319 --> 02:34:27,280 as the design from top to bottom. And 3486 02:34:24,880 --> 02:34:29,120 each element is taking up its own line. 3487 02:34:27,280 --> 02:34:31,439 So that is the display property. It 3488 02:34:29,120 --> 02:34:33,359 allows us to control how an element is 3489 02:34:31,439 --> 02:34:35,439 displayed, whether they're a block 3490 02:34:33,359 --> 02:34:37,439 element and take up the whole line or 3491 02:34:35,439 --> 02:34:42,280 they're an inline block element and only 3492 02:34:37,439 --> 02:34:42,280 take up as much space as they need to. 3493 02:35:01,520 --> 02:35:05,760 In this lesson, we're going to learn 3494 02:35:02,880 --> 02:35:08,399 about the most important HTML element 3495 02:35:05,760 --> 02:35:11,040 called the div element. 3496 02:35:08,399 --> 02:35:13,439 For example, here's twitter.com. If you 3497 02:35:11,040 --> 02:35:15,439 look at the HTML that Twitter uses, you 3498 02:35:13,439 --> 02:35:18,000 can see that they're using lots and lots 3499 02:35:15,439 --> 02:35:20,240 of divs. Here's another example, 3500 02:35:18,000 --> 02:35:22,640 Instagram. If we look at Instagram's 3501 02:35:20,240 --> 02:35:26,080 HTML, we can also see that they're using 3502 02:35:22,640 --> 02:35:28,319 lots and lots of divs. 3503 02:35:26,080 --> 02:35:31,200 So, what exactly is a div and why is it 3504 02:35:28,319 --> 02:35:33,439 used so much? So, the div element stands 3505 02:35:31,200 --> 02:35:35,600 for division. But an easy way to 3506 02:35:33,439 --> 02:35:38,319 understand this is that the div is just 3507 02:35:35,600 --> 02:35:40,880 a box. We're going to go into our code 3508 02:35:38,319 --> 02:35:43,760 and look at an example. 3509 02:35:40,880 --> 02:35:46,479 So, below our paragraphs, let's create a 3510 02:35:43,760 --> 02:35:47,840 div element. 3511 02:35:46,479 --> 02:35:51,439 And inside we're going to have some 3512 02:35:47,840 --> 02:35:53,920 text. This is a div. 3513 02:35:51,439 --> 02:35:56,720 Save it. And now we have our first div 3514 02:35:53,920 --> 02:35:58,720 element on the page. To show you that 3515 02:35:56,720 --> 02:36:02,560 the div is just a box, we're going to 3516 02:35:58,720 --> 02:36:04,800 rightclick and inspect. 3517 02:36:02,560 --> 02:36:08,399 And then we're going to click this top 3518 02:36:04,800 --> 02:36:10,720 left icon and hover over the div. So, as 3519 02:36:08,399 --> 02:36:13,040 you can see, we created a box around our 3520 02:36:10,720 --> 02:36:15,120 text. You'll notice that this box 3521 02:36:13,040 --> 02:36:18,000 stretches to the end. And that's because 3522 02:36:15,120 --> 02:36:19,840 the div like the paragraph by default is 3523 02:36:18,000 --> 02:36:21,840 a block element. So it takes up the 3524 02:36:19,840 --> 02:36:23,200 entire line. 3525 02:36:21,840 --> 02:36:25,439 But like we learned in the previous 3526 02:36:23,200 --> 02:36:28,160 lesson, we can easily change this to an 3527 02:36:25,439 --> 02:36:30,240 inline block using the display property. 3528 02:36:28,160 --> 02:36:33,359 So let's go ahead and do that and it'll 3529 02:36:30,240 --> 02:36:35,359 be more clear that this is really a box. 3530 02:36:33,359 --> 02:36:40,120 So we're going to set a class here. 3531 02:36:35,359 --> 02:36:40,120 We're going to call this divample. 3532 02:36:40,560 --> 02:36:49,520 And now we're going to style it 3533 02:36:44,080 --> 02:36:51,120 and change the display to inline block 3534 02:36:49,520 --> 02:36:54,560 so that it doesn't take up the entire 3535 02:36:51,120 --> 02:36:56,960 line anymore. Save it. And now if we go 3536 02:36:54,560 --> 02:36:59,760 to our web page, click this icon and 3537 02:36:56,960 --> 02:37:02,000 hover over, you can clearly see that the 3538 02:36:59,760 --> 02:37:04,000 div just creates a box around our 3539 02:37:02,000 --> 02:37:06,479 content. In this case, our content is 3540 02:37:04,000 --> 02:37:09,040 some text. So that's basically what a 3541 02:37:06,479 --> 02:37:12,399 div is. Now the second question is why 3542 02:37:09,040 --> 02:37:14,960 is a div so useful? The key feature of a 3543 02:37:12,399 --> 02:37:17,760 div is that it can contain any other 3544 02:37:14,960 --> 02:37:20,399 elements inside. So right now we only 3545 02:37:17,760 --> 02:37:23,359 have some text inside this div. But we 3546 02:37:20,399 --> 02:37:25,520 can actually put paragraphs, we can put 3547 02:37:23,359 --> 02:37:28,960 images, we can put any elements inside 3548 02:37:25,520 --> 02:37:31,680 divs as well as other divs. Divs are 3549 02:37:28,960 --> 02:37:33,600 meant to be containers. And if we look 3550 02:37:31,680 --> 02:37:35,680 at the YouTube design that we have in 3551 02:37:33,600 --> 02:37:38,720 our project, we use containers 3552 02:37:35,680 --> 02:37:41,359 everywhere. So, here's a container. 3553 02:37:38,720 --> 02:37:43,840 Here's another container. And here's 3554 02:37:41,359 --> 02:37:45,920 another container. These containers 3555 02:37:43,840 --> 02:37:48,080 allow us to group all of these elements 3556 02:37:45,920 --> 02:37:50,479 together so that we can create a layout 3557 02:37:48,080 --> 02:37:52,560 that looks like this. Here's another 3558 02:37:50,479 --> 02:37:55,840 example from Twitter. Here's a 3559 02:37:52,560 --> 02:37:58,560 container. Here's another container. And 3560 02:37:55,840 --> 02:38:00,880 here's another container. 3561 02:37:58,560 --> 02:38:03,280 In order to build complex real world 3562 02:38:00,880 --> 02:38:05,120 website, we need containers to group our 3563 02:38:03,280 --> 02:38:07,760 elements together and lay them out on 3564 02:38:05,120 --> 02:38:10,240 the page. And the div is the perfect 3565 02:38:07,760 --> 02:38:13,439 solution for this container problem. And 3566 02:38:10,240 --> 02:38:15,280 that's why it's used so much. Let's go 3567 02:38:13,439 --> 02:38:18,560 back to our website and we're going to 3568 02:38:15,280 --> 02:38:20,720 practice using our div as a container. 3569 02:38:18,560 --> 02:38:22,720 So we're going to create a container 3570 02:38:20,720 --> 02:38:26,399 just like our final project for this 3571 02:38:22,720 --> 02:38:27,600 entire video preview here. So that means 3572 02:38:26,399 --> 02:38:29,680 we're going to put all of these 3573 02:38:27,600 --> 02:38:32,479 elements, this image, and all three 3574 02:38:29,680 --> 02:38:34,319 paragraphs inside our div. Let's see how 3575 02:38:32,479 --> 02:38:35,760 that works. 3576 02:38:34,319 --> 02:38:38,479 So, I'm going to get rid of this text 3577 02:38:35,760 --> 02:38:44,399 first, and then I'm going to change this 3578 02:38:38,479 --> 02:38:46,000 div to a class of video dash preview 3579 02:38:44,399 --> 02:38:47,760 because this is going to contain all 3580 02:38:46,000 --> 02:38:51,520 these elements that are part of a video 3581 02:38:47,760 --> 02:38:54,399 preview. And then I'm going to move the 3582 02:38:51,520 --> 02:38:57,399 image and the three paragraphs into the 3583 02:38:54,399 --> 02:38:57,399 div. 3584 02:38:59,359 --> 02:39:04,000 Now, save. And you might not notice any 3585 02:39:02,399 --> 02:39:06,960 difference because the div is simply 3586 02:39:04,000 --> 02:39:08,880 just drawing a box around the content 3587 02:39:06,960 --> 02:39:12,720 inside. 3588 02:39:08,880 --> 02:39:16,399 But we can rightclick and inspect. 3589 02:39:12,720 --> 02:39:18,880 And we can see the div in our HTML here. 3590 02:39:16,399 --> 02:39:21,680 And inside the div, we have our image 3591 02:39:18,880 --> 02:39:25,359 and our paragraphs. The div is just 3592 02:39:21,680 --> 02:39:27,439 creating a box around all this content. 3593 02:39:25,359 --> 02:39:29,920 So now I'll show you why containers are 3594 02:39:27,439 --> 02:39:33,120 so useful. We're going to go into our 3595 02:39:29,920 --> 02:39:35,760 code and we're going to change the width 3596 02:39:33,120 --> 02:39:38,880 of our div element here. So, we're going 3597 02:39:35,760 --> 02:39:44,040 to go up here and we can remove this. 3598 02:39:38,880 --> 02:39:44,040 Let's style the video preview class. 3599 02:39:44,399 --> 02:39:53,399 And we're going to set a width of 300 3600 02:39:48,640 --> 02:39:53,399 pixels. Let's see how that looks. 3601 02:39:53,439 --> 02:39:57,680 So, the page doesn't look any different, 3602 02:39:55,520 --> 02:39:59,920 but if we click the icon in the top left 3603 02:39:57,680 --> 02:40:02,319 and then hover over our paragraphs, 3604 02:39:59,920 --> 02:40:04,560 we'll notice something interesting. 3605 02:40:02,319 --> 02:40:06,000 This paragraph is a block element, so 3606 02:40:04,560 --> 02:40:08,479 it's supposed to take up the entire 3607 02:40:06,000 --> 02:40:11,600 line. But in this case, because this 3608 02:40:08,479 --> 02:40:14,880 paragraph is inside a div, it takes up 3609 02:40:11,600 --> 02:40:17,040 the entire line in the div. So the way 3610 02:40:14,880 --> 02:40:19,359 that block elements actually work is 3611 02:40:17,040 --> 02:40:23,359 that they take up the entire line in 3612 02:40:19,359 --> 02:40:25,200 their container rather than on the page. 3613 02:40:23,359 --> 02:40:28,080 So that's really useful because if we 3614 02:40:25,200 --> 02:40:30,080 look at our final project, so for these 3615 02:40:28,080 --> 02:40:32,240 paragraphs, we want them to appear on 3616 02:40:30,080 --> 02:40:34,720 separate lines like this. So we do want 3617 02:40:32,240 --> 02:40:36,399 them to take up their own line, but we 3618 02:40:34,720 --> 02:40:38,800 don't necessarily want them to take up 3619 02:40:36,399 --> 02:40:41,600 the line on the entire page because we 3620 02:40:38,800 --> 02:40:43,760 have some stuff on the right side here. 3621 02:40:41,600 --> 02:40:46,560 So to solve this problem, we put the 3622 02:40:43,760 --> 02:40:48,479 paragraphs inside a container so that 3623 02:40:46,560 --> 02:40:50,960 they take up their own line in the 3624 02:40:48,479 --> 02:40:52,720 container and not in the page. And 3625 02:40:50,960 --> 02:40:54,319 that's how we can create a layout like 3626 02:40:52,720 --> 02:40:56,880 this. 3627 02:40:54,319 --> 02:41:00,240 Let's go back to our website. If we 3628 02:40:56,880 --> 02:41:02,720 hover over our div now, so this blue box 3629 02:41:00,240 --> 02:41:04,880 on the left is our container. It groups 3630 02:41:02,720 --> 02:41:08,240 all the elements together and keeps it 3631 02:41:04,880 --> 02:41:09,840 within that blue area that you see. Now, 3632 02:41:08,240 --> 02:41:11,600 a really cool thing about this is that 3633 02:41:09,840 --> 02:41:14,000 notice that the blue box doesn't 3634 02:41:11,600 --> 02:41:17,280 actually take up the entire page. So, we 3635 02:41:14,000 --> 02:41:19,600 can actually have a second box beside it 3636 02:41:17,280 --> 02:41:22,160 on the right. So, we can add another 3637 02:41:19,600 --> 02:41:24,560 blue box on the right containing another 3638 02:41:22,160 --> 02:41:26,479 video preview. 3639 02:41:24,560 --> 02:41:28,720 So, now we're going to do that. But 3640 02:41:26,479 --> 02:41:30,880 first of all, a div by default is a 3641 02:41:28,720 --> 02:41:32,560 block element. So, notice on the right 3642 02:41:30,880 --> 02:41:35,600 side it's all orange. That's because 3643 02:41:32,560 --> 02:41:36,960 this div is taking up the entire line. 3644 02:41:35,600 --> 02:41:39,200 In this case, we don't want it to take 3645 02:41:36,960 --> 02:41:41,680 up the entire line anymore. That's why 3646 02:41:39,200 --> 02:41:44,319 we're going to convert it into an inline 3647 02:41:41,680 --> 02:41:46,960 block element. So, let's go into our 3648 02:41:44,319 --> 02:41:50,960 code. We're going to go into the video 3649 02:41:46,960 --> 02:41:54,160 preview and we're going to type display 3650 02:41:50,960 --> 02:41:56,640 inline block. 3651 02:41:54,160 --> 02:41:58,880 Let's save it. And now you can see that 3652 02:41:56,640 --> 02:42:00,560 our div is a display inline block. And 3653 02:41:58,880 --> 02:42:02,640 it's actually appearing beside our 3654 02:42:00,560 --> 02:42:04,960 search bar because this is also an 3655 02:42:02,640 --> 02:42:07,840 inline block. So, they're both only 3656 02:42:04,960 --> 02:42:09,520 taking up as much space as they need to. 3657 02:42:07,840 --> 02:42:11,920 And now they can appear beside each 3658 02:42:09,520 --> 02:42:15,200 other. However, we do want the search 3659 02:42:11,920 --> 02:42:16,560 box to be at the top in its own line. 3660 02:42:15,200 --> 02:42:19,120 So, we're going to practice using the 3661 02:42:16,560 --> 02:42:22,880 display property again. We're going to 3662 02:42:19,120 --> 02:42:24,479 set the search bar to display 3663 02:42:22,880 --> 02:42:26,720 block 3664 02:42:24,479 --> 02:42:29,359 so that it takes up the entire line and 3665 02:42:26,720 --> 02:42:32,720 everything else is forced below it. 3666 02:42:29,359 --> 02:42:34,880 Let's save it and refresh. And now if we 3667 02:42:32,720 --> 02:42:36,399 hover over this input element, we can 3668 02:42:34,880 --> 02:42:38,640 see that we forced it to take up the 3669 02:42:36,399 --> 02:42:40,000 entire line. 3670 02:42:38,640 --> 02:42:42,319 Next, we're going to create another 3671 02:42:40,000 --> 02:42:44,160 video preview beside this one because 3672 02:42:42,319 --> 02:42:47,520 this is inline block. Now, we can put 3673 02:42:44,160 --> 02:42:50,560 another div here. So, I'm just going to 3674 02:42:47,520 --> 02:42:52,640 simplify this by making a copy of our 3675 02:42:50,560 --> 02:42:56,560 current code. 3676 02:42:52,640 --> 02:42:59,600 So, I'm just going to copy and paste. 3677 02:42:56,560 --> 02:43:02,720 And now we have two video previews. 3678 02:42:59,600 --> 02:43:05,280 Save it. And there we go. We now have 3679 02:43:02,720 --> 02:43:08,399 two video previews beside each other. So 3680 02:43:05,280 --> 02:43:12,000 they are two containers right beside 3681 02:43:08,399 --> 02:43:15,200 each other. And remember in our CSS we 3682 02:43:12,000 --> 02:43:17,280 set the width of these containers to 300 3683 02:43:15,200 --> 02:43:19,600 pixels. So that's the amount of space 3684 02:43:17,280 --> 02:43:22,000 that they take. And we set their display 3685 02:43:19,600 --> 02:43:23,920 to inline block so they don't take up 3686 02:43:22,000 --> 02:43:26,160 the entire line and they can appear 3687 02:43:23,920 --> 02:43:28,240 beside each other. And now we're on our 3688 02:43:26,160 --> 02:43:30,960 way to creating a layout that looks like 3689 02:43:28,240 --> 02:43:34,240 this. In fact, let's actually replace 3690 02:43:30,960 --> 02:43:36,399 the second video preview here with this 3691 02:43:34,240 --> 02:43:38,160 content. So to do that, we're going to 3692 02:43:36,399 --> 02:43:41,280 download the thumbnail and then change 3693 02:43:38,160 --> 02:43:42,800 the text. So let's rightclick and 3694 02:43:41,280 --> 02:43:44,560 inspect. 3695 02:43:42,800 --> 02:43:46,960 Going to click this top left and then 3696 02:43:44,560 --> 02:43:49,920 click this image. And now I can download 3697 02:43:46,960 --> 02:43:53,279 the thumbnail by going to this URL and 3698 02:43:49,920 --> 02:43:56,080 then clicking down here. 3699 02:43:53,279 --> 02:43:59,040 I'm going to Ctrl S to save the 3700 02:43:56,080 --> 02:44:01,680 thumbnail. So, I'm going to save it in 3701 02:43:59,040 --> 02:44:03,680 the folder that contains my code in the 3702 02:44:01,680 --> 02:44:06,560 thumbnails folder along with our 3703 02:44:03,680 --> 02:44:09,279 previous thumbnail. So, save it here. 3704 02:44:06,560 --> 02:44:11,520 And I should see it in my code editor 3705 02:44:09,279 --> 02:44:13,600 right there. 3706 02:44:11,520 --> 02:44:15,120 Next, we're going to swap out the 3707 02:44:13,600 --> 02:44:17,200 thumbnails. So, instead of thumbnail 3708 02:44:15,120 --> 02:44:19,600 one, we're going to set thumbnail two. 3709 02:44:17,200 --> 02:44:23,439 And we're going to change the text. So, 3710 02:44:19,600 --> 02:44:25,840 I'm going to change this text here 3711 02:44:23,439 --> 02:44:27,359 to be my title. 3712 02:44:25,840 --> 02:44:30,160 And I notice we're still using the 3713 02:44:27,359 --> 02:44:34,439 strong element which we can now delete 3714 02:44:30,160 --> 02:44:34,439 because it was just for an example. 3715 02:44:36,560 --> 02:44:42,800 And I'm also going to change the channel 3716 02:44:39,600 --> 02:44:45,680 name here 3717 02:44:42,800 --> 02:44:49,120 and the video stats which is 19 million 3718 02:44:45,680 --> 02:44:51,279 and four years 3719 02:44:49,120 --> 02:44:54,960 and four 3720 02:44:51,279 --> 02:44:57,359 years ago. So now if I save this, we 3721 02:44:54,960 --> 02:44:59,520 have two different video previews. But 3722 02:44:57,359 --> 02:45:01,680 now we have a problem. You'll notice 3723 02:44:59,520 --> 02:45:04,399 that these two aren't aligned with each 3724 02:45:01,680 --> 02:45:06,160 other. And that's because this container 3725 02:45:04,399 --> 02:45:09,279 is actually a little bit taller than 3726 02:45:06,160 --> 02:45:12,000 this one. This piece of text here wraps 3727 02:45:09,279 --> 02:45:14,640 around to a second line while this one 3728 02:45:12,000 --> 02:45:16,560 does not. However, to make it look 3729 02:45:14,640 --> 02:45:19,120 better, we want to align these at the 3730 02:45:16,560 --> 02:45:20,560 top. So we learned this way back in one 3731 02:45:19,120 --> 02:45:22,319 of the earlier lessons, and we're going 3732 02:45:20,560 --> 02:45:24,800 to review how to do that. 3733 02:45:22,319 --> 02:45:26,960 We're going to go into our code 3734 02:45:24,800 --> 02:45:28,720 and we just have to set this property 3735 02:45:26,960 --> 02:45:30,240 vertical 3736 02:45:28,720 --> 02:45:32,640 align 3737 02:45:30,240 --> 02:45:34,880 and we're going to set it to top so that 3738 02:45:32,640 --> 02:45:37,600 these elements align at the top. I'm 3739 02:45:34,880 --> 02:45:39,920 going to save it. And now that looks 3740 02:45:37,600 --> 02:45:42,560 pretty good. 3741 02:45:39,920 --> 02:45:44,720 We now have two different video previews 3742 02:45:42,560 --> 02:45:46,479 and they are aligned with each other. 3743 02:45:44,720 --> 02:45:48,960 The last thing we'll do is to add some 3744 02:45:46,479 --> 02:45:51,279 space between them. So remember the 3745 02:45:48,960 --> 02:45:54,000 space outside of an element is called 3746 02:45:51,279 --> 02:45:56,319 margin and we're going to add margin to 3747 02:45:54,000 --> 02:45:58,479 this entire container right now. So 3748 02:45:56,319 --> 02:46:02,240 we'll go into our code and in the video 3749 02:45:58,479 --> 02:46:04,640 preview styles we're going to add margin 3750 02:46:02,240 --> 02:46:06,800 dash 3751 02:46:04,640 --> 02:46:08,399 and let's set it to something like 15 3752 02:46:06,800 --> 02:46:11,120 pixels. 3753 02:46:08,399 --> 02:46:13,279 Save it. And now we added margin on the 3754 02:46:11,120 --> 02:46:16,080 right. And now the interesting thing 3755 02:46:13,279 --> 02:46:18,240 about this is if we rightclick and 3756 02:46:16,080 --> 02:46:21,200 inspect 3757 02:46:18,240 --> 02:46:23,359 and then in our HTML we find our div 3758 02:46:21,200 --> 02:46:26,960 which is here. You'll see that the 3759 02:46:23,359 --> 02:46:28,960 margin is applied on the entire div. 3760 02:46:26,960 --> 02:46:30,800 So that's how the div element works. 3761 02:46:28,960 --> 02:46:32,960 It's a container that groups other 3762 02:46:30,800 --> 02:46:35,760 elements together so that we can create 3763 02:46:32,960 --> 02:46:39,640 complex layouts like this and eventually 3764 02:46:35,760 --> 02:46:39,640 our YouTube project. 3765 02:46:58,640 --> 02:47:02,640 All right. So, this is probably the most 3766 02:47:00,399 --> 02:47:04,000 important lesson of this course. We're 3767 02:47:02,640 --> 02:47:06,319 going to learn a technique called the 3768 02:47:04,000 --> 02:47:07,840 nested layouts technique. And this is 3769 02:47:06,319 --> 02:47:11,200 going to get us to a professional level 3770 02:47:07,840 --> 02:47:14,000 with HTML and CSS. So, what is the 3771 02:47:11,200 --> 02:47:16,640 nested layouts technique? The basic idea 3772 02:47:14,000 --> 02:47:19,040 is that there are two types of layouts. 3773 02:47:16,640 --> 02:47:21,040 The first one is a vertical layout which 3774 02:47:19,040 --> 02:47:23,200 looks like this where items are on top 3775 02:47:21,040 --> 02:47:25,760 of each other. And then the second one 3776 02:47:23,200 --> 02:47:29,120 is a horizontal layout which looks like 3777 02:47:25,760 --> 02:47:31,600 this where items are beside each other. 3778 02:47:29,120 --> 02:47:33,920 And by using a combination of vertical 3779 02:47:31,600 --> 02:47:35,600 and horizontal layouts, we can create 3780 02:47:33,920 --> 02:47:38,640 almost anything that we see on a 3781 02:47:35,600 --> 02:47:40,319 website. So for example, let's take the 3782 02:47:38,640 --> 02:47:42,000 YouTube video preview that we've been 3783 02:47:40,319 --> 02:47:44,080 working on. 3784 02:47:42,000 --> 02:47:46,720 We can break this down by using a 3785 02:47:44,080 --> 02:47:48,399 vertical layout. And then inside this 3786 02:47:46,720 --> 02:47:51,200 vertical layout, we're going to have a 3787 02:47:48,399 --> 02:47:53,439 horizontal layout. And then inside this 3788 02:47:51,200 --> 02:47:55,760 horizontal layout, we're going to have a 3789 02:47:53,439 --> 02:47:57,920 vertical layout. 3790 02:47:55,760 --> 02:48:00,640 So, as you can see, we have layouts 3791 02:47:57,920 --> 02:48:02,479 inside layouts inside layouts. And 3792 02:48:00,640 --> 02:48:05,200 that's why it's called the nested 3793 02:48:02,479 --> 02:48:06,720 layouts technique. And using this, we 3794 02:48:05,200 --> 02:48:08,640 can pretty much break down almost 3795 02:48:06,720 --> 02:48:11,279 everything that we see on a professional 3796 02:48:08,640 --> 02:48:14,399 website into a series of layouts and 3797 02:48:11,279 --> 02:48:15,520 then recreate them using our code. 3798 02:48:14,399 --> 02:48:17,359 So now we're going to go through 3799 02:48:15,520 --> 02:48:19,359 together a way that we can practice 3800 02:48:17,359 --> 02:48:21,840 using the nested layouts technique to 3801 02:48:19,359 --> 02:48:24,479 break down a design. We're going to go 3802 02:48:21,840 --> 02:48:26,960 to our final project. If you close it, 3803 02:48:24,479 --> 02:48:29,200 you can go to superimple.dev/ex 3804 02:48:26,960 --> 02:48:30,960 exercises/youtube. 3805 02:48:29,200 --> 02:48:32,240 And what we're going to do is we're 3806 02:48:30,960 --> 02:48:34,080 going to take a screenshot of one of 3807 02:48:32,240 --> 02:48:36,640 these designs and then we're going to 3808 02:48:34,080 --> 02:48:39,760 use an image editing software to draw 3809 02:48:36,640 --> 02:48:42,080 out the layout. So first let's create a 3810 02:48:39,760 --> 02:48:44,720 screenshot. On Windows you can use an 3811 02:48:42,080 --> 02:48:47,680 app called Snip. On Mac we're going to 3812 02:48:44,720 --> 02:48:49,200 type commandshift and 4 to create a 3813 02:48:47,680 --> 02:48:53,200 screenshot. 3814 02:48:49,200 --> 02:48:55,520 So let's take a screenshot of this 3815 02:48:53,200 --> 02:48:58,319 and then we're going to upload this into 3816 02:48:55,520 --> 02:48:59,680 an image editing software. Now, feel 3817 02:48:58,319 --> 02:49:01,439 free to use anything that you're 3818 02:48:59,680 --> 02:49:05,200 comfortable with, but if you don't know 3819 02:49:01,439 --> 02:49:07,840 what to use, we can go to a new tab, and 3820 02:49:05,200 --> 02:49:10,840 we're going to search for Google 3821 02:49:07,840 --> 02:49:10,840 Drawings, 3822 02:49:10,880 --> 02:49:16,080 and we're going to use this to practice 3823 02:49:13,200 --> 02:49:17,760 the nested layouts technique. 3824 02:49:16,080 --> 02:49:20,000 So, once we have this open, we're going 3825 02:49:17,760 --> 02:49:22,399 to upload our image. So, I'm going to go 3826 02:49:20,000 --> 02:49:25,359 to my computer and upload the 3827 02:49:22,399 --> 02:49:27,040 screenshot. 3828 02:49:25,359 --> 02:49:30,720 And now we're just going to draw some 3829 02:49:27,040 --> 02:49:33,840 rectangles to represent our layout. So 3830 02:49:30,720 --> 02:49:36,080 we're going to go up here to shapes and 3831 02:49:33,840 --> 02:49:37,359 we're going to create a rectangle. 3832 02:49:36,080 --> 02:49:41,040 And first we're going to create a 3833 02:49:37,359 --> 02:49:45,520 vertical layout. One and two. So I'm 3834 02:49:41,040 --> 02:49:47,200 just going to draw a rectangle here. 3835 02:49:45,520 --> 02:49:48,880 Let's change the background to 3836 02:49:47,200 --> 02:49:50,479 transparent so we can see what's 3837 02:49:48,880 --> 02:49:52,479 underneath. 3838 02:49:50,479 --> 02:49:56,080 And I'll make the border a little more 3839 02:49:52,479 --> 02:49:59,439 thick and change it to red 3840 02:49:56,080 --> 02:50:03,120 so it's easier to see. 3841 02:49:59,439 --> 02:50:06,240 And now I'm going to copy this and paste 3842 02:50:03,120 --> 02:50:10,479 it to create a duplicate. 3843 02:50:06,240 --> 02:50:14,720 And I'm just going to move it down here 3844 02:50:10,479 --> 02:50:16,399 and resize the rectangle like this. 3845 02:50:14,720 --> 02:50:19,680 All right. So just like that, we created 3846 02:50:16,399 --> 02:50:21,600 a vertical layout. For now, don't worry 3847 02:50:19,680 --> 02:50:23,439 about the video time here. We're going 3848 02:50:21,600 --> 02:50:27,200 to recreate this later in the course 3849 02:50:23,439 --> 02:50:29,680 using another feature of CSS. 3850 02:50:27,200 --> 02:50:33,279 And now looking at our design, we have a 3851 02:50:29,680 --> 02:50:34,880 horizontal layout one and two. So to 3852 02:50:33,279 --> 02:50:37,920 create a horizontal layout, we're going 3853 02:50:34,880 --> 02:50:40,560 to draw it out again using rectangles. 3854 02:50:37,920 --> 02:50:43,359 So let's go in here and we're going to 3855 02:50:40,560 --> 02:50:45,680 create another rectangle 3856 02:50:43,359 --> 02:50:47,520 and we're going to 3857 02:50:45,680 --> 02:50:50,080 draw out the horizontal layout like 3858 02:50:47,520 --> 02:50:53,200 this. So, here's one. 3859 02:50:50,080 --> 02:50:55,359 Change the background to transparent. 3860 02:50:53,200 --> 02:50:58,240 Make it bold. 3861 02:50:55,359 --> 02:51:01,279 And I'm going to use the blue color to 3862 02:50:58,240 --> 02:51:03,520 represent a horizontal layout. Now, I'm 3863 02:51:01,279 --> 02:51:06,640 going to copy this 3864 02:51:03,520 --> 02:51:10,840 and paste it here 3865 02:51:06,640 --> 02:51:10,840 and resize it a little bit 3866 02:51:12,000 --> 02:51:17,760 like that. And now we have our 3867 02:51:14,560 --> 02:51:19,840 horizontal layout. And finally, inside 3868 02:51:17,760 --> 02:51:22,560 here, we're going to have a vertical 3869 02:51:19,840 --> 02:51:24,880 layout like this. So again, we're just 3870 02:51:22,560 --> 02:51:29,680 going to keep drawing rectangles. 3871 02:51:24,880 --> 02:51:31,920 Going to copy this and paste it and move 3872 02:51:29,680 --> 02:51:34,720 it down here and resize it a little bit 3873 02:51:31,920 --> 02:51:39,680 so that we can see it. 3874 02:51:34,720 --> 02:51:42,160 So right here. And then copy this. 3875 02:51:39,680 --> 02:51:43,600 And then paste it again. 3876 02:51:42,160 --> 02:51:47,200 We're going to create the second part of 3877 02:51:43,600 --> 02:51:51,439 our vertical layout. 3878 02:51:47,200 --> 02:51:53,439 like that and then copy and paste it one 3879 02:51:51,439 --> 02:51:56,760 last time 3880 02:51:53,439 --> 02:51:56,760 down here. 3881 02:51:59,520 --> 02:52:04,160 So that's how we use the nested layouts 3882 02:52:01,359 --> 02:52:06,880 technique to visualize and break down a 3883 02:52:04,160 --> 02:52:10,640 design into a combination of vertical 3884 02:52:06,880 --> 02:52:12,080 layouts and horizontal layouts. Now 3885 02:52:10,640 --> 02:52:14,080 let's do some more practice. We're going 3886 02:52:12,080 --> 02:52:16,560 to take another design and break that 3887 02:52:14,080 --> 02:52:19,120 down using this technique. So, we're 3888 02:52:16,560 --> 02:52:21,200 going to open a new tab 3889 02:52:19,120 --> 02:52:24,200 and we're going to go to 3890 02:52:21,200 --> 02:52:24,200 twitter.com/sups 3891 02:52:25,760 --> 02:52:28,760 simpledev. 3892 02:52:29,840 --> 02:52:34,720 And we're going to take just take one of 3893 02:52:31,920 --> 02:52:37,359 my tweets here and take a screenshot of 3894 02:52:34,720 --> 02:52:38,800 this. 3895 02:52:37,359 --> 02:52:41,520 And we're going to break down this 3896 02:52:38,800 --> 02:52:45,040 design using the same technique. 3897 02:52:41,520 --> 02:52:48,160 So, let's go back to Google Drawings 3898 02:52:45,040 --> 02:52:51,600 and we're going to create a new drawing 3899 02:52:48,160 --> 02:52:53,680 to practice with. 3900 02:52:51,600 --> 02:52:55,760 And let's upload that screenshot that we 3901 02:52:53,680 --> 02:53:00,640 just took 3902 02:52:55,760 --> 02:53:01,840 onto this new drawing right here. 3903 02:53:00,640 --> 02:53:03,760 So, now we're going to do the same 3904 02:53:01,840 --> 02:53:07,120 thing. We're going to draw rectangles to 3905 02:53:03,760 --> 02:53:08,479 represent the nested layouts. So, let's 3906 02:53:07,120 --> 02:53:10,880 take a look at this to see how we can 3907 02:53:08,479 --> 02:53:16,000 break this down. Immediately I see that 3908 02:53:10,880 --> 02:53:19,279 we have a horizontal layout one and two. 3909 02:53:16,000 --> 02:53:22,800 So we can break it down into that. First 3910 02:53:19,279 --> 02:53:25,120 let's draw a rectangle 3911 02:53:22,800 --> 02:53:28,120 to represent that. So here's the first 3912 02:53:25,120 --> 02:53:28,120 one. 3913 02:53:28,960 --> 02:53:33,760 And I'm just going to make it blue to 3914 02:53:30,640 --> 02:53:35,680 represent a horizontal layout. 3915 02:53:33,760 --> 02:53:40,560 And copy 3916 02:53:35,680 --> 02:53:45,720 and paste it like this. 3917 02:53:40,560 --> 02:53:45,720 Okay, so that's our horizontal layout. 3918 02:53:45,760 --> 02:53:49,600 And now looking at the design inside 3919 02:53:47,600 --> 02:53:52,720 here, I can see that we can break it 3920 02:53:49,600 --> 02:53:57,120 down further into a vertical layout. So 3921 02:53:52,720 --> 02:54:02,279 I'm going to draw some more rectangles. 3922 02:53:57,120 --> 02:54:02,279 And I'm just going to draw it right here 3923 02:54:02,880 --> 02:54:08,319 and style it a little bit and make it 3924 02:54:05,120 --> 02:54:12,160 red to represent the vertical layout. 3925 02:54:08,319 --> 02:54:16,439 So, copy and paste. 3926 02:54:12,160 --> 02:54:16,439 I'm just going to move it down here. 3927 02:54:17,040 --> 02:54:24,479 Okay. 3928 02:54:19,359 --> 02:54:28,120 Okay. So, that's two. Copy and paste 3929 02:54:24,479 --> 02:54:28,120 to get three. 3930 02:54:32,560 --> 02:54:35,920 So, it doesn't have to be perfect. It's 3931 02:54:34,080 --> 02:54:38,080 just here to help us visualize the 3932 02:54:35,920 --> 02:54:40,160 design. All right. Right. So, we have a 3933 02:54:38,080 --> 02:54:42,399 horizontal layout and then inside we 3934 02:54:40,160 --> 02:54:44,800 have a vertical layout. And now looking 3935 02:54:42,399 --> 02:54:47,680 at this, we can also break this down 3936 02:54:44,800 --> 02:54:49,600 into a horizontal layout. So, let's draw 3937 02:54:47,680 --> 02:54:53,760 some more rectangles. Actually, I'm 3938 02:54:49,600 --> 02:54:57,120 going to just copy this one and paste it 3939 02:54:53,760 --> 02:55:01,240 and resize it here. 3940 02:54:57,120 --> 02:55:01,240 So, I'm going to break this down further 3941 02:55:01,920 --> 02:55:07,080 into a horizontal layout inside here. 3942 02:55:09,120 --> 02:55:14,399 And finally, we can break this part down 3943 02:55:11,439 --> 02:55:20,840 further into a horizontal layout. So, 3944 02:55:14,399 --> 02:55:20,840 let's copy this again and paste it here. 3945 02:55:24,319 --> 02:55:28,200 And I'm just going to 3946 02:55:28,960 --> 02:55:34,560 I'm just going to create a few of them 3947 02:55:31,840 --> 02:55:36,399 like this. 3948 02:55:34,560 --> 02:55:39,279 So just like that, we broke down this 3949 02:55:36,399 --> 02:55:41,760 design into a combination of vertical 3950 02:55:39,279 --> 02:55:44,160 and horizontal layouts using the nested 3951 02:55:41,760 --> 02:55:46,160 layouts technique. So now that we have a 3952 02:55:44,160 --> 02:55:47,920 good understanding of how this works, 3953 02:55:46,160 --> 02:55:50,800 we're going to learn how to recreate 3954 02:55:47,920 --> 02:55:53,600 this using code. 3955 02:55:50,800 --> 02:55:55,359 So let's go back into our project. I'm 3956 02:55:53,600 --> 02:55:56,880 going to delete all these extra tabs 3957 02:55:55,359 --> 02:55:58,240 here. 3958 02:55:56,880 --> 02:56:00,240 So we're going to go from something that 3959 02:55:58,240 --> 02:56:02,880 looks like this to something that looks 3960 02:56:00,240 --> 02:56:04,399 like our final design here. Now, before 3961 02:56:02,880 --> 02:56:06,479 we start, we actually need to download 3962 02:56:04,399 --> 02:56:09,359 this channel profile picture. So, 3963 02:56:06,479 --> 02:56:11,920 remember to do that, we can rightclick 3964 02:56:09,359 --> 02:56:14,160 and inspect. 3965 02:56:11,920 --> 02:56:16,720 Click the top left icon here, and then 3966 02:56:14,160 --> 02:56:18,479 click this picture. And we have the URL 3967 02:56:16,720 --> 02:56:21,200 to download it here. So, I'm going to 3968 02:56:18,479 --> 02:56:25,439 hover over it, scroll down, and click 3969 02:56:21,200 --> 02:56:27,040 this link. Now, Ctrl S to save. And I'm 3970 02:56:25,439 --> 02:56:32,319 going to save it in the folder that 3971 02:56:27,040 --> 02:56:34,080 contains our code, which is right here. 3972 02:56:32,319 --> 02:56:35,920 And now this should show up in our code 3973 02:56:34,080 --> 02:56:38,000 editor. 3974 02:56:35,920 --> 02:56:39,760 So I'm actually going to create a folder 3975 02:56:38,000 --> 02:56:41,680 to store all of these channel profile 3976 02:56:39,760 --> 02:56:43,359 pictures since we're going to have a lot 3977 02:56:41,680 --> 02:56:47,760 of them. So I'm going to call this 3978 02:56:43,359 --> 02:56:52,040 channel dash pictures. 3979 02:56:47,760 --> 02:56:52,040 And I'll put this in there. 3980 02:56:52,800 --> 02:56:59,040 Now we're ready to create our layouts. 3981 02:56:55,359 --> 02:57:02,160 So, let's go back to our final design 3982 02:56:59,040 --> 02:57:04,000 and see what kind of layouts we have. 3983 02:57:02,160 --> 02:57:07,920 So, we're going to have a vertical 3984 02:57:04,000 --> 02:57:09,359 layout. It's one and two. So, two rows. 3985 02:57:07,920 --> 02:57:11,279 And then inside the second row, we're 3986 02:57:09,359 --> 02:57:16,000 going to have a horizontal layout, which 3987 02:57:11,279 --> 02:57:17,760 is one and two. Now, inside the second 3988 02:57:16,000 --> 02:57:23,200 horizontal layout, we're going to have a 3989 02:57:17,760 --> 02:57:24,720 vertical layout. 1 2 and three. 3990 02:57:23,200 --> 02:57:27,520 So that's how we're going to break down 3991 02:57:24,720 --> 02:57:29,359 this design. And again, don't worry 3992 02:57:27,520 --> 02:57:32,560 about the video time here. We're going 3993 02:57:29,359 --> 02:57:34,000 to recreate this later in the course. 3994 02:57:32,560 --> 02:57:36,720 Let's go into our code and we're going 3995 02:57:34,000 --> 02:57:39,200 to implement that. So make sure that we 3996 02:57:36,720 --> 02:57:41,040 have our project open on the left here 3997 02:57:39,200 --> 02:57:43,840 and we're going to start by creating 3998 02:57:41,040 --> 02:57:45,279 some vertical layouts. To create a 3999 02:57:43,840 --> 02:57:48,600 vertical layout, we're going to create 4000 02:57:45,279 --> 02:57:48,600 two divs. 4001 02:57:49,840 --> 02:57:54,880 So this is going to be our vertical 4002 02:57:51,840 --> 02:57:56,960 layout. Now remember that divs are block 4003 02:57:54,880 --> 02:57:59,040 elements by default. So they're going to 4004 02:57:56,960 --> 02:58:01,040 take up the entire line and appear one 4005 02:57:59,040 --> 02:58:03,840 on top of another. And that's exactly 4006 02:58:01,040 --> 02:58:05,600 what we want for a vertical layout. So 4007 02:58:03,840 --> 02:58:07,760 let's look at our design here. We have 4008 02:58:05,600 --> 02:58:10,560 the image in the first row. So I'm going 4009 02:58:07,760 --> 02:58:13,120 to move this up. 4010 02:58:10,560 --> 02:58:15,120 Cut and paste. 4011 02:58:13,120 --> 02:58:17,920 And then in the second row we have 4012 02:58:15,120 --> 02:58:20,479 everything else. So, I'm going to put 4013 02:58:17,920 --> 02:58:24,319 everything here in the second row. So, 4014 02:58:20,479 --> 02:58:26,960 cut and paste. 4015 02:58:24,319 --> 02:58:28,560 Let's save it and refresh. 4016 02:58:26,960 --> 02:58:31,279 Now, we're going to create a horizontal 4017 02:58:28,560 --> 02:58:33,200 layout down here. One column is going to 4018 02:58:31,279 --> 02:58:35,520 have the channel profile picture and the 4019 02:58:33,200 --> 02:58:36,960 other column is going to have the text. 4020 02:58:35,520 --> 02:58:40,080 Let's create the channel profile 4021 02:58:36,960 --> 02:58:41,840 picture. First, we're going to create an 4022 02:58:40,080 --> 02:58:44,880 image element. 4023 02:58:41,840 --> 02:58:47,279 We're going to give it the source 4024 02:58:44,880 --> 02:58:50,479 of the picture that we downloaded in the 4025 02:58:47,279 --> 02:58:52,800 beginning. So that picture is in this 4026 02:58:50,479 --> 02:58:56,640 folder. So we're going to go into this 4027 02:58:52,800 --> 02:58:59,279 folder first, which is channel-p 4028 02:58:56,640 --> 02:59:01,520 pictures. And then remember to have a 4029 02:58:59,279 --> 02:59:04,560 slash to go into that folder. And then 4030 02:59:01,520 --> 02:59:06,399 channel one.jpeg. 4031 02:59:04,560 --> 02:59:07,680 Save it. 4032 02:59:06,399 --> 02:59:09,760 And now if we look at our current 4033 02:59:07,680 --> 02:59:11,600 website, the image is actually in its 4034 02:59:09,760 --> 02:59:13,359 own row. And that's because the 4035 02:59:11,600 --> 02:59:15,680 paragraph is a block element, so it has 4036 02:59:13,359 --> 02:59:17,680 to appear on its own line. We're going 4037 02:59:15,680 --> 02:59:21,040 to change this by creating a horizontal 4038 02:59:17,680 --> 02:59:23,520 layout like one and two. So to do that, 4039 02:59:21,040 --> 02:59:28,960 we're going to create two divs. 4040 02:59:23,520 --> 02:59:31,120 Here's one div and here is another div. 4041 02:59:28,960 --> 02:59:33,040 Now the difference here is that we're 4042 02:59:31,120 --> 02:59:35,600 going to make these divs inline block 4043 02:59:33,040 --> 02:59:37,760 elements. So remember that inline block 4044 02:59:35,600 --> 02:59:39,920 is what allows elements to appear beside 4045 02:59:37,760 --> 02:59:41,840 each other like this. while block 4046 02:59:39,920 --> 02:59:43,600 elements force the element to take up 4047 02:59:41,840 --> 02:59:45,760 the entire line so they will appear 4048 02:59:43,600 --> 02:59:47,279 vertically. 4049 02:59:45,760 --> 02:59:49,359 So we're going to make these two divs 4050 02:59:47,279 --> 02:59:52,000 inline block elements to create our 4051 02:59:49,359 --> 02:59:54,560 horizontal layout. Let's reference our 4052 02:59:52,000 --> 02:59:56,880 design first. In the first column we 4053 02:59:54,560 --> 02:59:59,600 have the channel profile picture. So I'm 4054 02:59:56,880 --> 03:00:03,200 just going to move this 4055 02:59:59,600 --> 03:00:05,040 into the first div here. 4056 03:00:03,200 --> 03:00:07,200 And then in the second div, we have all 4057 03:00:05,040 --> 03:00:10,319 the text. So, I'm going to move all of 4058 03:00:07,200 --> 03:00:14,319 the text here. 4059 03:00:10,319 --> 03:00:16,479 Cut and paste. 4060 03:00:14,319 --> 03:00:19,279 Now, let's make these divs inline blocks 4061 03:00:16,479 --> 03:00:21,439 so that they appear next to each other. 4062 03:00:19,279 --> 03:00:24,640 I'm going to give a class so that we can 4063 03:00:21,439 --> 03:00:26,160 target it with CSS. Let's call this the 4064 03:00:24,640 --> 03:00:28,479 channel 4065 03:00:26,160 --> 03:00:30,479 picture. And then we're also going to 4066 03:00:28,479 --> 03:00:33,760 give a class to this div so that we can 4067 03:00:30,479 --> 03:00:36,720 target it. Let's call this the video 4068 03:00:33,760 --> 03:00:40,399 dash info. 4069 03:00:36,720 --> 03:00:44,399 And now in our CSS, 4070 03:00:40,399 --> 03:00:46,240 we're going to make the channel picture. 4071 03:00:44,399 --> 03:00:50,640 Picture 4072 03:00:46,240 --> 03:00:53,040 display inline dashblock. 4073 03:00:50,640 --> 03:00:55,359 And we're also going to make the video 4074 03:00:53,040 --> 03:01:00,560 info display inline block so they appear 4075 03:00:55,359 --> 03:01:04,960 next to each other. video dash info 4076 03:01:00,560 --> 03:01:08,000 display inline block. 4077 03:01:04,960 --> 03:01:09,520 Save it and refresh. 4078 03:01:08,000 --> 03:01:10,960 Now, you'll notice that they're still on 4079 03:01:09,520 --> 03:01:13,760 top of each other, and that's because 4080 03:01:10,960 --> 03:01:15,920 divs by default have a width of 100%. 4081 03:01:13,760 --> 03:01:18,160 So, we need to decrease the width of 4082 03:01:15,920 --> 03:01:20,479 these two divs so that they appear next 4083 03:01:18,160 --> 03:01:22,800 to each other. So, remember that for the 4084 03:01:20,479 --> 03:01:26,080 video preview card, so this whole thing, 4085 03:01:22,800 --> 03:01:28,080 we set the div to 300 pixels. And that's 4086 03:01:26,080 --> 03:01:29,359 how they can appear beside each other. 4087 03:01:28,080 --> 03:01:33,120 So we're going to do the same thing for 4088 03:01:29,359 --> 03:01:35,279 our horizontal layout down here. 4089 03:01:33,120 --> 03:01:36,880 For the channel picture, let's set a 4090 03:01:35,279 --> 03:01:39,840 width 4091 03:01:36,880 --> 03:01:41,520 of 50 pixels. 4092 03:01:39,840 --> 03:01:43,600 And then for the video info, we're going 4093 03:01:41,520 --> 03:01:46,479 to set a width 4094 03:01:43,600 --> 03:01:48,160 to 200 pixels. 4095 03:01:46,479 --> 03:01:50,080 So this is the first column of our 4096 03:01:48,160 --> 03:01:52,640 horizontal layout. It's going to take up 4097 03:01:50,080 --> 03:01:54,160 50 pixels like this. And then this is 4098 03:01:52,640 --> 03:01:56,800 the second column. It's going to take up 4099 03:01:54,160 --> 03:01:58,800 200 pixels. It's going to appear beside 4100 03:01:56,800 --> 03:02:01,920 the first column because both of them 4101 03:01:58,800 --> 03:02:04,479 are display inline block. 4102 03:02:01,920 --> 03:02:07,200 So, let's save this. And you'll notice 4103 03:02:04,479 --> 03:02:09,279 it looks really weird. So, let's look at 4104 03:02:07,200 --> 03:02:11,040 our code and see what the problem is. 4105 03:02:09,279 --> 03:02:12,800 I'm going to scroll up here. And you'll 4106 03:02:11,040 --> 03:02:15,920 notice that we set the width of the 4107 03:02:12,800 --> 03:02:18,319 video title, which is this text, to 300. 4108 03:02:15,920 --> 03:02:20,640 So, we're forcing it to overflow here. 4109 03:02:18,319 --> 03:02:24,160 And that's not what we want. So, we just 4110 03:02:20,640 --> 03:02:27,040 need to remove this 4111 03:02:24,160 --> 03:02:29,920 and not force a width. 4112 03:02:27,040 --> 03:02:32,160 So if we don't force a width of 300, the 4113 03:02:29,920 --> 03:02:34,720 paragraph will just take up the entire 4114 03:02:32,160 --> 03:02:37,520 space of the container which is 200 4115 03:02:34,720 --> 03:02:39,760 pixels. Now the second thing we notice 4116 03:02:37,520 --> 03:02:42,160 is that this image is overflowing and 4117 03:02:39,760 --> 03:02:44,720 that's because images by default they 4118 03:02:42,160 --> 03:02:46,479 overflow. So they keep their original 4119 03:02:44,720 --> 03:02:49,200 dimensions. So they keep their original 4120 03:02:46,479 --> 03:02:51,680 size and that causes them to overflow. 4121 03:02:49,200 --> 03:02:55,040 So, we want to resize this image so that 4122 03:02:51,680 --> 03:02:58,399 it only takes up 50 pixels. 4123 03:02:55,040 --> 03:03:00,319 Let's go ahead and do that right now. 4124 03:02:58,399 --> 03:03:02,479 Let's give it a class so that we can 4125 03:03:00,319 --> 03:03:06,640 resize it. And I'm going to call this 4126 03:03:02,479 --> 03:03:10,760 the profile dash picture. 4127 03:03:06,640 --> 03:03:10,760 And then I'll scroll up here. 4128 03:03:11,520 --> 03:03:15,680 Picture. 4129 03:03:13,120 --> 03:03:18,880 And then I'm going to resize the width 4130 03:03:15,680 --> 03:03:22,160 to 50 pixels so that it fits exactly 4131 03:03:18,880 --> 03:03:25,520 this column. I'm going to save it. And 4132 03:03:22,160 --> 03:03:27,680 now that looks pretty good. 4133 03:03:25,520 --> 03:03:32,160 We can actually see the layout in our 4134 03:03:27,680 --> 03:03:35,200 browser by right-clicking inspect 4135 03:03:32,160 --> 03:03:37,680 and finding this HTML. 4136 03:03:35,200 --> 03:03:40,399 So I can click this top left icon and 4137 03:03:37,680 --> 03:03:44,479 just click this picture. So I'll show 4138 03:03:40,399 --> 03:03:47,359 you what it looks like in the HTML. 4139 03:03:44,479 --> 03:03:50,160 So here we have a vertical layout. So 4140 03:03:47,359 --> 03:03:54,920 one and two. And then here we have a 4141 03:03:50,160 --> 03:03:54,920 horizontal layout. One and two. 4142 03:03:56,080 --> 03:04:02,000 Now a better way to do this is actually 4143 03:03:57,920 --> 03:04:04,160 to set this to 100%. 4144 03:04:02,000 --> 03:04:06,640 So this means the image will take up the 4145 03:04:04,160 --> 03:04:08,880 entire space of its container. So if we 4146 03:04:06,640 --> 03:04:11,760 look at our HTML, 4147 03:04:08,880 --> 03:04:13,760 this image is inside this container. If 4148 03:04:11,760 --> 03:04:16,000 we set it to 100%, it'll take up the 4149 03:04:13,760 --> 03:04:17,760 space in the container, which is 4150 03:04:16,000 --> 03:04:22,240 basically the 50 pixels that we have 4151 03:04:17,760 --> 03:04:23,920 here. Let's save it. 4152 03:04:22,240 --> 03:04:27,439 Next, remember that we've seen this 4153 03:04:23,920 --> 03:04:29,520 problem before. They're not aligned. 4154 03:04:27,439 --> 03:04:32,479 So we're going to align this inline 4155 03:04:29,520 --> 03:04:34,080 block element to the top. 4156 03:04:32,479 --> 03:04:36,399 To do that, we're going to use this 4157 03:04:34,080 --> 03:04:40,560 property here, vertical align top that 4158 03:04:36,399 --> 03:04:42,240 we've seen before. So, vertical dash 4159 03:04:40,560 --> 03:04:44,319 align 4160 03:04:42,240 --> 03:04:46,800 top. 4161 03:04:44,319 --> 03:04:48,399 Save it. 4162 03:04:46,800 --> 03:04:51,279 All right. So, we're almost there, but 4163 03:04:48,399 --> 03:04:53,279 notice that these two aren't aligned. 4164 03:04:51,279 --> 03:04:56,080 This paragraph has some margin at the 4165 03:04:53,279 --> 03:04:58,880 top. Remember that paragraphs by default 4166 03:04:56,080 --> 03:05:01,120 come with margin at the top and at the 4167 03:04:58,880 --> 03:05:02,720 bottom. So, we're going to go into our 4168 03:05:01,120 --> 03:05:06,399 code and we're going to get rid of this 4169 03:05:02,720 --> 03:05:08,960 margin at the top. So, let's scroll up. 4170 03:05:06,399 --> 03:05:11,600 Oh, so we actually deleted that style. 4171 03:05:08,960 --> 03:05:15,520 So, let's create a new style here. We're 4172 03:05:11,600 --> 03:05:17,439 going to target the video-title. 4173 03:05:15,520 --> 03:05:19,600 We're going to target the class 4174 03:05:17,439 --> 03:05:21,600 video-title. 4175 03:05:19,600 --> 03:05:25,439 Set the margin 4176 03:05:21,600 --> 03:05:26,960 top to zero. 4177 03:05:25,439 --> 03:05:30,200 And that's going to eliminate the space 4178 03:05:26,960 --> 03:05:30,200 up here. 4179 03:05:31,120 --> 03:05:34,960 So, I'm going to pause here because 4180 03:05:32,479 --> 03:05:37,840 we've actually created the nested layout 4181 03:05:34,960 --> 03:05:41,279 that we need. Let's look into our HTML 4182 03:05:37,840 --> 03:05:44,560 in the dev tools. And if we look at this 4183 03:05:41,279 --> 03:05:46,800 video preview, we have a vertical layout 4184 03:05:44,560 --> 03:05:48,640 1 and two. 4185 03:05:46,800 --> 03:05:52,479 Inside the vertical layout, we have a 4186 03:05:48,640 --> 03:05:54,640 horizontal layout 1 and two. And then 4187 03:05:52,479 --> 03:05:59,279 inside our horizontal layout, we have 4188 03:05:54,640 --> 03:06:01,359 another vertical layout. 1 2 3. 4189 03:05:59,279 --> 03:06:04,319 So that's a practical example of using 4190 03:06:01,359 --> 03:06:08,479 the nested layout technique to create a 4191 03:06:04,319 --> 03:06:10,560 layout that's a similar shape to this. 4192 03:06:08,479 --> 03:06:14,399 The only thing that's left to do is to 4193 03:06:10,560 --> 03:06:17,040 style our website with CSS one by one 4194 03:06:14,399 --> 03:06:19,680 until it looks like this. So we're going 4195 03:06:17,040 --> 03:06:21,200 to do that right now. So let's go into 4196 03:06:19,680 --> 03:06:24,080 our code and we're going to style these 4197 03:06:21,200 --> 03:06:25,920 elements one by one. So, I'm actually 4198 03:06:24,080 --> 03:06:29,880 going to move this down here so that I 4199 03:06:25,920 --> 03:06:29,880 can see it a lot easier. 4200 03:06:33,520 --> 03:06:39,120 So, the first thing I notice is that the 4201 03:06:35,760 --> 03:06:41,840 image is round. So, remember to create a 4202 03:06:39,120 --> 03:06:44,000 round image or round anything, we're 4203 03:06:41,840 --> 03:06:46,800 going to use rounded corners. So, we're 4204 03:06:44,000 --> 03:06:51,359 going to set the border- 4205 03:06:46,800 --> 03:06:53,200 radius to, let's say, 20 pixels. Save 4206 03:06:51,359 --> 03:06:54,880 it. Okay. Okay, so we have rounded 4207 03:06:53,200 --> 03:06:57,200 corners and it's getting more round, but 4208 03:06:54,880 --> 03:07:01,279 it's not a full circle yet. So, let's 4209 03:06:57,200 --> 03:07:03,920 set this to maybe 50 pixels. Okay, so 4210 03:07:01,279 --> 03:07:09,319 now it looks a little too big. Let's set 4211 03:07:03,920 --> 03:07:09,319 the width to something like 40 pixels. 4212 03:07:09,520 --> 03:07:14,240 I think that looks pretty close, and we 4213 03:07:11,760 --> 03:07:16,800 can always change it later. Next, 4214 03:07:14,240 --> 03:07:20,319 there's some spacing between the first 4215 03:07:16,800 --> 03:07:22,319 row and the second row. So, let's go in 4216 03:07:20,319 --> 03:07:24,880 here. 4217 03:07:22,319 --> 03:07:27,520 We're going to set a class here. Call 4218 03:07:24,880 --> 03:07:32,080 this the thumbnail 4219 03:07:27,520 --> 03:07:35,760 dash row. And then we're going to style 4220 03:07:32,080 --> 03:07:37,520 this thumbnail row. 4221 03:07:35,760 --> 03:07:39,920 And remember to add spacing to the 4222 03:07:37,520 --> 03:07:42,319 bottom, we add 4223 03:07:39,920 --> 03:07:44,399 margin 4224 03:07:42,319 --> 03:07:46,240 dash bottom. 4225 03:07:44,399 --> 03:07:48,640 And let's add a margin of maybe 10 4226 03:07:46,240 --> 03:07:51,600 pixels. Save it. 4227 03:07:48,640 --> 03:07:53,920 Okay, maybe 12 pixels. Okay, so that 4228 03:07:51,600 --> 03:07:57,279 looks good enough. And finally, we can 4229 03:07:53,920 --> 03:07:59,359 style the text. 4230 03:07:57,279 --> 03:08:02,319 So, this YouTube project is actually 4231 03:07:59,359 --> 03:08:04,160 using the Google font called Roboto. We 4232 03:08:02,319 --> 03:08:06,240 learned in a previous lesson how to load 4233 03:08:04,160 --> 03:08:08,160 Google Fonts and in particular, how to 4234 03:08:06,240 --> 03:08:12,080 load Roboto. So, we're going to do that 4235 03:08:08,160 --> 03:08:16,479 again. Let's go to a new tab. We're 4236 03:08:12,080 --> 03:08:19,040 going to search for Google Fonts 4237 03:08:16,479 --> 03:08:21,439 and we're going to load Roboto onto our 4238 03:08:19,040 --> 03:08:23,760 page. So, if you don't have this here, 4239 03:08:21,439 --> 03:08:27,200 this is from my previous session. We can 4240 03:08:23,760 --> 03:08:30,160 actually search for Roboto 4241 03:08:27,200 --> 03:08:31,840 and then just open it here. 4242 03:08:30,160 --> 03:08:34,160 And then we select the styles that we 4243 03:08:31,840 --> 03:08:37,840 want. So, I'm going to get the regular 4244 03:08:34,160 --> 03:08:40,479 style. And then this seems like a bolded 4245 03:08:37,840 --> 03:08:44,800 font. So, I'm going to get the medium 4246 03:08:40,479 --> 03:08:46,960 font. and the bold font just in case. 4247 03:08:44,800 --> 03:08:50,000 So, I'm going to go up to see the styles 4248 03:08:46,960 --> 03:08:51,520 I selected and then that looks pretty 4249 03:08:50,000 --> 03:08:53,600 good. 4250 03:08:51,520 --> 03:08:56,160 And Google will give me the code that I 4251 03:08:53,600 --> 03:08:59,040 need to load this onto my website. I'm 4252 03:08:56,160 --> 03:09:02,319 going to copy this 4253 03:08:59,040 --> 03:09:06,880 and just paste it into my head section. 4254 03:09:02,319 --> 03:09:10,000 So, right in between here. 4255 03:09:06,880 --> 03:09:12,080 All right. So now I loaded the Roboto 4256 03:09:10,000 --> 03:09:14,640 font and we're going to use it in our 4257 03:09:12,080 --> 03:09:19,040 page. 4258 03:09:14,640 --> 03:09:21,279 So we're going to target all paragraphs 4259 03:09:19,040 --> 03:09:22,800 and we're going to change their font 4260 03:09:21,279 --> 03:09:26,000 family 4261 03:09:22,800 --> 03:09:30,800 to Roboto and we're also going to use a 4262 03:09:26,000 --> 03:09:32,960 backup font with this comma of Ariel. 4263 03:09:30,800 --> 03:09:35,600 So this syntax here with a comma is 4264 03:09:32,960 --> 03:09:38,399 called a font stack. This basically lets 4265 03:09:35,600 --> 03:09:41,120 us set up a backup font. If for whatever 4266 03:09:38,399 --> 03:09:42,960 reason Roboto fails to load from Google, 4267 03:09:41,120 --> 03:09:46,479 then it will fall back to our backup 4268 03:09:42,960 --> 03:09:49,960 font, which is Aerial. 4269 03:09:46,479 --> 03:09:49,960 Let's save it. 4270 03:09:50,000 --> 03:09:54,640 Next, I'm going to change the size of 4271 03:09:51,760 --> 03:09:58,399 the font. So, let's change the video 4272 03:09:54,640 --> 03:10:00,240 title to maybe 4273 03:09:58,399 --> 03:10:02,960 14 pixels. 4274 03:10:00,240 --> 03:10:04,479 Save it. Okay, I think that looks pretty 4275 03:10:02,960 --> 03:10:08,399 good. 4276 03:10:04,479 --> 03:10:10,560 Next, I'm going to make it bold. So, 4277 03:10:08,399 --> 03:10:14,160 font dashweight 4278 03:10:10,560 --> 03:10:15,520 bold. Save it. 4279 03:10:14,160 --> 03:10:18,399 So, this looks like it's a little bit 4280 03:10:15,520 --> 03:10:20,399 too bold compared to this font. So, I'm 4281 03:10:18,399 --> 03:10:22,240 actually going to change this value to 4282 03:10:20,399 --> 03:10:24,720 500. 4283 03:10:22,240 --> 03:10:28,080 So, if you recall, we actually selected 4284 03:10:24,720 --> 03:10:31,920 three styles of fonts. The regular 400, 4285 03:10:28,080 --> 03:10:34,399 medium 500, and bold 700. So when we set 4286 03:10:31,920 --> 03:10:37,680 the font weight to bold, it actually 4287 03:10:34,399 --> 03:10:40,560 corresponds to a number which is 700. A 4288 03:10:37,680 --> 03:10:43,520 regular font weight is 400 and a 4289 03:10:40,560 --> 03:10:45,200 semibold is 500. 4290 03:10:43,520 --> 03:10:47,840 So usually we use the number value 4291 03:10:45,200 --> 03:10:50,080 because it's a little more precise. So 4292 03:10:47,840 --> 03:10:54,240 usually instead of typing font weight 4293 03:10:50,080 --> 03:10:56,720 bold, we would use font weight 700. 4294 03:10:54,240 --> 03:10:59,520 In our case, our font is a little too 4295 03:10:56,720 --> 03:11:01,600 bold. So we're going to decrease this to 4296 03:10:59,520 --> 03:11:04,000 500. 4297 03:11:01,600 --> 03:11:08,399 which is the medium size that we picked 4298 03:11:04,000 --> 03:11:11,680 on Google Fonts. So, let's save this. 4299 03:11:08,399 --> 03:11:13,279 And that looks pretty close. Next, we're 4300 03:11:11,680 --> 03:11:14,960 going to change the space between the 4301 03:11:13,279 --> 03:11:17,120 lines. 4302 03:11:14,960 --> 03:11:20,880 So, remember the property to do that is 4303 03:11:17,120 --> 03:11:24,880 called line dash height. 4304 03:11:20,880 --> 03:11:29,040 And let's try 14 pixels. 4305 03:11:24,880 --> 03:11:29,920 That's not enough. Maybe 20 pixels. 4306 03:11:29,040 --> 03:11:31,680 All right. All right. So, I think that 4307 03:11:29,920 --> 03:11:33,920 looks pretty good and close to our 4308 03:11:31,680 --> 03:11:36,960 design. You might notice that the text 4309 03:11:33,920 --> 03:11:39,200 here is shorter than what we have in the 4310 03:11:36,960 --> 03:11:41,680 design. You may or may not see this 4311 03:11:39,200 --> 03:11:43,840 because this text actually depends on 4312 03:11:41,680 --> 03:11:47,040 the size of the web page. So, depending 4313 03:11:43,840 --> 03:11:49,680 on how wide your web page is, 4314 03:11:47,040 --> 03:11:51,439 the length of this text will change. And 4315 03:11:49,680 --> 03:11:54,240 in our current website, we actually 4316 03:11:51,439 --> 03:11:57,439 haven't implemented this resizing. So, 4317 03:11:54,240 --> 03:12:00,479 we are going to fix this later. 4318 03:11:57,439 --> 03:12:03,760 Next, I'm going to style this paragraph. 4319 03:12:00,479 --> 03:12:05,520 So, let's go into our HTML here and look 4320 03:12:03,760 --> 03:12:07,120 at the class name. So, it's the video 4321 03:12:05,520 --> 03:12:09,279 author. 4322 03:12:07,120 --> 03:12:11,120 And it looks like we don't have any 4323 03:12:09,279 --> 03:12:14,160 styles for that yet. So, I'm going to 4324 03:12:11,120 --> 03:12:19,560 write it down here. So, we're going to 4325 03:12:14,160 --> 03:12:19,560 style the class video- aauthor. 4326 03:12:19,920 --> 03:12:24,399 The first thing I notice is the font 4327 03:12:21,600 --> 03:12:27,279 size. So, it's a lot smaller. So, font- 4328 03:12:24,399 --> 03:12:29,920 size. Let's try 12 pixels. Let's see how 4329 03:12:27,279 --> 03:12:32,720 that looks. Okay, so I think that looks 4330 03:12:29,920 --> 03:12:35,120 pretty close. And we're going to change 4331 03:12:32,720 --> 03:12:36,720 the color. 4332 03:12:35,120 --> 03:12:38,800 Color. 4333 03:12:36,720 --> 03:12:40,560 Now remember to get an exact color, we 4334 03:12:38,800 --> 03:12:42,399 can rightclick, 4335 03:12:40,560 --> 03:12:44,479 inspect, 4336 03:12:42,399 --> 03:12:46,800 and then 4337 03:12:44,479 --> 03:12:50,880 click this top left icon, click this 4338 03:12:46,800 --> 03:12:52,880 text, go to the computer tab, 4339 03:12:50,880 --> 03:12:58,240 and if we scroll down, we should get the 4340 03:12:52,880 --> 03:13:00,160 text color right here. So, RGB 96 96 96. 4341 03:12:58,240 --> 03:13:03,880 Save that. 4342 03:13:00,160 --> 03:13:03,880 And if we go back. 4343 03:13:06,560 --> 03:13:12,000 Okay, that looks perfect. Next, I'm 4344 03:13:09,279 --> 03:13:14,160 going to style this paragraph. 4345 03:13:12,000 --> 03:13:16,640 So, in our code, this paragraph is 4346 03:13:14,160 --> 03:13:18,880 called video-stats. 4347 03:13:16,640 --> 03:13:21,279 And I'm not sure if we have a style for 4348 03:13:18,880 --> 03:13:23,920 this. Doesn't look like we do. So, I'm 4349 03:13:21,279 --> 03:13:26,560 going to write a new one. So, dot 4350 03:13:23,920 --> 03:13:29,200 video-stats. 4351 03:13:26,560 --> 03:13:33,600 We're going to set the font size to 12 4352 03:13:29,200 --> 03:13:35,200 pixels because these two look the same. 4353 03:13:33,600 --> 03:13:38,560 Okay. And then we're going to set the 4354 03:13:35,200 --> 03:13:41,120 color as well since these two look the 4355 03:13:38,560 --> 03:13:42,800 same. 4356 03:13:41,120 --> 03:13:45,359 And now remember that whenever we have 4357 03:13:42,800 --> 03:13:48,080 these duplicate styles like this and 4358 03:13:45,359 --> 03:13:50,960 this, we can actually target multiple 4359 03:13:48,080 --> 03:13:53,600 classes by adding a comma. So, we're 4360 03:13:50,960 --> 03:13:56,720 going to target the video- aauthor class 4361 03:13:53,600 --> 03:13:59,040 as well as the video-stats 4362 03:13:56,720 --> 03:14:01,600 class. So, this is going to help us 4363 03:13:59,040 --> 03:14:03,920 reduce duplication of our code. So, I'm 4364 03:14:01,600 --> 03:14:07,200 going to delete these lines. 4365 03:14:03,920 --> 03:14:08,560 Save it. Everything looks okay. 4366 03:14:07,200 --> 03:14:11,040 And the last thing we're going to modify 4367 03:14:08,560 --> 03:14:13,200 is the spacing between the paragraphs. 4368 03:14:11,040 --> 03:14:15,840 So, remember that paragraphs by default 4369 03:14:13,200 --> 03:14:18,239 come with margin at the top and at the 4370 03:14:15,840 --> 03:14:20,319 bottom. Now, instead of removing them 4371 03:14:18,239 --> 03:14:23,120 individually, I'm actually going to go 4372 03:14:20,319 --> 03:14:25,279 up to the top of our page. So, we did 4373 03:14:23,120 --> 03:14:27,520 this once before, we're going to get rid 4374 03:14:25,279 --> 03:14:30,000 of the default margin for all paragraphs 4375 03:14:27,520 --> 03:14:32,000 on the page. So, to do that, we're going 4376 03:14:30,000 --> 03:14:34,960 to go into these styles, and we're going 4377 03:14:32,000 --> 03:14:37,040 to set the margin-top 4378 03:14:34,960 --> 03:14:38,319 to zero. 4379 03:14:37,040 --> 03:14:41,319 And we're also going to set the 4380 03:14:38,319 --> 03:14:41,319 margin-bottom 4381 03:14:41,359 --> 03:14:45,920 to zero. And this will get rid of all 4382 03:14:43,680 --> 03:14:47,680 the default margins. 4383 03:14:45,920 --> 03:14:49,680 Save it. 4384 03:14:47,680 --> 03:14:52,160 And now we can set a more precise margin 4385 03:14:49,680 --> 03:14:57,279 at the bottom here. So under the video 4386 03:14:52,160 --> 03:14:59,920 title, let's set a margin bottom of 4387 03:14:57,279 --> 03:15:02,319 maybe 15 pixels. 4388 03:14:59,920 --> 03:15:06,319 Save it. Okay, looks like it's a little 4389 03:15:02,319 --> 03:15:08,239 too much. Maybe 12 pixels. 4390 03:15:06,319 --> 03:15:10,239 Okay, I think that looks pretty good. 4391 03:15:08,239 --> 03:15:13,800 And now under the video author, we're 4392 03:15:10,239 --> 03:15:13,800 going to add some margin. 4393 03:15:13,840 --> 03:15:18,000 So currently we have some styles that 4394 03:15:15,600 --> 03:15:22,319 apply to both of these. I'm going to 4395 03:15:18,000 --> 03:15:24,000 target video- aauthor individually down 4396 03:15:22,319 --> 03:15:25,520 here. 4397 03:15:24,000 --> 03:15:29,000 So for the video author, I'm going to 4398 03:15:25,520 --> 03:15:29,000 add a margin-bottom 4399 03:15:29,520 --> 03:15:34,160 of maybe six pixels. 4400 03:15:32,160 --> 03:15:37,680 Save it 4401 03:15:34,160 --> 03:15:39,120 and maybe four pixels. 4402 03:15:37,680 --> 03:15:40,720 Okay, so I think that looks pretty 4403 03:15:39,120 --> 03:15:42,399 close. And now if we look at our 4404 03:15:40,720 --> 03:15:45,040 website, you can tell that it's actually 4405 03:15:42,399 --> 03:15:47,760 really close to the final design that we 4406 03:15:45,040 --> 03:15:50,160 have. Now, to finish off this second 4407 03:15:47,760 --> 03:15:52,000 video preview, you have a choice. You 4408 03:15:50,160 --> 03:15:54,000 can either do everything that we did in 4409 03:15:52,000 --> 03:15:56,479 the code here to give yourself more 4410 03:15:54,000 --> 03:15:58,560 practice, or if you want to save time 4411 03:15:56,479 --> 03:16:01,680 and move on to the next section, we can 4412 03:15:58,560 --> 03:16:05,040 just copy all of this HTML and replace 4413 03:16:01,680 --> 03:16:08,160 this part here. 4414 03:16:05,040 --> 03:16:10,479 and then just swap out the thumbnail 4415 03:16:08,160 --> 03:16:12,080 as well as the channel profile picture, 4416 03:16:10,479 --> 03:16:14,560 which you will need to download first 4417 03:16:12,080 --> 03:16:16,399 from here, as well as swap out all the 4418 03:16:14,560 --> 03:16:18,239 text. So, I'm just going to fast forward 4419 03:16:16,399 --> 03:16:20,800 this video to finish up this second 4420 03:16:18,239 --> 03:16:22,479 video preview, but feel free to pause it 4421 03:16:20,800 --> 03:16:25,800 and try it yourself to give yourself 4422 03:16:22,479 --> 03:16:25,800 more practice. 4423 03:16:29,200 --> 03:16:33,439 And there we go. In this lesson, we 4424 03:16:31,439 --> 03:16:34,800 learn the nested layouts technique, 4425 03:16:33,439 --> 03:16:36,960 which is one of the most important 4426 03:16:34,800 --> 03:16:39,359 techniques for being able to break down 4427 03:16:36,960 --> 03:16:43,560 a design that you see on a website and 4428 03:16:39,359 --> 03:16:43,560 recreate it using code. 4429 03:17:01,840 --> 03:17:05,920 In this lesson, we're going to learn 4430 03:17:03,200 --> 03:17:08,720 about CSS grid, which is a much better 4431 03:17:05,920 --> 03:17:11,359 way to create these horizontal layouts, 4432 03:17:08,720 --> 03:17:13,840 as well as to create a grid like this 4433 03:17:11,359 --> 03:17:15,279 that you see in our final project. 4434 03:17:13,840 --> 03:17:17,520 First, we're going to open up the 4435 03:17:15,279 --> 03:17:20,479 website we were working on. So, I have 4436 03:17:17,520 --> 03:17:22,800 it open right here. And remember that 4437 03:17:20,479 --> 03:17:24,640 for our horizontal layouts, we were 4438 03:17:22,800 --> 03:17:27,520 creating them using something called 4439 03:17:24,640 --> 03:17:32,000 display inline block. So if we go into 4440 03:17:27,520 --> 03:17:34,880 our code and we scroll down, 4441 03:17:32,000 --> 03:17:38,479 we were using display inline block and a 4442 03:17:34,880 --> 03:17:40,080 width to put these two side by side. Now 4443 03:17:38,479 --> 03:17:41,760 there are some problems with display 4444 03:17:40,080 --> 03:17:44,239 inline block that I want to show you 4445 03:17:41,760 --> 03:17:48,000 right now. We're going to set the 4446 03:17:44,239 --> 03:17:49,680 background color of these to gray. So 4447 03:17:48,000 --> 03:17:52,479 this will make it easier to see what the 4448 03:17:49,680 --> 03:17:55,200 problem is. 4449 03:17:52,479 --> 03:17:56,880 Now let's save it. 4450 03:17:55,200 --> 03:17:59,120 And now you can see that there's a 4451 03:17:56,880 --> 03:18:02,160 little bit of space between these two. 4452 03:17:59,120 --> 03:18:04,560 And this causes some alignment problems. 4453 03:18:02,160 --> 03:18:08,720 So the width of this entire container 4454 03:18:04,560 --> 03:18:11,279 here, the width here, we set it to 300 4455 03:18:08,720 --> 03:18:14,319 pixels. But we set the channel picture 4456 03:18:11,279 --> 03:18:17,120 to 50 pixels here and the video info to 4457 03:18:14,319 --> 03:18:20,160 200. So you would expect that we can 4458 03:18:17,120 --> 03:18:24,160 actually set this to 250 to take up the 4459 03:18:20,160 --> 03:18:25,760 entire 300 pixels. But if I save it, you 4460 03:18:24,160 --> 03:18:27,920 can see that it's too long and it wraps 4461 03:18:25,760 --> 03:18:30,960 to the next line. So we have to set it 4462 03:18:27,920 --> 03:18:32,720 to something like 245 4463 03:18:30,960 --> 03:18:35,439 and that will cause it to appear beside 4464 03:18:32,720 --> 03:18:37,359 each other. So this is one problem with 4465 03:18:35,439 --> 03:18:39,439 inline block is that it has some 4466 03:18:37,359 --> 03:18:40,880 alignment problems. Now you might be 4467 03:18:39,439 --> 03:18:46,319 wondering where this space is coming 4468 03:18:40,880 --> 03:18:48,319 from. If we scroll down to our HTML, 4469 03:18:46,319 --> 03:18:50,800 we can see that there's actually some 4470 03:18:48,319 --> 03:18:53,359 space between these two divs. And we 4471 03:18:50,800 --> 03:18:55,680 learned earlier that HTML combines 4472 03:18:53,359 --> 03:18:58,880 multiple spaces together and that's what 4473 03:18:55,680 --> 03:19:01,359 shows up here. So we could remove this 4474 03:18:58,880 --> 03:19:03,120 and save and get rid of that space. But 4475 03:19:01,359 --> 03:19:06,080 that means our code is less easy to 4476 03:19:03,120 --> 03:19:08,000 read. Now the second problem that inline 4477 03:19:06,080 --> 03:19:10,560 block has is that it's not vertically 4478 03:19:08,000 --> 03:19:12,319 aligned like you see here. So now we're 4479 03:19:10,560 --> 03:19:14,880 going to learn a new technique called 4480 03:19:12,319 --> 03:19:18,239 CSS grid that's going to help us create 4481 03:19:14,880 --> 03:19:20,160 perfectly aligned horizontal layouts. 4482 03:19:18,239 --> 03:19:21,680 to learn grid. We're going to create a 4483 03:19:20,160 --> 03:19:24,239 new file where we're just going to 4484 03:19:21,680 --> 03:19:26,399 practice using grids. So, let's go into 4485 03:19:24,239 --> 03:19:28,880 our code editor 4486 03:19:26,399 --> 03:19:32,680 and we're going to create a new file 4487 03:19:28,880 --> 03:19:32,680 called grid.html. 4488 03:19:33,359 --> 03:19:37,920 And remember, for every HTML file, we 4489 03:19:35,680 --> 03:19:41,920 want the proper structure. So, at the 4490 03:19:37,920 --> 03:19:43,920 top, we're going to have a doc type. 4491 03:19:41,920 --> 03:19:45,439 And then we're going to have an HTML 4492 03:19:43,920 --> 03:19:47,200 element. 4493 03:19:45,439 --> 03:19:52,080 And then inside we're going to have a 4494 03:19:47,200 --> 03:19:53,920 head element and a body element. Now 4495 03:19:52,080 --> 03:19:56,640 that we have the proper structure, we 4496 03:19:53,920 --> 03:19:59,359 can open this file in live server. So 4497 03:19:56,640 --> 03:20:02,359 let's rightclick and open with live 4498 03:19:59,359 --> 03:20:02,359 server. 4499 03:20:04,800 --> 03:20:10,399 And then let's set the title or the text 4500 03:20:07,760 --> 03:20:14,960 in the tabs here 4501 03:20:10,399 --> 03:20:17,279 to grid practice 4502 03:20:14,960 --> 03:20:20,239 so we know what this file is about. 4503 03:20:17,279 --> 03:20:21,920 Let's save it. So I'm going to resize my 4504 03:20:20,239 --> 03:20:24,560 windows here just so we can see what's 4505 03:20:21,920 --> 03:20:27,200 going on. 4506 03:20:24,560 --> 03:20:29,920 We're going to start off in the body and 4507 03:20:27,200 --> 03:20:31,359 we're going to create a div. And then 4508 03:20:29,920 --> 03:20:34,000 inside this div, we're going to create 4509 03:20:31,359 --> 03:20:37,359 two divs. 4510 03:20:34,000 --> 03:20:42,960 So let's call this div one and let's 4511 03:20:37,359 --> 03:20:44,640 call this div 2. Save it. And now to 4512 03:20:42,960 --> 03:20:47,840 help us learn, I'm actually going to 4513 03:20:44,640 --> 03:20:50,399 show you a new way of writing CSS. So if 4514 03:20:47,840 --> 03:20:52,960 we go to the opening tag here, we can 4515 03:20:50,399 --> 03:20:54,479 set a special attribute called a style 4516 03:20:52,960 --> 03:20:56,319 attribute. 4517 03:20:54,479 --> 03:20:58,479 Now the style attribute is unique 4518 03:20:56,319 --> 03:21:01,279 because it lets us write CSS code 4519 03:20:58,479 --> 03:21:06,560 inside. So let's write the code 4520 03:21:01,279 --> 03:21:08,640 background dash color light blue 4521 03:21:06,560 --> 03:21:10,720 and we save it. We can see that these 4522 03:21:08,640 --> 03:21:14,080 styles that we wrote here are applied to 4523 03:21:10,720 --> 03:21:16,800 this element. So this code here is 4524 03:21:14,080 --> 03:21:19,520 another way of writing CSS called inline 4525 03:21:16,800 --> 03:21:21,600 styles. We're writing our CSS inside a 4526 03:21:19,520 --> 03:21:23,200 line of HTML. 4527 03:21:21,600 --> 03:21:25,680 We've already learned two other ways of 4528 03:21:23,200 --> 03:21:28,000 writing CSS. One of them is the style 4529 03:21:25,680 --> 03:21:30,880 element and the other is to put our CSS 4530 03:21:28,000 --> 03:21:33,680 in a separate file. This is a third way 4531 03:21:30,880 --> 03:21:35,520 of writing CSS. Now, generally we don't 4532 03:21:33,680 --> 03:21:38,239 use this in real websites because it 4533 03:21:35,520 --> 03:21:39,920 makes our HTML harder to read. In real 4534 03:21:38,239 --> 03:21:42,319 websites, we put our styles in a 4535 03:21:39,920 --> 03:21:44,560 separate file. But for now, since we're 4536 03:21:42,319 --> 03:21:46,960 learning, this is pretty useful because 4537 03:21:44,560 --> 03:21:49,439 number one, it only affects the element 4538 03:21:46,960 --> 03:21:52,319 with the style attribute. 4539 03:21:49,439 --> 03:21:55,040 And the other thing is that the CSS code 4540 03:21:52,319 --> 03:21:57,200 is right beside our HTML so that when 4541 03:21:55,040 --> 03:21:59,840 you go and review this file later, it's 4542 03:21:57,200 --> 03:22:01,840 very easy to see what's going on. So 4543 03:21:59,840 --> 03:22:03,279 let's practice with the style attribute. 4544 03:22:01,840 --> 03:22:06,720 We're going to add another one to this 4545 03:22:03,279 --> 03:22:09,200 second div. So let's set the style to 4546 03:22:06,720 --> 03:22:11,200 background color 4547 03:22:09,200 --> 03:22:14,160 and we'll set a background color of 4548 03:22:11,200 --> 03:22:16,399 light pink. 4549 03:22:14,160 --> 03:22:19,600 Let's save it. And now we have the two 4550 03:22:16,399 --> 03:22:21,600 divs we're going to work with. 4551 03:22:19,600 --> 03:22:23,920 Now, currently we just have two divs 4552 03:22:21,600 --> 03:22:25,760 inside another div. There's nothing new 4553 03:22:23,920 --> 03:22:28,319 going on here. But now we're going to 4554 03:22:25,760 --> 03:22:31,520 create our first grid. 4555 03:22:28,319 --> 03:22:34,479 So what is a grid? A grid is a layout 4556 03:22:31,520 --> 03:22:38,080 that has rows and columns. For example, 4557 03:22:34,479 --> 03:22:41,760 this is a 2x3 grid. We have two rows and 4558 03:22:38,080 --> 03:22:44,640 three columns. This is a 1x 2 grid. We 4559 03:22:41,760 --> 03:22:46,319 have one row and two columns. So we're 4560 03:22:44,640 --> 03:22:49,120 going to learn how to make this kind of 4561 03:22:46,319 --> 03:22:51,439 structure in our HTML. To do that, we're 4562 03:22:49,120 --> 03:22:53,920 going to style this outer div or the 4563 03:22:51,439 --> 03:22:55,760 container. So let's see how that works. 4564 03:22:53,920 --> 03:22:57,359 We're going to set a style attribute 4565 03:22:55,760 --> 03:22:59,359 here. 4566 03:22:57,359 --> 03:23:01,600 And to create a grid, we're going to 4567 03:22:59,359 --> 03:23:03,840 need two steps. 4568 03:23:01,600 --> 03:23:06,640 The first step is to set the display 4569 03:23:03,840 --> 03:23:10,800 property. And we're going to set display 4570 03:23:06,640 --> 03:23:14,560 to grid. The second step is we need to 4571 03:23:10,800 --> 03:23:16,800 set how many columns our grid has. So to 4572 03:23:14,560 --> 03:23:19,439 do that we're going to use this property 4573 03:23:16,800 --> 03:23:21,520 grid-template-ash 4574 03:23:19,439 --> 03:23:23,200 columns 4575 03:23:21,520 --> 03:23:28,640 and we're going to give this property 4576 03:23:23,200 --> 03:23:31,439 two values 100 pixels and 100 pixels. So 4577 03:23:28,640 --> 03:23:34,080 these two values define how wide our 4578 03:23:31,439 --> 03:23:36,960 grid columns are. The first column is 4579 03:23:34,080 --> 03:23:38,560 going to have a width of 100 pixels and 4580 03:23:36,960 --> 03:23:40,960 the second column is going to have a 4581 03:23:38,560 --> 03:23:43,120 width of 100 pixels as well. And our 4582 03:23:40,960 --> 03:23:45,920 grid will have two columns. So if we 4583 03:23:43,120 --> 03:23:49,760 save this, you'll see that we created 4584 03:23:45,920 --> 03:23:52,800 our first 1x 2 grid. Now I want to point 4585 03:23:49,760 --> 03:23:55,920 out a few characteristics of a grid. 4586 03:23:52,800 --> 03:23:58,880 First of all, notice that this div is no 4587 03:23:55,920 --> 03:24:00,960 longer taking up the entire line. So 4588 03:23:58,880 --> 03:24:02,720 recall that divs are display block by 4589 03:24:00,960 --> 03:24:05,040 default. they're supposed to take up the 4590 03:24:02,720 --> 03:24:08,319 entire line, but when this element is 4591 03:24:05,040 --> 03:24:10,239 inside a grid, it's actually placed into 4592 03:24:08,319 --> 03:24:13,439 the grid. So, it only takes up the 4593 03:24:10,239 --> 03:24:15,040 entire column instead. 4594 03:24:13,439 --> 03:24:17,439 The second thing you'll notice is that 4595 03:24:15,040 --> 03:24:22,080 there's no extra space between these 4596 03:24:17,439 --> 03:24:24,399 two, unlike with display inline block. 4597 03:24:22,080 --> 03:24:26,720 And the third thing to notice is that, 4598 03:24:24,399 --> 03:24:28,960 for example, let's add another element 4599 03:24:26,720 --> 03:24:31,359 into the second div. Let's add a 4600 03:24:28,960 --> 03:24:33,200 paragraph. 4601 03:24:31,359 --> 03:24:36,239 of text. 4602 03:24:33,200 --> 03:24:38,080 Save it. When we add more elements, this 4603 03:24:36,239 --> 03:24:40,000 makes the second div taller than the 4604 03:24:38,080 --> 03:24:42,080 first one, but they are vertically 4605 03:24:40,000 --> 03:24:45,760 aligned. And that's another difference 4606 03:24:42,080 --> 03:24:49,200 between grids and display inline block. 4607 03:24:45,760 --> 03:24:51,200 Grids maintain alignment much better. 4608 03:24:49,200 --> 03:24:52,880 All right, so that is our basic grid. 4609 03:24:51,200 --> 03:24:55,040 Now, we're going to create another grid 4610 03:24:52,880 --> 03:24:57,200 to practice with. We're going to go into 4611 03:24:55,040 --> 03:25:00,239 our code. We're going to copy all of 4612 03:24:57,200 --> 03:25:02,399 this and then we're going to paste it 4613 03:25:00,239 --> 03:25:04,080 below. 4614 03:25:02,399 --> 03:25:06,399 And it's a little bit weird the 4615 03:25:04,080 --> 03:25:09,279 formatting. So, we can select this and 4616 03:25:06,399 --> 03:25:11,040 press tab to move it back into a normal 4617 03:25:09,279 --> 03:25:13,359 position. 4618 03:25:11,040 --> 03:25:15,279 Let's save it. And now we have our 4619 03:25:13,359 --> 03:25:17,359 second grid, but let's actually add some 4620 03:25:15,279 --> 03:25:19,279 space to the top so that we can see it 4621 03:25:17,359 --> 03:25:23,399 more clearly. 4622 03:25:19,279 --> 03:25:23,399 We're going to add some margin-top 4623 03:25:23,520 --> 03:25:28,560 of 30 pixels. 4624 03:25:25,760 --> 03:25:30,560 Save it. Okay, that looks pretty good. 4625 03:25:28,560 --> 03:25:33,760 And this time we're going to add a third 4626 03:25:30,560 --> 03:25:36,560 column. So this property actually takes 4627 03:25:33,760 --> 03:25:40,000 any number of values that you give it. 4628 03:25:36,560 --> 03:25:42,399 So if we add a third value here of 200 4629 03:25:40,000 --> 03:25:46,080 pixels, it's going to create a third 4630 03:25:42,399 --> 03:25:48,080 column that is 200 pixels wide. 4631 03:25:46,080 --> 03:25:50,880 So the number of values determine the 4632 03:25:48,080 --> 03:25:53,600 number of columns and the value itself 4633 03:25:50,880 --> 03:25:55,920 determines the width of the column. So, 4634 03:25:53,600 --> 03:25:57,760 if we save it, 4635 03:25:55,920 --> 03:26:00,000 we do have three columns here, but we 4636 03:25:57,760 --> 03:26:03,040 only have two divs. So, we need another 4637 03:26:00,000 --> 03:26:06,239 div to fill out the third column. To do 4638 03:26:03,040 --> 03:26:09,040 that, let's copy our first div. And then 4639 03:26:06,239 --> 03:26:12,239 we're just going to paste it down here 4640 03:26:09,040 --> 03:26:14,560 and call it div 3. So, now we have three 4641 03:26:12,239 --> 03:26:16,880 divs to fill out the three columns. And 4642 03:26:14,560 --> 03:26:19,840 you can see that our third column is 200 4643 03:26:16,880 --> 03:26:21,760 pixels versus 100 pixels that we saw 4644 03:26:19,840 --> 03:26:23,520 right here. 4645 03:26:21,760 --> 03:26:25,680 So, let's actually change the text here 4646 03:26:23,520 --> 03:26:27,520 so that we can see what's going on. So, 4647 03:26:25,680 --> 03:26:31,920 100 pixels, 4648 03:26:27,520 --> 03:26:34,160 100 pixels, and 200 pixels. 4649 03:26:31,920 --> 03:26:35,840 Save it. 4650 03:26:34,160 --> 03:26:38,880 So, now let's see what happens when we 4651 03:26:35,840 --> 03:26:41,279 add another div to our grid here. So, 4652 03:26:38,880 --> 03:26:43,359 let's copy this second div and then 4653 03:26:41,279 --> 03:26:46,319 duplicate it. 4654 03:26:43,359 --> 03:26:49,439 Let's copy it and paste. Can actually 4655 03:26:46,319 --> 03:26:52,239 get rid of this paragraph here and save 4656 03:26:49,439 --> 03:26:56,800 it. And now you can see that this fourth 4657 03:26:52,239 --> 03:26:59,040 div wraps around to a second row. So 4658 03:26:56,800 --> 03:27:01,439 whenever we have more elements than we 4659 03:26:59,040 --> 03:27:04,880 have columns here, it starts to wrap 4660 03:27:01,439 --> 03:27:07,760 around and create new rows. 4661 03:27:04,880 --> 03:27:09,359 So that's the basics of how grids work. 4662 03:27:07,760 --> 03:27:12,080 Now I'm going to show you a special 4663 03:27:09,359 --> 03:27:14,640 value that we can use with grids. First, 4664 03:27:12,080 --> 03:27:17,920 let's copy this and then create a new 4665 03:27:14,640 --> 03:27:20,800 grid to practice with. 4666 03:27:17,920 --> 03:27:23,760 space it here and then select this and 4667 03:27:20,800 --> 03:27:25,680 tab. And this time we're only going to 4668 03:27:23,760 --> 03:27:28,239 have two columns. So let's get rid of 4669 03:27:25,680 --> 03:27:31,439 this third column and let's only have 4670 03:27:28,239 --> 03:27:32,720 two divs here. 4671 03:27:31,439 --> 03:27:35,680 And we can also get rid of this 4672 03:27:32,720 --> 03:27:37,279 paragraph. 4673 03:27:35,680 --> 03:27:40,640 For this grid, we're going to have two 4674 03:27:37,279 --> 03:27:42,239 columns. The first one is 100 pixels and 4675 03:27:40,640 --> 03:27:47,520 the second one we're going to change it 4676 03:27:42,239 --> 03:27:50,080 to 1 FR. So FR is a special value in 4677 03:27:47,520 --> 03:27:52,399 grid that stands for free space. It 4678 03:27:50,080 --> 03:27:56,560 means to take up the remaining amount of 4679 03:27:52,399 --> 03:27:58,800 space on this grid. So if I save it, you 4680 03:27:56,560 --> 03:28:02,080 can see that the first column here is 4681 03:27:58,800 --> 03:28:04,160 100 pixels and the second column has a 4682 03:28:02,080 --> 03:28:06,720 width of 1 FR. So it takes up the 4683 03:28:04,160 --> 03:28:09,200 remaining amount of space that we have. 4684 03:28:06,720 --> 03:28:11,200 If I resize the page, it'll take up the 4685 03:28:09,200 --> 03:28:14,239 remaining amount of space. So that's 4686 03:28:11,200 --> 03:28:16,800 what 1 fr means. 4687 03:28:14,239 --> 03:28:18,800 I'm going to change this to 1 FR so that 4688 03:28:16,800 --> 03:28:20,960 it's easier to see when we review this 4689 03:28:18,800 --> 03:28:24,000 file. 4690 03:28:20,960 --> 03:28:26,640 So this FR value is exactly what we need 4691 03:28:24,000 --> 03:28:29,439 in our final design. If I open my final 4692 03:28:26,640 --> 03:28:31,920 design, you can see that we have a 4693 03:28:29,439 --> 03:28:34,640 horizontal layout here. The first column 4694 03:28:31,920 --> 03:28:36,560 is about 50 pixels and we want the 4695 03:28:34,640 --> 03:28:39,120 second column to take up the remaining 4696 03:28:36,560 --> 03:28:42,720 amount of space, which is exactly what 4697 03:28:39,120 --> 03:28:44,399 we need one FR for. Now before we go and 4698 03:28:42,720 --> 03:28:48,239 update our project, I'm going to show 4699 03:28:44,399 --> 03:28:51,600 you another property of this FR value. 4700 03:28:48,239 --> 03:28:53,200 Let's copy this div and create another 4701 03:28:51,600 --> 03:28:56,160 grid 4702 03:28:53,200 --> 03:28:58,720 below it. 4703 03:28:56,160 --> 03:29:02,560 And this time we're going to add a third 4704 03:28:58,720 --> 03:29:04,399 column that is also 1 FR. And we're 4705 03:29:02,560 --> 03:29:08,319 going to add another div to fill out 4706 03:29:04,399 --> 03:29:11,040 this third column. Let's copy this and 4707 03:29:08,319 --> 03:29:14,560 paste it into a third div. This one is 4708 03:29:11,040 --> 03:29:18,239 also going to be 1 FR. So let's save it 4709 03:29:14,560 --> 03:29:20,319 here. And for this example, the second 4710 03:29:18,239 --> 03:29:23,840 column and the third column both have 4711 03:29:20,319 --> 03:29:26,080 one FR. So one FR tells the columns to 4712 03:29:23,840 --> 03:29:28,560 take up the remaining amount of space. 4713 03:29:26,080 --> 03:29:30,640 And the number in front of it tells us 4714 03:29:28,560 --> 03:29:33,760 relatively how much of the remaining 4715 03:29:30,640 --> 03:29:35,920 space this column gets. Since in this 4716 03:29:33,760 --> 03:29:38,000 example both of them are one, they'll 4717 03:29:35,920 --> 03:29:41,279 get an equal amount of the remaining 4718 03:29:38,000 --> 03:29:43,920 space. So here these two are equal and 4719 03:29:41,279 --> 03:29:47,040 they take up the remaining space. If we 4720 03:29:43,920 --> 03:29:50,800 change the third column to 2 FR. So 4721 03:29:47,040 --> 03:29:52,479 let's change this to two FR and save. 4722 03:29:50,800 --> 03:29:54,640 The second and third column will take up 4723 03:29:52,479 --> 03:29:56,960 the remaining space. But the third 4724 03:29:54,640 --> 03:29:59,439 column will be twice as wide as the 4725 03:29:56,960 --> 03:30:02,239 second column. So this number here is 4726 03:29:59,439 --> 03:30:05,200 sort of like a ratio. This second column 4727 03:30:02,239 --> 03:30:07,600 will have 1/3 of the remaining space and 4728 03:30:05,200 --> 03:30:10,399 this third column will have 2/3 of the 4729 03:30:07,600 --> 03:30:12,319 remaining space. 4730 03:30:10,399 --> 03:30:14,399 Now that we understand that concept, 4731 03:30:12,319 --> 03:30:17,279 we're going to go back into our project 4732 03:30:14,399 --> 03:30:21,439 and use grids to create this horizontal 4733 03:30:17,279 --> 03:30:23,840 layout instead of inline block. 4734 03:30:21,439 --> 03:30:26,399 Let's go to our code 4735 03:30:23,840 --> 03:30:30,319 and we're going to scroll down into the 4736 03:30:26,399 --> 03:30:31,840 HTML for this which is right here. And 4737 03:30:30,319 --> 03:30:34,080 I'm going to collapse it so it's easier 4738 03:30:31,840 --> 03:30:37,600 to see. We have the channel picture and 4739 03:30:34,080 --> 03:30:39,439 the video info which is these two. So to 4740 03:30:37,600 --> 03:30:42,399 create a grid, remember we need to 4741 03:30:39,439 --> 03:30:46,479 create it on the container which is this 4742 03:30:42,399 --> 03:30:49,359 div. So let's set a class name of 4743 03:30:46,479 --> 03:30:51,279 video-info-grid 4744 03:30:49,359 --> 03:30:55,200 and then we'll target this class in our 4745 03:30:51,279 --> 03:30:56,960 CSS above. Going to scroll up 4746 03:30:55,200 --> 03:30:58,479 and I'm going to actually put it right 4747 03:30:56,960 --> 03:31:02,720 here. 4748 03:30:58,479 --> 03:31:04,720 video- info-g grid because this is right 4749 03:31:02,720 --> 03:31:07,279 above the channel picture and the video 4750 03:31:04,720 --> 03:31:10,000 info. So, it's beside other related 4751 03:31:07,279 --> 03:31:12,000 styles. 4752 03:31:10,000 --> 03:31:14,880 Now, remember to create a grid, we need 4753 03:31:12,000 --> 03:31:18,640 two steps. The first one is to set the 4754 03:31:14,880 --> 03:31:20,880 display property to grid. 4755 03:31:18,640 --> 03:31:24,479 This creates our grid. And then we need 4756 03:31:20,880 --> 03:31:28,160 to set how many columns our grid has. 4757 03:31:24,479 --> 03:31:29,840 So, we're going to set grid-template-c 4758 03:31:28,160 --> 03:31:32,399 columns. 4759 03:31:29,840 --> 03:31:35,279 And for our purposes, let's set a column 4760 03:31:32,399 --> 03:31:37,600 of 50 pixels for the channel profile 4761 03:31:35,279 --> 03:31:39,439 picture. 4762 03:31:37,600 --> 03:31:42,000 And then we want the second column to 4763 03:31:39,439 --> 03:31:46,160 take up the remaining amount of space. 4764 03:31:42,000 --> 03:31:47,760 So, as we learned that is one fr. 4765 03:31:46,160 --> 03:31:49,920 Now, if we save it, you'll notice that 4766 03:31:47,760 --> 03:31:52,720 the space between the inline blocks is 4767 03:31:49,920 --> 03:31:54,640 gone. So, unlike here. And you'll also 4768 03:31:52,720 --> 03:31:56,560 notice that these two are vertically 4769 03:31:54,640 --> 03:31:58,239 aligned. 4770 03:31:56,560 --> 03:32:00,080 So now that we have our grid, we can 4771 03:31:58,239 --> 03:32:02,000 actually remove all of these inline 4772 03:32:00,080 --> 03:32:04,640 block styles because we're not using 4773 03:32:02,000 --> 03:32:06,960 them anymore. So we can actually remove 4774 03:32:04,640 --> 03:32:10,080 all of these 4775 03:32:06,960 --> 03:32:12,960 and all of these. 4776 03:32:10,080 --> 03:32:15,279 Let's save it. And now let's set a grid 4777 03:32:12,960 --> 03:32:18,720 for the second video preview. We're 4778 03:32:15,279 --> 03:32:19,840 going to scroll down. 4779 03:32:18,720 --> 03:32:22,800 So remember, we're going to set the 4780 03:32:19,840 --> 03:32:24,720 styles on the container here. And then 4781 03:32:22,800 --> 03:32:26,720 these two divs are going to appear in 4782 03:32:24,720 --> 03:32:28,800 our grid. 4783 03:32:26,720 --> 03:32:31,600 So we've already created the CSS at the 4784 03:32:28,800 --> 03:32:35,600 top. We just need to set a class of 4785 03:32:31,600 --> 03:32:38,239 video- info- grid. 4786 03:32:35,600 --> 03:32:42,560 Save it. And then all the styles that we 4787 03:32:38,239 --> 03:32:44,560 wrote up here will target that class. So 4788 03:32:42,560 --> 03:32:46,479 now we have both of our grids. And you 4789 03:32:44,560 --> 03:32:48,399 can see our horizontal layout is 4790 03:32:46,479 --> 03:32:50,560 perfectly aligned with the rest of our 4791 03:32:48,399 --> 03:32:53,040 layout. And now we can remove this 4792 03:32:50,560 --> 03:32:56,160 background color. 4793 03:32:53,040 --> 03:32:57,200 And this part of the project is done. 4794 03:32:56,160 --> 03:32:59,840 The last thing we're going to learn 4795 03:32:57,200 --> 03:33:01,840 about grids is if we go to our final 4796 03:32:59,840 --> 03:33:05,840 design, we're going to learn how to 4797 03:33:01,840 --> 03:33:07,359 build a bigger grid like this. So notice 4798 03:33:05,840 --> 03:33:09,680 that there's a little bit of spacing 4799 03:33:07,359 --> 03:33:13,279 between the columns as well as between 4800 03:33:09,680 --> 03:33:15,520 the rows. Now before we start, you might 4801 03:33:13,279 --> 03:33:18,560 have a bigger screen and you might see 4802 03:33:15,520 --> 03:33:20,720 four videos in each row. So for now, 4803 03:33:18,560 --> 03:33:23,600 let's actually resize the browser so 4804 03:33:20,720 --> 03:33:25,439 that we see three videos in each row. So 4805 03:33:23,600 --> 03:33:27,920 I'm doing this because not everyone has 4806 03:33:25,439 --> 03:33:29,359 a big screen to work with and this will 4807 03:33:27,920 --> 03:33:30,880 make sure that everyone can follow 4808 03:33:29,359 --> 03:33:33,040 along. 4809 03:33:30,880 --> 03:33:34,960 So I'm going to zoom back in and just 4810 03:33:33,040 --> 03:33:36,479 make sure I have three videos in each 4811 03:33:34,960 --> 03:33:39,279 row. And we're going to learn how to 4812 03:33:36,479 --> 03:33:42,560 create this kind of layout. Let's go 4813 03:33:39,279 --> 03:33:45,200 into our grid practice file and we'll go 4814 03:33:42,560 --> 03:33:48,479 back into our code again and to our 4815 03:33:45,200 --> 03:33:49,840 grid.html file 4816 03:33:48,479 --> 03:33:53,279 and we're going to create another grid 4817 03:33:49,840 --> 03:33:57,640 to practice with. So let's copy this and 4818 03:33:53,279 --> 03:33:57,640 then just paste it down here. 4819 03:33:59,359 --> 03:34:04,800 And now for this example, let's look at 4820 03:34:01,760 --> 03:34:08,479 our final design. We essentially want 4821 03:34:04,800 --> 03:34:10,880 three columns of equal size. And when we 4822 03:34:08,479 --> 03:34:13,760 resize the page, notice that the columns 4823 03:34:10,880 --> 03:34:15,760 resize as well. So notice that if I 4824 03:34:13,760 --> 03:34:17,200 resize too much, it becomes two columns. 4825 03:34:15,760 --> 03:34:18,479 We're going to deal with this later in 4826 03:34:17,200 --> 03:34:20,080 the course. We're not going to deal with 4827 03:34:18,479 --> 03:34:22,880 that. We're just going to deal with 4828 03:34:20,080 --> 03:34:24,800 three columns that we have here. 4829 03:34:22,880 --> 03:34:29,359 So for this layout, we want something 4830 03:34:24,800 --> 03:34:31,439 like 1 FR, 1 FR, and 1 FR to divide the 4831 03:34:29,359 --> 03:34:34,239 space evenly. 4832 03:34:31,439 --> 03:34:36,800 Let's go into our file here, 4833 03:34:34,239 --> 03:34:41,359 and we're going to set three columns. 4834 03:34:36,800 --> 03:34:43,359 one FR, one FR, and one FR. So, this 4835 03:34:41,359 --> 03:34:45,920 will create three equal columns that 4836 03:34:43,359 --> 03:34:49,120 will resize with the page. Let's set 4837 03:34:45,920 --> 03:34:53,359 this to one FR as well, so that it's 4838 03:34:49,120 --> 03:34:55,200 clear what's going on. Let's save it. 4839 03:34:53,359 --> 03:34:58,479 And now we have the three columns we're 4840 03:34:55,200 --> 03:35:01,279 going to be working with. 4841 03:34:58,479 --> 03:35:03,120 Let's also set the height so that it 4842 03:35:01,279 --> 03:35:06,239 looks a little bit like our video 4843 03:35:03,120 --> 03:35:09,200 previews that we have here. 4844 03:35:06,239 --> 03:35:12,560 So, let's go into our HTML file and 4845 03:35:09,200 --> 03:35:15,520 we're going to set the height to 200 4846 03:35:12,560 --> 03:35:18,560 pixels. And let's also set the height of 4847 03:35:15,520 --> 03:35:22,399 these other columns as well. 200 pixels 4848 03:35:18,560 --> 03:35:24,000 and 200. Save it. Okay. So, that looks 4849 03:35:22,399 --> 03:35:26,000 pretty good, but they're a little bit 4850 03:35:24,000 --> 03:35:27,680 too much at the bottom of the page. 4851 03:35:26,000 --> 03:35:29,680 We're going to add some spacing at the 4852 03:35:27,680 --> 03:35:31,520 bottom of the website so that we can 4853 03:35:29,680 --> 03:35:34,640 scroll these up. 4854 03:35:31,520 --> 03:35:37,120 Let's go back up into our HTML and we're 4855 03:35:34,640 --> 03:35:38,960 going to scroll up to the body tag. 4856 03:35:37,120 --> 03:35:42,399 We're actually going to add some spacing 4857 03:35:38,960 --> 03:35:44,720 inside the bottom of the body tag. So 4858 03:35:42,399 --> 03:35:49,439 remember that spacing on the inside is 4859 03:35:44,720 --> 03:35:51,920 called padding. So padding-bottom. 4860 03:35:49,439 --> 03:35:54,720 And let's set it to something like a,000 4861 03:35:51,920 --> 03:35:56,800 pixels. So it's a lot easier for us to 4862 03:35:54,720 --> 03:35:58,800 practice. So now that we have a lot of 4863 03:35:56,800 --> 03:36:01,120 space at the bottom, we can scroll all 4864 03:35:58,800 --> 03:36:04,560 the way up. 4865 03:36:01,120 --> 03:36:07,680 and see our grid clearly. 4866 03:36:04,560 --> 03:36:09,680 So remember that in a grid if we have 4867 03:36:07,680 --> 03:36:11,600 more elements than we have columns, 4868 03:36:09,680 --> 03:36:14,640 it'll start wrapping around to the 4869 03:36:11,600 --> 03:36:17,600 second row. So all we have to do is add 4870 03:36:14,640 --> 03:36:20,640 three more divs. So we're just going to 4871 03:36:17,600 --> 03:36:25,040 let's actually copy the pink one first. 4872 03:36:20,640 --> 03:36:27,200 Let's copy it and paste it. 4873 03:36:25,040 --> 03:36:30,160 And then we'll add a blue and a pink at 4874 03:36:27,200 --> 03:36:33,120 the bottom. So let's copy 4875 03:36:30,160 --> 03:36:35,120 and paste it. So, we just need six divs 4876 03:36:33,120 --> 03:36:38,960 to work with that have alternating 4877 03:36:35,120 --> 03:36:40,720 colors like this. So, let's save it. And 4878 03:36:38,960 --> 03:36:42,960 now we essentially have our video 4879 03:36:40,720 --> 03:36:44,640 preview that we see here. And we're 4880 03:36:42,960 --> 03:36:47,600 going to learn how to create the space 4881 03:36:44,640 --> 03:36:49,680 between the columns and the rows. So, 4882 03:36:47,600 --> 03:36:53,120 it's actually really easy to create this 4883 03:36:49,680 --> 03:36:59,040 space. We just need two CSS properties. 4884 03:36:53,120 --> 03:37:00,560 The first one is called column dash gap. 4885 03:36:59,040 --> 03:37:03,040 So, it's pretty straightforward what 4886 03:37:00,560 --> 03:37:06,000 this means. We're setting some space or 4887 03:37:03,040 --> 03:37:08,640 a gap between the columns. So, let's set 4888 03:37:06,000 --> 03:37:11,680 a column gap of 20 pixels. Let's see how 4889 03:37:08,640 --> 03:37:14,239 that looks. Save it. 4890 03:37:11,680 --> 03:37:17,200 And now all of our columns have a gap 4891 03:37:14,239 --> 03:37:19,359 just like our final design here. 4892 03:37:17,200 --> 03:37:21,680 Next, we're going to set the space 4893 03:37:19,359 --> 03:37:22,960 between the rows. 4894 03:37:21,680 --> 03:37:25,439 And we have a similar and 4895 03:37:22,960 --> 03:37:27,840 straightforward property for that called 4896 03:37:25,439 --> 03:37:30,399 row dash gap. 4897 03:37:27,840 --> 03:37:31,920 And let's set this to something like 40 4898 03:37:30,399 --> 03:37:34,319 pixels. 4899 03:37:31,920 --> 03:37:38,080 Save it. And now we have space between 4900 03:37:34,319 --> 03:37:40,000 the rows just like our final design. 4901 03:37:38,080 --> 03:37:43,279 So that's how we create a grid like 4902 03:37:40,000 --> 03:37:45,120 this. First we define our three columns. 4903 03:37:43,279 --> 03:37:47,279 So in this case we want to divide it up 4904 03:37:45,120 --> 03:37:50,399 into three equal columns that resize 4905 03:37:47,279 --> 03:37:53,520 with the page. That's why we used 1 FR 1 4906 03:37:50,399 --> 03:37:55,439 FR 1 FR. And then we just add some space 4907 03:37:53,520 --> 03:37:57,840 between the columns using column gap 4908 03:37:55,439 --> 03:38:00,319 which creates this. And we add space 4909 03:37:57,840 --> 03:38:02,160 between the rows using row gap which 4910 03:38:00,319 --> 03:38:04,319 creates this. 4911 03:38:02,160 --> 03:38:06,080 Let's go back into our website we were 4912 03:38:04,319 --> 03:38:09,200 working on and we're going to apply 4913 03:38:06,080 --> 03:38:13,040 these skills to here. Let's go back 4914 03:38:09,200 --> 03:38:15,359 here. Going to scroll down and first of 4915 03:38:13,040 --> 03:38:18,319 all let's just create six of these video 4916 03:38:15,359 --> 03:38:21,920 previews so we can organize them into a 4917 03:38:18,319 --> 03:38:24,080 grid that looks like this. two rows and 4918 03:38:21,920 --> 03:38:26,880 three columns. So, we're going to go 4919 03:38:24,080 --> 03:38:29,520 into our code and we're going to copy 4920 03:38:26,880 --> 03:38:31,680 both of these 4921 03:38:29,520 --> 03:38:34,000 and we're just going to make duplicates. 4922 03:38:31,680 --> 03:38:37,680 So, copy it 4923 03:38:34,000 --> 03:38:39,600 and paste it. So, now if we save, we 4924 03:38:37,680 --> 03:38:43,040 have four and we're going to create two 4925 03:38:39,600 --> 03:38:47,960 more. So, paste it again. 4926 03:38:43,040 --> 03:38:47,960 Save. And now we have six. 4927 03:38:50,399 --> 03:38:55,439 So remember to create a grid we need a 4928 03:38:53,279 --> 03:38:58,319 container. So we need a container for 4929 03:38:55,439 --> 03:39:00,560 all of these video previews. So let's 4930 03:38:58,319 --> 03:39:03,840 create a div. And this is going to be 4931 03:39:00,560 --> 03:39:08,239 our container. We're going to call this 4932 03:39:03,840 --> 03:39:10,160 the video dash grid. 4933 03:39:08,239 --> 03:39:12,720 And now let's move all of these video 4934 03:39:10,160 --> 03:39:15,359 previews inside our new grid. Just going 4935 03:39:12,720 --> 03:39:21,160 to move all of them, 4936 03:39:15,359 --> 03:39:21,160 cut it, and paste it in here. 4937 03:39:21,439 --> 03:39:26,319 Let's save it. Scroll back up. 4938 03:39:24,479 --> 03:39:30,080 And now to create the grid, we want to 4939 03:39:26,319 --> 03:39:32,800 set styles on this container element. 4940 03:39:30,080 --> 03:39:35,520 So, let's go into our CSS. We're going 4941 03:39:32,800 --> 03:39:38,319 to target the video 4942 03:39:35,520 --> 03:39:40,640 dash grid. And remember, we have two 4943 03:39:38,319 --> 03:39:44,000 steps. The first step is to set the 4944 03:39:40,640 --> 03:39:46,560 display to grid. And the second step is 4945 03:39:44,000 --> 03:39:48,800 to set how many columns we have. 4946 03:39:46,560 --> 03:39:52,439 Grid-template 4947 03:39:48,800 --> 03:39:52,439 dash columns. 4948 03:39:53,200 --> 03:40:00,160 And for our example, we want three equal 4949 03:39:56,319 --> 03:40:07,359 columns that take up the entire space. 4950 03:40:00,160 --> 03:40:09,359 So let's set one FR, one FR, and one FR. 4951 03:40:07,359 --> 03:40:12,560 Now, if we look at our page, we now have 4952 03:40:09,359 --> 03:40:15,120 the three columns in our grid. But you 4953 03:40:12,560 --> 03:40:16,720 might notice that if I resize this down, 4954 03:40:15,120 --> 03:40:18,399 it actually doesn't resize with the 4955 03:40:16,720 --> 03:40:20,319 page. 4956 03:40:18,399 --> 03:40:23,279 So, the reason this happens is because 4957 03:40:20,319 --> 03:40:26,080 if we go and scroll up, 4958 03:40:23,279 --> 03:40:28,640 we set a width on the video preview, 4959 03:40:26,080 --> 03:40:31,359 which sort of forces the width to be 300 4960 03:40:28,640 --> 03:40:34,560 pixels. And earlier, we also set the 4961 03:40:31,359 --> 03:40:36,319 width of the thumbnail to 300. 4962 03:40:34,560 --> 03:40:38,720 So instead of setting the width like 4963 03:40:36,319 --> 03:40:40,160 this, which will force the width, we 4964 03:40:38,720 --> 03:40:42,640 actually just want these elements to 4965 03:40:40,160 --> 03:40:45,279 take up all the space in the columns 4966 03:40:42,640 --> 03:40:48,560 that they're inside of. So to do that, 4967 03:40:45,279 --> 03:40:51,680 we can remove this property here. 4968 03:40:48,560 --> 03:40:53,760 And let's save it. And for images, a 4969 03:40:51,680 --> 03:40:57,200 weird behavior is that they always keep 4970 03:40:53,760 --> 03:40:59,520 their original size. To get them to fit 4971 03:40:57,200 --> 03:41:02,160 inside their container or inside the 4972 03:40:59,520 --> 03:41:05,840 column of the grid, we have to set a 4973 03:41:02,160 --> 03:41:08,080 width of 100%. 4974 03:41:05,840 --> 03:41:10,720 Save it. And now they will only take up 4975 03:41:08,080 --> 03:41:12,880 100% of their container. 4976 03:41:10,720 --> 03:41:15,359 Now we also don't need the display block 4977 03:41:12,880 --> 03:41:18,560 here anymore. So this image is taking up 4978 03:41:15,359 --> 03:41:21,600 100%. It's already on its own line. So 4979 03:41:18,560 --> 03:41:24,319 display block is not necessary. So let's 4980 03:41:21,600 --> 03:41:27,439 delete that. And now we're going to deal 4981 03:41:24,319 --> 03:41:30,399 with this video preview width. For this, 4982 03:41:27,439 --> 03:41:33,120 we can just get rid of the width here 4983 03:41:30,399 --> 03:41:35,359 and the display inline block and also 4984 03:41:33,120 --> 03:41:38,319 vertical align which relates to inline 4985 03:41:35,359 --> 03:41:39,920 block. And we can get rid of the margin 4986 03:41:38,319 --> 03:41:42,239 since we're going to create this space 4987 03:41:39,920 --> 03:41:44,720 using the column gap property we learned 4988 03:41:42,239 --> 03:41:49,040 earlier. So let's just get rid of all of 4989 03:41:44,720 --> 03:41:51,279 these styles. And now if we save, 4990 03:41:49,040 --> 03:41:53,359 we can now see that our video previews 4991 03:41:51,279 --> 03:41:55,680 are fitting perfectly inside of our 4992 03:41:53,359 --> 03:41:57,920 grid. The final step is we're going to 4993 03:41:55,680 --> 03:42:01,520 add some space to the columns and to the 4994 03:41:57,920 --> 03:42:03,600 rows. So let's go into our CSS here. And 4995 03:42:01,520 --> 03:42:07,840 remember the two properties, they're 4996 03:42:03,600 --> 03:42:10,800 pretty straightforward. Our column- gap 4997 03:42:07,840 --> 03:42:14,160 and let's set a column gap of maybe 15 4998 03:42:10,800 --> 03:42:17,200 pixels. Save it. Okay, let's compare 4999 03:42:14,160 --> 03:42:19,680 that to our design. 5000 03:42:17,200 --> 03:42:21,840 And I'm going to resize it a little bit. 5001 03:42:19,680 --> 03:42:25,920 So I think this looks pretty close to 5002 03:42:21,840 --> 03:42:27,760 what we have. Maybe 16 pixels. 5003 03:42:25,920 --> 03:42:32,000 Okay. And then we're going to set a row 5004 03:42:27,760 --> 03:42:33,600 gap. Let's set a row dash gap of maybe 5005 03:42:32,000 --> 03:42:37,279 40. 5006 03:42:33,600 --> 03:42:39,359 Save it and compare it to our design. 5007 03:42:37,279 --> 03:42:41,920 So I think that looks pretty close to 5008 03:42:39,359 --> 03:42:43,439 what we have. Now, the design might look 5009 03:42:41,920 --> 03:42:45,439 a little bit smaller, and that's because 5010 03:42:43,439 --> 03:42:46,800 we have the sidebar here, but we're 5011 03:42:45,439 --> 03:42:48,479 going to deal with that in a later 5012 03:42:46,800 --> 03:42:52,000 lesson. 5013 03:42:48,479 --> 03:42:53,680 So, for now, this looks perfect. 5014 03:42:52,000 --> 03:42:55,840 The last thing we're going to do is to 5015 03:42:53,680 --> 03:42:58,000 swap out the thumbnails, the channel 5016 03:42:55,840 --> 03:43:00,800 profile pictures, as well as the rest of 5017 03:42:58,000 --> 03:43:02,720 the text to match our design. So, I'll 5018 03:43:00,800 --> 03:43:04,160 let you get some practice doing that. 5019 03:43:02,720 --> 03:43:05,680 Remember, you'll have to download the 5020 03:43:04,160 --> 03:43:07,680 thumbnail and the channel profile 5021 03:43:05,680 --> 03:43:09,760 picture first. 5022 03:43:07,680 --> 03:43:11,920 For now, let's just do six of these 5023 03:43:09,760 --> 03:43:14,960 videos and then we can add the rest of 5024 03:43:11,920 --> 03:43:17,120 them at the end of the course. 5025 03:43:14,960 --> 03:43:19,040 So, pause the video right now and swap 5026 03:43:17,120 --> 03:43:21,520 out all the thumbnails, the channel 5027 03:43:19,040 --> 03:43:25,479 pictures, and the text. And I'll see you 5028 03:43:21,520 --> 03:43:25,479 back after you've done that. 5029 03:43:26,000 --> 03:43:29,840 So, this is what it looks like after I 5030 03:43:27,920 --> 03:43:32,000 swapped everything out. So, that's the 5031 03:43:29,840 --> 03:43:34,239 end of this lesson. We learned about CSS 5032 03:43:32,000 --> 03:43:36,160 grid, which is a great way to create 5033 03:43:34,239 --> 03:43:38,640 these horizontal layouts that are 5034 03:43:36,160 --> 03:43:43,000 perfectly aligned and to create this 5035 03:43:38,640 --> 03:43:43,000 bigger grid that we see here. 5036 03:43:43,520 --> 03:43:49,080 Here's some exercises to get yourself 5037 03:43:45,279 --> 03:43:49,080 familiar with grids. 5038 03:44:02,000 --> 03:44:05,279 In this lesson, we're going to learn 5039 03:44:03,279 --> 03:44:07,279 about flexbox, which is another way to 5040 03:44:05,279 --> 03:44:09,680 create layouts. And we're going to use 5041 03:44:07,279 --> 03:44:12,880 flexbox to create the header at the top 5042 03:44:09,680 --> 03:44:15,520 of the page. So, flexbox is similar to 5043 03:44:12,880 --> 03:44:18,479 CSS grid. It can create the same kind of 5044 03:44:15,520 --> 03:44:20,239 layouts, but it's more flexible. 5045 03:44:18,479 --> 03:44:22,800 Just like the previous lesson, let's go 5046 03:44:20,239 --> 03:44:25,439 into our code and create a new file just 5047 03:44:22,800 --> 03:44:28,239 to practice flexbox. We're going to 5048 03:44:25,439 --> 03:44:32,760 create a new file by clicking this icon. 5049 03:44:28,239 --> 03:44:32,760 And let's call it flexbox.html. 5050 03:44:33,199 --> 03:44:37,040 And remember, we always start with the 5051 03:44:34,720 --> 03:44:41,040 HTML structure. We're going to have a 5052 03:44:37,040 --> 03:44:44,479 doc type at the top and then an HTML 5053 03:44:41,040 --> 03:44:48,160 element, a head element, 5054 03:44:44,479 --> 03:44:50,160 and a body element. 5055 03:44:48,160 --> 03:44:53,520 Let's save it. And now we can open this 5056 03:44:50,160 --> 03:44:57,239 in live server. So right click and open 5057 03:44:53,520 --> 03:44:57,239 with live server. 5058 03:44:57,840 --> 03:45:02,000 Now in this lesson we're also going to 5059 03:44:59,279 --> 03:45:04,479 compare flexbox to grid to show what the 5060 03:45:02,000 --> 03:45:06,880 similarities and differences are. So 5061 03:45:04,479 --> 03:45:09,359 we're also going to go into our code and 5062 03:45:06,880 --> 03:45:11,279 open the grid.html from the previous 5063 03:45:09,359 --> 03:45:14,080 lesson. And we're also going to open 5064 03:45:11,279 --> 03:45:17,960 this in live server. So rightclick and 5065 03:45:14,080 --> 03:45:17,960 open with the live server. 5066 03:45:18,319 --> 03:45:22,640 Just going to move these beside each 5067 03:45:19,680 --> 03:45:26,000 other and resize the page. And now we're 5068 03:45:22,640 --> 03:45:28,239 ready to begin. 5069 03:45:26,000 --> 03:45:30,399 So, we're going to start off in our 5070 03:45:28,239 --> 03:45:31,680 flexbox.html. 5071 03:45:30,399 --> 03:45:33,920 And first, we're going to go into the 5072 03:45:31,680 --> 03:45:35,920 head section and we're going to add a 5073 03:45:33,920 --> 03:45:38,399 title. 5074 03:45:35,920 --> 03:45:42,160 Let's call this flexbox 5075 03:45:38,399 --> 03:45:43,760 practice and then save. So, this is just 5076 03:45:42,160 --> 03:45:45,760 going to remind us that this file is for 5077 03:45:43,760 --> 03:45:48,239 flexbox practice and it's going to show 5078 03:45:45,760 --> 03:45:50,319 up here. Next, we're going to go into 5079 03:45:48,239 --> 03:45:52,000 the body and start creating some 5080 03:45:50,319 --> 03:45:53,439 flexboxes. 5081 03:45:52,000 --> 03:45:55,600 So, just like for grid, we're going to 5082 03:45:53,439 --> 03:45:57,120 create a div. 5083 03:45:55,600 --> 03:45:58,800 And inside, we're going to have two 5084 03:45:57,120 --> 03:46:02,960 divs. 5085 03:45:58,800 --> 03:46:05,960 So, div one and div 5086 03:46:02,960 --> 03:46:05,960 two. 5087 03:46:06,880 --> 03:46:12,560 So, we're going to use inline CSS again 5088 03:46:09,359 --> 03:46:15,040 just like we did for grid like here so 5089 03:46:12,560 --> 03:46:17,359 that we keep our CSS code close to our 5090 03:46:15,040 --> 03:46:18,720 HTML code and it'll be easier to 5091 03:46:17,359 --> 03:46:21,439 understand what's going on when we 5092 03:46:18,720 --> 03:46:24,800 review this file in the future. So, 5093 03:46:21,439 --> 03:46:26,479 inside our div, let's set a style. 5094 03:46:24,800 --> 03:46:28,479 And for this div, we're going to set the 5095 03:46:26,479 --> 03:46:32,720 background color 5096 03:46:28,479 --> 03:46:34,479 to light blue like before. 5097 03:46:32,720 --> 03:46:38,399 And then for the second div, we'll also 5098 03:46:34,479 --> 03:46:43,439 set it to light pink. So style equals 5099 03:46:38,399 --> 03:46:45,279 background dash color light pink. 5100 03:46:43,439 --> 03:46:47,359 Save it. 5101 03:46:45,279 --> 03:46:50,560 And now we have the two divs we can work 5102 03:46:47,359 --> 03:46:53,840 with. So just like with grid, flexbox 5103 03:46:50,560 --> 03:46:55,359 requires a container or this outer div. 5104 03:46:53,840 --> 03:46:57,520 This container is going to be the 5105 03:46:55,359 --> 03:47:00,640 flexbox and then these elements are 5106 03:46:57,520 --> 03:47:02,479 going to be placed into our flexbox. 5107 03:47:00,640 --> 03:47:05,279 So now let's learn how to turn our 5108 03:47:02,479 --> 03:47:08,000 container into a flexbox. 5109 03:47:05,279 --> 03:47:10,479 We're going to set a style here and 5110 03:47:08,000 --> 03:47:14,080 we're going to do two steps. The first 5111 03:47:10,479 --> 03:47:17,520 one is to set the display property to 5112 03:47:14,080 --> 03:47:19,920 flex. This creates a flexbox. And the 5113 03:47:17,520 --> 03:47:22,239 second step, we're going to set the flex 5114 03:47:19,920 --> 03:47:24,399 dash direction 5115 03:47:22,239 --> 03:47:25,920 to row. 5116 03:47:24,399 --> 03:47:28,560 This means we're going to align these 5117 03:47:25,920 --> 03:47:32,319 elements horizontally in a horizontal 5118 03:47:28,560 --> 03:47:35,920 layout. So now let's save this file and 5119 03:47:32,319 --> 03:47:38,720 we can see the effect that flexbox has. 5120 03:47:35,920 --> 03:47:40,800 So inside of flexbox, these divs which 5121 03:47:38,720 --> 03:47:43,279 are block elements don't behave like 5122 03:47:40,800 --> 03:47:45,600 block elements anymore. They behave more 5123 03:47:43,279 --> 03:47:48,000 like inline block elements. They only 5124 03:47:45,600 --> 03:47:49,920 take up as much horizontal space as they 5125 03:47:48,000 --> 03:47:53,040 need to. 5126 03:47:49,920 --> 03:47:55,040 Now compare that to grid where we first 5127 03:47:53,040 --> 03:47:57,279 set the columns and then the elements 5128 03:47:55,040 --> 03:48:00,239 went inside the columns. So the layout 5129 03:47:57,279 --> 03:48:02,880 is a little more rigid for grid. If we 5130 03:48:00,239 --> 03:48:05,520 go back to our flexbox, if we add some 5131 03:48:02,880 --> 03:48:09,120 more text to this first div 5132 03:48:05,520 --> 03:48:12,239 and save, notice that it expands to take 5133 03:48:09,120 --> 03:48:14,640 up as much space as it needs to. So this 5134 03:48:12,239 --> 03:48:16,800 is a flexible box and that's why we call 5135 03:48:14,640 --> 03:48:18,080 it flexbox. 5136 03:48:16,800 --> 03:48:20,080 Now, there's one other thing I want to 5137 03:48:18,080 --> 03:48:22,479 point out about flexbox is that if we 5138 03:48:20,080 --> 03:48:25,840 make this second div taller, just like 5139 03:48:22,479 --> 03:48:28,479 our grid example here, the flexbox will 5140 03:48:25,840 --> 03:48:31,920 be vertically aligned. Let's go into our 5141 03:48:28,479 --> 03:48:35,199 code and let's add a paragraph to make 5142 03:48:31,920 --> 03:48:37,120 this div taller. If I save it, you'll 5143 03:48:35,199 --> 03:48:40,239 see that it got taller, but we still 5144 03:48:37,120 --> 03:48:42,000 maintain vertical alignment. So, flexbox 5145 03:48:40,239 --> 03:48:44,239 is another way to create these 5146 03:48:42,000 --> 03:48:46,560 horizontal layouts while maintaining 5147 03:48:44,239 --> 03:48:48,000 alignment. 5148 03:48:46,560 --> 03:48:50,000 All right, let's go through some more 5149 03:48:48,000 --> 03:48:52,239 examples to see the similarities and 5150 03:48:50,000 --> 03:48:53,680 differences between flexbox and grid. 5151 03:48:52,239 --> 03:48:56,399 We'll start with these similarities 5152 03:48:53,680 --> 03:48:58,160 first. We'll go into our code and we're 5153 03:48:56,399 --> 03:49:01,120 going to create another flexbox to 5154 03:48:58,160 --> 03:49:04,000 practice with. So, we'll just copy this 5155 03:49:01,120 --> 03:49:06,720 and then paste it down here. 5156 03:49:04,000 --> 03:49:09,600 I'm going to select this and press tab. 5157 03:49:06,720 --> 03:49:11,520 I'll scroll down. 5158 03:49:09,600 --> 03:49:13,920 So, we'll also add some spacing to the 5159 03:49:11,520 --> 03:49:16,560 top of this because we want to make it 5160 03:49:13,920 --> 03:49:18,880 easier to separate. So, let's add some 5161 03:49:16,560 --> 03:49:22,399 margin-top 5162 03:49:18,880 --> 03:49:25,120 of 30 pixels. Save it. That looks pretty 5163 03:49:22,399 --> 03:49:28,000 good. And now for this first div, we're 5164 03:49:25,120 --> 03:49:30,239 going to set the width to 100 pixels. 5165 03:49:28,000 --> 03:49:32,399 So, I'm just going to organize my CSS a 5166 03:49:30,239 --> 03:49:37,199 little bit here. And we're going to set 5167 03:49:32,399 --> 03:49:40,160 the width to 100 pixels. And let's also 5168 03:49:37,199 --> 03:49:43,680 change the text to 100 pixels so that we 5169 03:49:40,160 --> 03:49:46,479 know what's going on. So let's save it. 5170 03:49:43,680 --> 03:49:49,840 So now our first flexbox element is 100 5171 03:49:46,479 --> 03:49:51,199 pixels wide. For the second div, we're 5172 03:49:49,840 --> 03:49:53,439 going to tell it to take up the 5173 03:49:51,199 --> 03:49:56,160 remaining amount of space. So if you 5174 03:49:53,439 --> 03:49:58,160 remember from grid, that's equivalent to 5175 03:49:56,160 --> 03:50:00,080 1 fr. We're going to learn how to do 5176 03:49:58,160 --> 03:50:02,720 that in flexbox. 5177 03:50:00,080 --> 03:50:06,000 So for this one in our code, we're going 5178 03:50:02,720 --> 03:50:07,840 to add a new style. 5179 03:50:06,000 --> 03:50:11,040 And we're going to add a style specific 5180 03:50:07,840 --> 03:50:14,080 to flexbox called flex. And we're going 5181 03:50:11,040 --> 03:50:18,960 to set this to one. And we're also going 5182 03:50:14,080 --> 03:50:22,720 to change this text here to flex 5183 03:50:18,960 --> 03:50:25,120 one. Let's save it. And now we can see 5184 03:50:22,720 --> 03:50:27,680 that flex one causes this div to take up 5185 03:50:25,120 --> 03:50:31,040 the remaining amount of space. So flex 5186 03:50:27,680 --> 03:50:33,680 one is the flexbox equivalent to 1 FR in 5187 03:50:31,040 --> 03:50:37,520 grid. So let's go through another 5188 03:50:33,680 --> 03:50:40,960 example. We're going to copy this and 5189 03:50:37,520 --> 03:50:42,720 then paste it again. 5190 03:50:40,960 --> 03:50:45,680 And for this example, we're going to add 5191 03:50:42,720 --> 03:50:48,319 another div to the bottom here. So let's 5192 03:50:45,680 --> 03:50:50,800 copy this first div. 5193 03:50:48,319 --> 03:50:53,520 Copy it and paste so that we have 5194 03:50:50,800 --> 03:50:57,040 alternating colors. And then we're going 5195 03:50:53,520 --> 03:51:01,760 to set the flex on the second div to 5196 03:50:57,040 --> 03:51:04,760 flex two. Let's change the text to flex 5197 03:51:01,760 --> 03:51:04,760 two. 5198 03:51:05,760 --> 03:51:12,000 So you can see that flex 2 is the 5199 03:51:07,600 --> 03:51:13,680 equivalent of 2 fr in grid. So two items 5200 03:51:12,000 --> 03:51:16,239 that both have flex are going to take up 5201 03:51:13,680 --> 03:51:18,319 the remaining amount of space. But this 5202 03:51:16,239 --> 03:51:21,359 number here tells us relatively how much 5203 03:51:18,319 --> 03:51:23,359 of the remaining space it takes. So this 5204 03:51:21,359 --> 03:51:25,600 element with flex 2 is going to take 5205 03:51:23,359 --> 03:51:28,239 twice the amount of the remaining space 5206 03:51:25,600 --> 03:51:30,399 as this element with flex one. So the 5207 03:51:28,239 --> 03:51:33,279 value here works the same as the value 5208 03:51:30,399 --> 03:51:34,720 with fr. 5209 03:51:33,279 --> 03:51:36,560 So you can see that the basic things 5210 03:51:34,720 --> 03:51:39,359 that we do with a grid we can also do 5211 03:51:36,560 --> 03:51:40,880 with flexbox. Now let's talk about the 5212 03:51:39,359 --> 03:51:43,920 differences. 5213 03:51:40,880 --> 03:51:47,120 So if we go to our grid examples and we 5214 03:51:43,920 --> 03:51:49,600 look at this example here, the layout is 5215 03:51:47,120 --> 03:51:51,520 more rigid for grid. 5216 03:51:49,600 --> 03:51:54,239 If we go into our grid code and we 5217 03:51:51,520 --> 03:51:58,239 scroll down to this example, 5218 03:51:54,239 --> 03:52:00,160 which is right here, 1 FR and two FR, 5219 03:51:58,239 --> 03:52:03,040 you'll see that we first define three 5220 03:52:00,160 --> 03:52:07,040 columns and then these elements go into 5221 03:52:03,040 --> 03:52:08,800 those columns. So if I move this element 5222 03:52:07,040 --> 03:52:12,560 to the second position. So I'm just 5223 03:52:08,800 --> 03:52:14,399 going to cut and move it down here. 5224 03:52:12,560 --> 03:52:16,479 This item is now going to go into the 5225 03:52:14,399 --> 03:52:19,520 second column and it's going to take up 5226 03:52:16,479 --> 03:52:22,640 one FR of space even though we wrote 100 5227 03:52:19,520 --> 03:52:25,359 pixels here. So if I save this, you'll 5228 03:52:22,640 --> 03:52:27,760 see that this one FR element goes into 5229 03:52:25,359 --> 03:52:30,479 the 100 pixel column. So it only takes 5230 03:52:27,760 --> 03:52:33,520 up 100 pixels of space and the layout 5231 03:52:30,479 --> 03:52:36,560 here is not changing for Flexbox. 5232 03:52:33,520 --> 03:52:39,760 However, if we go to our flexbox example 5233 03:52:36,560 --> 03:52:42,239 and our code, if we change the order of 5234 03:52:39,760 --> 03:52:45,600 the elements, so let's cut this and 5235 03:52:42,239 --> 03:52:48,319 paste it down here and save it. You'll 5236 03:52:45,600 --> 03:52:51,120 notice that the layout actually changes. 5237 03:52:48,319 --> 03:52:54,399 So, this element here actually keeps its 5238 03:52:51,120 --> 03:52:57,439 width of flex one and then the second 5239 03:52:54,399 --> 03:52:59,760 element keeps its width of 100 pixels. 5240 03:52:57,439 --> 03:53:02,080 So the elements take their width along 5241 03:52:59,760 --> 03:53:04,640 with them if they move around and that 5242 03:53:02,080 --> 03:53:06,960 causes us to have flexible layouts 5243 03:53:04,640 --> 03:53:10,239 depending on how many elements we have 5244 03:53:06,960 --> 03:53:12,239 and what order they're in. So that's the 5245 03:53:10,239 --> 03:53:13,760 biggest difference between flexbox and 5246 03:53:12,239 --> 03:53:15,760 grid. 5247 03:53:13,760 --> 03:53:18,560 So what's the advantage of having a 5248 03:53:15,760 --> 03:53:21,359 flexible layout like this? Let's go to 5249 03:53:18,560 --> 03:53:23,680 our final project and we're going to 5250 03:53:21,359 --> 03:53:26,000 resize the browser. And you'll notice 5251 03:53:23,680 --> 03:53:29,040 that in the header in the right section, 5252 03:53:26,000 --> 03:53:30,720 we have four icons or images. Now, we 5253 03:53:29,040 --> 03:53:33,279 could create this horizontal layout 5254 03:53:30,720 --> 03:53:35,199 using a grid. However, when we're logged 5255 03:53:33,279 --> 03:53:37,600 out of YouTube, you'll notice that we 5256 03:53:35,199 --> 03:53:39,359 only have three icons. So, the layout 5257 03:53:37,600 --> 03:53:42,000 actually changes because we only have 5258 03:53:39,359 --> 03:53:44,319 three elements now. So, this would be a 5259 03:53:42,000 --> 03:53:47,040 great situation to use flexbox instead 5260 03:53:44,319 --> 03:53:50,160 of grid when we want a flexible layout 5261 03:53:47,040 --> 03:53:52,239 dependent on our content. 5262 03:53:50,160 --> 03:53:54,319 So, that's the basics of how flexbox 5263 03:53:52,239 --> 03:53:56,960 works to create layouts and the main 5264 03:53:54,319 --> 03:53:58,560 difference between flexbox and grid. 5265 03:53:56,960 --> 03:54:00,560 We're going to go back to our practice 5266 03:53:58,560 --> 03:54:02,960 file and we're going to go through some 5267 03:54:00,560 --> 03:54:06,000 other examples of flexbox to help us 5268 03:54:02,960 --> 03:54:08,880 build the header of our final project. 5269 03:54:06,000 --> 03:54:11,520 So, first let's actually save this as it 5270 03:54:08,880 --> 03:54:13,840 is so that we get a reminder that the 5271 03:54:11,520 --> 03:54:15,840 layout is flexible. I'm going to change 5272 03:54:13,840 --> 03:54:18,160 this to light blue and the other one to 5273 03:54:15,840 --> 03:54:22,520 light pink so that we have alternating 5274 03:54:18,160 --> 03:54:22,520 colors and it's easier to see. 5275 03:54:25,680 --> 03:54:29,120 All right, let's go back into our grid 5276 03:54:27,199 --> 03:54:31,680 code and we're also going to move this 5277 03:54:29,120 --> 03:54:33,840 back into its original position. So, 5278 03:54:31,680 --> 03:54:36,479 just to remind us that for grid the 5279 03:54:33,840 --> 03:54:39,120 layout is more rigid. 5280 03:54:36,479 --> 03:54:41,680 Let's save it. And now we're back. So, 5281 03:54:39,120 --> 03:54:44,479 we'll go back to our flexbox file and 5282 03:54:41,680 --> 03:54:48,080 our flexbox html and we're going to do 5283 03:54:44,479 --> 03:54:50,080 another example. So, let's copy this 5284 03:54:48,080 --> 03:54:54,199 and we're going to create another 5285 03:54:50,080 --> 03:54:54,199 flexbox to practice with. 5286 03:54:55,520 --> 03:54:59,439 Now, for these next examples, we're 5287 03:54:57,600 --> 03:55:02,560 going to use them to learn how to create 5288 03:54:59,439 --> 03:55:04,000 the header up here. So, first, let's 5289 03:55:02,560 --> 03:55:07,040 create something that looks like the 5290 03:55:04,000 --> 03:55:09,600 header. We're going to create a box that 5291 03:55:07,040 --> 03:55:12,160 has the roughly the same shape. So, 5292 03:55:09,600 --> 03:55:13,840 we'll go into our file here and we're 5293 03:55:12,160 --> 03:55:17,120 going to make this flex box have the 5294 03:55:13,840 --> 03:55:21,439 same shape as a header. 5295 03:55:17,120 --> 03:55:23,840 So, let's set the height to 70 pixels. 5296 03:55:21,439 --> 03:55:26,640 And let's set a border so that we can 5297 03:55:23,840 --> 03:55:30,800 see the actual box. So, we're going to 5298 03:55:26,640 --> 03:55:34,640 set a border width of one pixel, a 5299 03:55:30,800 --> 03:55:38,640 border style of a solid color, and we'll 5300 03:55:34,640 --> 03:55:41,279 set the border color to gray. And when 5301 03:55:38,640 --> 03:55:43,920 we save it, we can now see our flexbox 5302 03:55:41,279 --> 03:55:45,520 using the border. I'm going to add a 5303 03:55:43,920 --> 03:55:47,279 little bit of spacing to the bottom of 5304 03:55:45,520 --> 03:55:49,520 the page here so that we can scroll this 5305 03:55:47,279 --> 03:55:52,880 up. So, remember to do that, we're going 5306 03:55:49,520 --> 03:55:56,479 to scroll up and add some padding to the 5307 03:55:52,880 --> 03:55:59,120 bottom of the body. 5308 03:55:56,479 --> 03:56:00,640 We're going to add a style to the body 5309 03:55:59,120 --> 03:56:07,479 and we're going to add some space to the 5310 03:56:00,640 --> 03:56:07,479 bottom. So, padding bottom 1,00 pixels. 5311 03:56:07,600 --> 03:56:11,840 And now we can scroll this flexbox up to 5312 03:56:10,080 --> 03:56:13,840 the top so that it's easier to work 5313 03:56:11,840 --> 03:56:15,359 with. 5314 03:56:13,840 --> 03:56:17,680 Now, let's scroll back down to the 5315 03:56:15,359 --> 03:56:20,479 example we were working with, which is 5316 03:56:17,680 --> 03:56:22,319 right here. 5317 03:56:20,479 --> 03:56:24,800 So, for each of these divs, let's change 5318 03:56:22,319 --> 03:56:28,720 the width to 100 pixels. So, I change 5319 03:56:24,800 --> 03:56:31,840 this one to 100 pixels. And let's also 5320 03:56:28,720 --> 03:56:34,319 change the text to 100 pixels 5321 03:56:31,840 --> 03:56:38,439 for this one's also 100 pixels. And the 5322 03:56:34,319 --> 03:56:38,439 third one to 100 pixels. 5323 03:56:40,880 --> 03:56:45,199 Now, let's save it. And we have our 5324 03:56:42,640 --> 03:56:49,199 three divs here. So, notice that these 5325 03:56:45,199 --> 03:56:50,960 three divs are aligned to the left side. 5326 03:56:49,199 --> 03:56:53,439 So, we can actually change how they are 5327 03:56:50,960 --> 03:56:55,920 aligned horizontally. To do that, we're 5328 03:56:53,439 --> 03:56:57,439 going to use a flexbox property called 5329 03:56:55,920 --> 03:56:59,600 justify-c 5330 03:56:57,439 --> 03:57:01,520 content. 5331 03:56:59,600 --> 03:57:04,479 So, this determines how these elements 5332 03:57:01,520 --> 03:57:07,600 are laid out horizontally. For example, 5333 03:57:04,479 --> 03:57:09,680 the default value is start. If we save 5334 03:57:07,600 --> 03:57:11,760 it, they'll be aligned to the start or 5335 03:57:09,680 --> 03:57:15,120 the left side. 5336 03:57:11,760 --> 03:57:17,680 If we change this to end, now they will 5337 03:57:15,120 --> 03:57:20,880 be aligned to the end or the right side. 5338 03:57:17,680 --> 03:57:22,880 We can also change this to center 5339 03:57:20,880 --> 03:57:25,520 to put all of our elements in the 5340 03:57:22,880 --> 03:57:26,880 center. So that's how we control how 5341 03:57:25,520 --> 03:57:28,640 these elements are positioned 5342 03:57:26,880 --> 03:57:29,600 horizontally. 5343 03:57:28,640 --> 03:57:31,600 We're going to go through another 5344 03:57:29,600 --> 03:57:34,160 example here. We're going to copy this 5345 03:57:31,600 --> 03:57:36,479 whole flexbox and we're going to create 5346 03:57:34,160 --> 03:57:40,680 another one below it. 5347 03:57:36,479 --> 03:57:40,680 Let's copy it and paste it. 5348 03:57:40,720 --> 03:57:46,080 And for this one, we're going to set a 5349 03:57:42,640 --> 03:57:49,479 special value of space 5350 03:57:46,080 --> 03:57:49,479 dash between. 5351 03:57:49,680 --> 03:57:53,760 So what space between does is that it 5352 03:57:51,680 --> 03:57:56,160 spreads out our elements evenly across 5353 03:57:53,760 --> 03:57:58,160 this horizontal space and it makes sure 5354 03:57:56,160 --> 03:58:00,880 that there's equal amount of space 5355 03:57:58,160 --> 03:58:02,880 between each element. 5356 03:58:00,880 --> 03:58:06,720 So this is really useful if we go back 5357 03:58:02,880 --> 03:58:09,520 to our header to spread out these four 5358 03:58:06,720 --> 03:58:11,120 icons evenly. 5359 03:58:09,520 --> 03:58:13,520 Now, the last example we're going to go 5360 03:58:11,120 --> 03:58:16,560 through for a flexbox 5361 03:58:13,520 --> 03:58:18,560 is how to align elements vertically. 5362 03:58:16,560 --> 03:58:20,720 So, let's copy this again and create 5363 03:58:18,560 --> 03:58:26,680 another flexbox. 5364 03:58:20,720 --> 03:58:26,680 So, let's copy this, paste it down here. 5365 03:58:28,399 --> 03:58:33,279 And for this one, we're going to set 5366 03:58:29,680 --> 03:58:34,800 another flexbox property called align- 5367 03:58:33,279 --> 03:58:36,720 items. 5368 03:58:34,800 --> 03:58:39,040 So, this determines how these elements 5369 03:58:36,720 --> 03:58:42,319 are aligned vertically. The default 5370 03:58:39,040 --> 03:58:44,080 value is stretch which you can see here. 5371 03:58:42,319 --> 03:58:46,479 The elements are stretching to fill up 5372 03:58:44,080 --> 03:58:49,040 the vertical space. But we also have 5373 03:58:46,479 --> 03:58:52,080 some options. We can align them to the 5374 03:58:49,040 --> 03:58:53,600 start. So they will no longer stretch to 5375 03:58:52,080 --> 03:58:55,439 the vertical space. They will just take 5376 03:58:53,600 --> 03:58:58,399 up as much vertical space as they need 5377 03:58:55,439 --> 03:59:01,520 to and they will be placed at the top. 5378 03:58:58,399 --> 03:59:03,120 Or we can put them at the end which will 5379 03:59:01,520 --> 03:59:04,720 place them at the bottom of the 5380 03:59:03,120 --> 03:59:09,199 container 5381 03:59:04,720 --> 03:59:10,800 and we can put them in the center. 5382 03:59:09,199 --> 03:59:13,279 which will place them vertically 5383 03:59:10,800 --> 03:59:15,120 centered. If we look at our final 5384 03:59:13,279 --> 03:59:16,560 project again, you'll notice that all of 5385 03:59:15,120 --> 03:59:19,120 these things in the header are 5386 03:59:16,560 --> 03:59:20,720 vertically centered. So now we learned 5387 03:59:19,120 --> 03:59:22,399 all these skills that we need and we're 5388 03:59:20,720 --> 03:59:24,399 ready to build the header for our 5389 03:59:22,399 --> 03:59:26,319 project. 5390 03:59:24,399 --> 03:59:29,840 Let's go to the code for our project we 5391 03:59:26,319 --> 03:59:31,680 were working on, which was YouTube.html. 5392 03:59:29,840 --> 03:59:34,479 And make sure you have this open in your 5393 03:59:31,680 --> 03:59:36,960 browser. 5394 03:59:34,479 --> 03:59:39,680 I'm going to resize the window here and 5395 03:59:36,960 --> 03:59:44,000 also the code editor so that it's easier 5396 03:59:39,680 --> 03:59:45,920 to see what's going on as we code. 5397 03:59:44,000 --> 03:59:48,640 We're first going to create an element 5398 03:59:45,920 --> 03:59:51,760 at the top to represent our header. So 5399 03:59:48,640 --> 03:59:54,399 let's scroll down and currently all we 5400 03:59:51,760 --> 03:59:57,680 have is this input. So we're going to 5401 03:59:54,399 --> 04:00:00,560 create a new div 5402 03:59:57,680 --> 04:00:02,960 and we're going to give it a class of 5403 04:00:00,560 --> 04:00:04,800 header. So this div is going to 5404 04:00:02,960 --> 04:00:07,199 represent the header in the final 5405 04:00:04,800 --> 04:00:09,439 project. 5406 04:00:07,199 --> 04:00:13,199 And now let's put our search bar into 5407 04:00:09,439 --> 04:00:16,840 our new header. So we'll cut this and 5408 04:00:13,199 --> 04:00:16,840 paste it in here. 5409 04:00:17,359 --> 04:00:22,800 Next, if we look at our final project, 5410 04:00:19,680 --> 04:00:24,960 the header has three sections. We have a 5411 04:00:22,800 --> 04:00:27,520 section on the left, a middle section 5412 04:00:24,960 --> 04:00:30,160 with a search bar, and the right section 5413 04:00:27,520 --> 04:00:31,680 here with some icons. 5414 04:00:30,160 --> 04:00:33,760 So, we're going to simplify this by 5415 04:00:31,680 --> 04:00:35,760 first creating these three sections and 5416 04:00:33,760 --> 04:00:37,680 then aligning them and then filling out 5417 04:00:35,760 --> 04:00:39,199 these sections with the appropriate 5418 04:00:37,680 --> 04:00:41,199 elements. 5419 04:00:39,199 --> 04:00:42,720 So, let's go back down here and we're 5420 04:00:41,199 --> 04:00:45,680 going to create three sections. So, 5421 04:00:42,720 --> 04:00:48,479 we'll just use three divs here. 5422 04:00:45,680 --> 04:00:51,520 So, let's call this class equals 5423 04:00:48,479 --> 04:00:54,000 left-ash section. 5424 04:00:51,520 --> 04:00:57,680 We'll create another div. We'll call it 5425 04:00:54,000 --> 04:01:00,479 class equals middle- section. 5426 04:00:57,680 --> 04:01:06,120 We'll create another div and we'll give 5427 04:01:00,479 --> 04:01:06,120 it a class of right dash section 5428 04:01:06,319 --> 04:01:10,319 and we'll put the search bar into the 5429 04:01:08,239 --> 04:01:13,560 middle section 5430 04:01:10,319 --> 04:01:13,560 right here. 5431 04:01:14,640 --> 04:01:20,680 And now let's style this div so that we 5432 04:01:16,720 --> 04:01:20,680 have roughly the same dimensions. 5433 04:01:21,439 --> 04:01:25,840 So before we do that, you'll notice that 5434 04:01:23,920 --> 04:01:28,000 we already have a lot of CSS code in 5435 04:01:25,840 --> 04:01:30,160 this file. And the best practice is 5436 04:01:28,000 --> 04:01:32,960 actually to put the CSS in a separate 5437 04:01:30,160 --> 04:01:35,120 file. So before we write even more CSS, 5438 04:01:32,960 --> 04:01:37,600 let's go ahead and put this into its own 5439 04:01:35,120 --> 04:01:40,720 CSS file. So we're actually going to 5440 04:01:37,600 --> 04:01:43,760 have multiple CSS files. One file for 5441 04:01:40,720 --> 04:01:47,040 styles of the video preview and another 5442 04:01:43,760 --> 04:01:49,199 for every style of the header. So let's 5443 04:01:47,040 --> 04:01:51,040 actually create a new folder first to 5444 04:01:49,199 --> 04:01:53,760 organize all of our different files of 5445 04:01:51,040 --> 04:01:56,640 CSS. So we'll create a new folder and 5446 04:01:53,760 --> 04:01:58,560 let's just call this styles. 5447 04:01:56,640 --> 04:02:00,640 Inside we're going to create two CSS 5448 04:01:58,560 --> 04:02:04,600 files. The first one is going to be 5449 04:02:00,640 --> 04:02:04,600 called video.css 5450 04:02:04,880 --> 04:02:10,120 and the second is going to be 5451 04:02:07,120 --> 04:02:10,120 header.css. 5452 04:02:10,640 --> 04:02:14,560 So first we're going to go into our 5453 04:02:12,720 --> 04:02:17,840 YouTube.html. 5454 04:02:14,560 --> 04:02:20,479 We're going to move all of this into the 5455 04:02:17,840 --> 04:02:24,880 video.css file. 5456 04:02:20,479 --> 04:02:26,640 So let's move this into here. 5457 04:02:24,880 --> 04:02:30,080 Now, all these styles for these videos 5458 04:02:26,640 --> 04:02:33,040 are separated into their own file. 5459 04:02:30,080 --> 04:02:34,800 Now, if I scroll up to the top here, 5460 04:02:33,040 --> 04:02:36,640 you'll notice we also have some styles 5461 04:02:34,800 --> 04:02:38,319 for the header. So, this actually 5462 04:02:36,640 --> 04:02:43,359 belongs in the header, and we're going 5463 04:02:38,319 --> 04:02:45,040 to move this into our header.css file. 5464 04:02:43,359 --> 04:02:48,160 So, we're grouping related styles 5465 04:02:45,040 --> 04:02:51,520 together to make it easier to read. Now, 5466 04:02:48,160 --> 04:02:53,520 for the top of this file, again, we have 5467 04:02:51,520 --> 04:02:55,279 this code that targets all paragraphs on 5468 04:02:53,520 --> 04:02:57,760 the page. So, this is not actually 5469 04:02:55,279 --> 04:03:00,640 specific to our videos. So, I'm actually 5470 04:02:57,760 --> 04:03:03,920 going to create another file 5471 04:03:00,640 --> 04:03:06,239 called general.css. 5472 04:03:03,920 --> 04:03:09,199 And that's going to contain all the 5473 04:03:06,239 --> 04:03:10,880 general CSS code like this, where we 5474 04:03:09,199 --> 04:03:14,640 target all paragraph elements on the 5475 04:03:10,880 --> 04:03:18,439 page. So, move this piece of code 5476 04:03:14,640 --> 04:03:18,439 into general. 5477 04:03:18,640 --> 04:03:23,439 So just like that, we have three CSS 5478 04:03:20,880 --> 04:03:26,720 files and they're all very focused on 5479 04:03:23,439 --> 04:03:28,720 one part of our web page. So this is 5480 04:03:26,720 --> 04:03:30,880 generally what we want to do. We want to 5481 04:03:28,720 --> 04:03:32,880 organize our code and separate them into 5482 04:03:30,880 --> 04:03:35,120 different files depending on what the 5483 04:03:32,880 --> 04:03:37,359 code does. 5484 04:03:35,120 --> 04:03:40,000 Next, we're going to go into our HTML 5485 04:03:37,359 --> 04:03:43,120 file. And we can remove this. And let's 5486 04:03:40,000 --> 04:03:44,640 save it. 5487 04:03:43,120 --> 04:03:47,040 But now you can see that all of these 5488 04:03:44,640 --> 04:03:50,239 styles that we had are gone. So we need 5489 04:03:47,040 --> 04:03:52,399 to link them back into our HTML. 5490 04:03:50,239 --> 04:03:54,160 To do that, we're going to create a link 5491 04:03:52,399 --> 04:03:56,800 element. 5492 04:03:54,160 --> 04:03:58,399 We'll have an attribute of re which 5493 04:03:56,800 --> 04:04:00,720 tells it what we're linking. So we're 5494 04:03:58,399 --> 04:04:05,520 linking a stylesheet. And we also tell 5495 04:04:00,720 --> 04:04:08,399 it what file we're linking with href. 5496 04:04:05,520 --> 04:04:10,399 So here beside our HTML file, we have a 5497 04:04:08,399 --> 04:04:12,720 styles folder. So, we're going to first 5498 04:04:10,399 --> 04:04:14,960 link the styles folder, and then we're 5499 04:04:12,720 --> 04:04:18,359 going to type a slash to go into it and 5500 04:04:14,960 --> 04:04:18,359 link general.css. 5501 04:04:19,359 --> 04:04:23,439 And now we're going to link our other 5502 04:04:20,880 --> 04:04:26,720 two CSS files. So, to do that, we just 5503 04:04:23,439 --> 04:04:31,359 need to copy and paste this. 5504 04:04:26,720 --> 04:04:32,479 And then we're going to link header.css. 5505 04:04:31,359 --> 04:04:36,000 And for the third one, we're going to 5506 04:04:32,479 --> 04:04:38,160 link video.css. 5507 04:04:36,000 --> 04:04:40,479 And if we save it, we linked all of our 5508 04:04:38,160 --> 04:04:43,199 code in three separate files and we're 5509 04:04:40,479 --> 04:04:45,439 back to where we were. 5510 04:04:43,199 --> 04:04:47,600 Next, let's focus on our header styles 5511 04:04:45,439 --> 04:04:50,399 and create our header. We're going to go 5512 04:04:47,600 --> 04:04:53,040 into this file and we actually don't 5513 04:04:50,399 --> 04:04:55,040 need this display block anymore. So, we 5514 04:04:53,040 --> 04:04:57,520 use this to put the search bar on a 5515 04:04:55,040 --> 04:04:59,760 separate line, but now the search bar is 5516 04:04:57,520 --> 04:05:03,279 inside a bunch of divs. So, the divs 5517 04:04:59,760 --> 04:05:04,960 will create that separate line for us. 5518 04:05:03,279 --> 04:05:06,560 Now the one other thing that we had to 5519 04:05:04,960 --> 04:05:09,439 do is that notice that there is some 5520 04:05:06,560 --> 04:05:13,040 spacing on the left side on the right 5521 04:05:09,439 --> 04:05:15,279 side and at the top. So by default if we 5522 04:05:13,040 --> 04:05:18,080 right click and inspect 5523 04:05:15,279 --> 04:05:20,560 and we look at the body. So the body 5524 04:05:18,080 --> 04:05:23,040 element has 8 pixels of margin on every 5525 04:05:20,560 --> 04:05:24,960 side by default. 5526 04:05:23,040 --> 04:05:26,960 Now to get a more precise design we 5527 04:05:24,960 --> 04:05:28,479 actually want to set this to zero. So 5528 04:05:26,960 --> 04:05:31,920 we're going to reset these default 5529 04:05:28,479 --> 04:05:33,680 styles. So, we'll go into our CSS code 5530 04:05:31,920 --> 04:05:35,279 and we're going to go into the general 5531 04:05:33,680 --> 04:05:37,760 file 5532 04:05:35,279 --> 04:05:39,760 and we're going to target the body and 5533 04:05:37,760 --> 04:05:41,760 we're going to get rid of all margins. 5534 04:05:39,760 --> 04:05:43,760 An easier way to do this is to set the 5535 04:05:41,760 --> 04:05:45,920 margin property 5536 04:05:43,760 --> 04:05:48,479 and set it to zero. So, this will set 5537 04:05:45,920 --> 04:05:50,800 all margins in all directions to zero. 5538 04:05:48,479 --> 04:05:53,520 Let's save it. And now our elements are 5539 04:05:50,800 --> 04:05:56,399 right up to the edge of the page. 5540 04:05:53,520 --> 04:05:59,199 Next, we're going to work on our header. 5541 04:05:56,399 --> 04:06:01,279 So, I'm actually going to make this 5542 04:05:59,199 --> 04:06:03,680 wider so that we can have both of these 5543 04:06:01,279 --> 04:06:06,239 files on each side. We're going to have 5544 04:06:03,680 --> 04:06:08,399 the HTML on the left and the CSS on the 5545 04:06:06,239 --> 04:06:09,920 right. So, the first thing we'll do is 5546 04:06:08,399 --> 04:06:12,080 we're going to add a height to this 5547 04:06:09,920 --> 04:06:15,439 header so that it looks like our design 5548 04:06:12,080 --> 04:06:17,920 here. So, let's go into our header CSS 5549 04:06:15,439 --> 04:06:21,439 file. And remember, we set a class of 5550 04:06:17,920 --> 04:06:23,120 header. So, we'll target that using dot 5551 04:06:21,439 --> 04:06:26,160 header. 5552 04:06:23,120 --> 04:06:28,239 and we'll set a height of maybe 40 5553 04:06:26,160 --> 04:06:29,840 pixels. 5554 04:06:28,239 --> 04:06:31,520 Okay, so let's compare that to our 5555 04:06:29,840 --> 04:06:34,239 design. 5556 04:06:31,520 --> 04:06:39,120 Looks like our design is a lot taller. 5557 04:06:34,239 --> 04:06:41,680 Let's change it to maybe 55 pixels. 5558 04:06:39,120 --> 04:06:43,439 Let's compare that. So, I'm just 5559 04:06:41,680 --> 04:06:48,239 comparing this to the bottom edge of 5560 04:06:43,439 --> 04:06:50,080 here. And that looks pretty good. 5561 04:06:48,239 --> 04:06:52,000 So, next we're going to position these 5562 04:06:50,080 --> 04:06:56,239 three sections. the left section, the 5563 04:06:52,000 --> 04:06:59,199 middle section, and the right section. 5564 04:06:56,239 --> 04:07:01,279 So, in our code, uh we can't actually 5565 04:06:59,199 --> 04:07:03,279 see the sections right now because they 5566 04:07:01,279 --> 04:07:06,960 don't have any content in them. Let's 5567 04:07:03,279 --> 04:07:10,000 just call this the left section. And 5568 04:07:06,960 --> 04:07:13,199 then add the text here as well, 5569 04:07:10,000 --> 04:07:15,439 the right section. 5570 04:07:13,199 --> 04:07:16,800 Save it. And now we have these three. 5571 04:07:15,439 --> 04:07:18,880 However, you'll notice that they're 5572 04:07:16,800 --> 04:07:20,800 being aligned vertically. And that's 5573 04:07:18,880 --> 04:07:23,359 because divs by default are display 5574 04:07:20,800 --> 04:07:25,439 block and we haven't made this into a 5575 04:07:23,359 --> 04:07:27,520 flexbox yet. 5576 04:07:25,439 --> 04:07:29,520 So to create a horizontal layout, we're 5577 04:07:27,520 --> 04:07:32,479 going to turn our header container here 5578 04:07:29,520 --> 04:07:35,760 into a flexbox. We're going to set the 5579 04:07:32,479 --> 04:07:37,600 display to flex. 5580 04:07:35,760 --> 04:07:39,920 And we're also going to set the flex 5581 04:07:37,600 --> 04:07:43,279 dash direction 5582 04:07:39,920 --> 04:07:46,399 to row to lay them out horizontally. So 5583 04:07:43,279 --> 04:07:48,880 let's save. And now our sections only 5584 04:07:46,399 --> 04:07:51,920 take up as much space as we need to, as 5585 04:07:48,880 --> 04:07:53,439 we saw in our examples. 5586 04:07:51,920 --> 04:07:56,479 Next, let's give these a background 5587 04:07:53,439 --> 04:07:58,479 color so it's easier to see them. So for 5588 04:07:56,479 --> 04:08:02,800 the left section, we're going to target 5589 04:07:58,479 --> 04:08:05,840 it and we'll set a background dash color 5590 04:08:02,800 --> 04:08:09,960 of light blue. 5591 04:08:05,840 --> 04:08:09,960 And for the middle section, 5592 04:08:10,080 --> 04:08:14,800 we'll set a background color of light 5593 04:08:13,040 --> 04:08:16,239 pink. 5594 04:08:14,800 --> 04:08:20,479 And for the right section, we're going 5595 04:08:16,239 --> 04:08:22,560 to set a background color of light blue. 5596 04:08:20,479 --> 04:08:26,399 Right section 5597 04:08:22,560 --> 04:08:29,359 background color of light 5598 04:08:26,399 --> 04:08:32,800 blue. 5599 04:08:29,359 --> 04:08:35,120 So now, how do we create this layout? So 5600 04:08:32,800 --> 04:08:37,760 let's analyze it a little bit. If we 5601 04:08:35,120 --> 04:08:41,439 resize the page, notice that this middle 5602 04:08:37,760 --> 04:08:43,279 section is also resizing. 5603 04:08:41,439 --> 04:08:45,840 So to achieve this, we're going to use a 5604 04:08:43,279 --> 04:08:48,160 property called flex. So if you recall 5605 04:08:45,840 --> 04:08:50,560 in our examples, flex takes up the 5606 04:08:48,160 --> 04:08:52,239 remaining amount of space. 5607 04:08:50,560 --> 04:08:55,120 So if I look at the header in our final 5608 04:08:52,239 --> 04:08:57,760 project, when I resize, this right 5609 04:08:55,120 --> 04:09:00,080 section is not changing its width and 5610 04:08:57,760 --> 04:09:02,319 neither is the left section. So these 5611 04:09:00,080 --> 04:09:05,279 will have a predefined width and then 5612 04:09:02,319 --> 04:09:07,359 this will be flex because as you can see 5613 04:09:05,279 --> 04:09:09,279 it's growing as the page is being 5614 04:09:07,359 --> 04:09:11,120 resized. 5615 04:09:09,279 --> 04:09:13,120 So that's an example of how to analyze 5616 04:09:11,120 --> 04:09:15,279 these layouts. Don't worry, you'll get 5617 04:09:13,120 --> 04:09:17,920 better with more practice. For now, 5618 04:09:15,279 --> 04:09:20,000 we're going to do this example together. 5619 04:09:17,920 --> 04:09:23,199 On the left section, we're going to set 5620 04:09:20,000 --> 04:09:26,239 a fixed width. Let's set this to maybe 5621 04:09:23,199 --> 04:09:28,720 200 pixels. See how that looks. We'll 5622 04:09:26,239 --> 04:09:30,319 compare it to our design. So, it's 5623 04:09:28,720 --> 04:09:33,359 actually a little too much. I want it to 5624 04:09:30,319 --> 04:09:35,199 end right here after the YouTube logo. 5625 04:09:33,359 --> 04:09:38,800 So, we're going to go back and let's 5626 04:09:35,199 --> 04:09:40,800 change this to 150 pixels. 5627 04:09:38,800 --> 04:09:43,120 And let's compare it. So, that looks 5628 04:09:40,800 --> 04:09:44,880 pretty close. 5629 04:09:43,120 --> 04:09:47,439 For this middle section, we want it to 5630 04:09:44,880 --> 04:09:51,680 stretch. So, remember the property to do 5631 04:09:47,439 --> 04:09:53,439 that is called flex one. So, now the 5632 04:09:51,680 --> 04:09:55,520 middle section is stretching. And for 5633 04:09:53,439 --> 04:09:58,239 the right section, we also want a fixed 5634 04:09:55,520 --> 04:10:00,960 width. So, let's compare it. We want it 5635 04:09:58,239 --> 04:10:05,120 to be somewhere here. Let's try setting 5636 04:10:00,960 --> 04:10:08,000 a width of 200 pixels. 5637 04:10:05,120 --> 04:10:10,880 And then let's compare these two. Okay. 5638 04:10:08,000 --> 04:10:13,439 So, I think this is pretty close to the 5639 04:10:10,880 --> 04:10:14,800 structure that we have here. 5640 04:10:13,439 --> 04:10:17,439 So, what we're doing is we're just 5641 04:10:14,800 --> 04:10:19,279 simplifying the structure into the 5642 04:10:17,439 --> 04:10:23,080 bigger picture and then we'll go in and 5643 04:10:19,279 --> 04:10:23,080 add these smaller details. 5644 04:10:23,439 --> 04:10:27,840 Now, we're going to set some spacing on 5645 04:10:25,520 --> 04:10:29,920 the left and the right side of this 5646 04:10:27,840 --> 04:10:32,239 middle section. So, remember to do that, 5647 04:10:29,920 --> 04:10:36,080 we're going to set our margins. So, on 5648 04:10:32,239 --> 04:10:41,600 the left side, let's set a margin- 5649 04:10:36,080 --> 04:10:43,439 leftft of maybe 30 pixels. Save it and 5650 04:10:41,600 --> 04:10:46,720 let's compare. So, it's definitely more 5651 04:10:43,439 --> 04:10:50,239 than 30 pixels. Let's change it to maybe 5652 04:10:46,720 --> 04:10:53,279 70 pixels. Save it and compare. So this 5653 04:10:50,239 --> 04:10:55,279 compared to this, I think that's close 5654 04:10:53,279 --> 04:10:57,040 enough. 5655 04:10:55,279 --> 04:10:58,960 So now for the right section, we're also 5656 04:10:57,040 --> 04:11:01,199 going to add a little bit of space. So 5657 04:10:58,960 --> 04:11:03,520 if we look at our design, so it's less 5658 04:11:01,199 --> 04:11:06,720 space than we have here. So we're going 5659 04:11:03,520 --> 04:11:09,960 to add a margin to the right of the 5660 04:11:06,720 --> 04:11:09,960 middle section. 5661 04:11:10,080 --> 04:11:15,600 And we'll set it to maybe 30 pixels. 5662 04:11:13,760 --> 04:11:17,840 Save it. 5663 04:11:15,600 --> 04:11:21,760 And that looks pretty close to what we 5664 04:11:17,840 --> 04:11:24,560 have here. maybe 35 pixels. 5665 04:11:21,760 --> 04:11:26,720 Okay. 5666 04:11:24,560 --> 04:11:28,319 So now if we resize our page, you'll 5667 04:11:26,720 --> 04:11:30,560 notice that the middle section is 5668 04:11:28,319 --> 04:11:32,160 growing and shrinking with the page and 5669 04:11:30,560 --> 04:11:34,720 the right and left are staying the same 5670 04:11:32,160 --> 04:11:36,640 width, which is exactly what we have 5671 04:11:34,720 --> 04:11:38,000 here. 5672 04:11:36,640 --> 04:11:40,319 So there's one other detail we're going 5673 04:11:38,000 --> 04:11:42,720 to copy for this middle section. Notice 5674 04:11:40,319 --> 04:11:45,199 that if I resize the browser and make it 5675 04:11:42,720 --> 04:11:47,520 wider, at some point the middle section 5676 04:11:45,199 --> 04:11:49,840 stops growing. So, at roughly this 5677 04:11:47,520 --> 04:11:52,640 point, the middle section will stop 5678 04:11:49,840 --> 04:11:54,319 growing if the browser gets wider and it 5679 04:11:52,640 --> 04:11:56,479 just keeps the same width and is 5680 04:11:54,319 --> 04:11:58,640 centered horizontally. We're going to 5681 04:11:56,479 --> 04:12:01,120 learn how to do that. Let's go back into 5682 04:11:58,640 --> 04:12:03,680 our project and we're going to limit the 5683 04:12:01,120 --> 04:12:06,399 width of this middle section first. So, 5684 04:12:03,680 --> 04:12:11,439 we'll go into our code and the property 5685 04:12:06,399 --> 04:12:14,960 to do that is called max dash width 5686 04:12:11,439 --> 04:12:17,199 and let's set it to 300 pixels. 5687 04:12:14,960 --> 04:12:19,600 So this property says the width can be 5688 04:12:17,199 --> 04:12:21,920 less than 300 pixels, but as soon as it 5689 04:12:19,600 --> 04:12:24,640 grows to be over 300 pixels, we're going 5690 04:12:21,920 --> 04:12:26,800 to limit it to 300. So that's what we 5691 04:12:24,640 --> 04:12:29,680 see here. Now, when we resize the 5692 04:12:26,800 --> 04:12:31,279 browser to be less than 300 pixels, 5693 04:12:29,680 --> 04:12:34,239 notice that it's shrinking and growing 5694 04:12:31,279 --> 04:12:36,800 again. But when the browser gets wider, 5695 04:12:34,239 --> 04:12:39,760 it's limited to 300 pixels because of 5696 04:12:36,800 --> 04:12:41,680 this line of code. 5697 04:12:39,760 --> 04:12:44,319 Next, we want to distribute these three 5698 04:12:41,680 --> 04:12:47,760 sections evenly across our horizontal 5699 04:12:44,319 --> 04:12:51,279 space. So, just like what we have here. 5700 04:12:47,760 --> 04:12:54,479 Now, remember to do that in flexbox, 5701 04:12:51,279 --> 04:12:57,840 we have an example here. If we go back 5702 04:12:54,479 --> 04:13:00,399 into our code and go into our flexbox 5703 04:12:57,840 --> 04:13:02,880 practice file, 5704 04:13:00,399 --> 04:13:06,159 we can find that example in our code. 5705 04:13:02,880 --> 04:13:09,279 And remember that we achieved this using 5706 04:13:06,159 --> 04:13:11,760 a property called justify content space 5707 04:13:09,279 --> 04:13:14,159 between and we set this property on our 5708 04:13:11,760 --> 04:13:16,720 flexbox container. And that's what we're 5709 04:13:14,159 --> 04:13:18,800 going to do for our project right now. 5710 04:13:16,720 --> 04:13:20,880 So we're going to go up to our flexbox 5711 04:13:18,800 --> 04:13:23,279 container. Let's go back to our 5712 04:13:20,880 --> 04:13:25,359 YouTube.html. 5713 04:13:23,279 --> 04:13:28,080 And to spread these out evenly across 5714 04:13:25,359 --> 04:13:30,560 the entire horizontal space, we're going 5715 04:13:28,080 --> 04:13:35,040 to set justify 5716 04:13:30,560 --> 04:13:38,080 content space dash between. 5717 04:13:35,040 --> 04:13:40,800 Let's save it. And now they take up the 5718 04:13:38,080 --> 04:13:42,560 entire space. So if we compare this to 5719 04:13:40,800 --> 04:13:44,560 our design, 5720 04:13:42,560 --> 04:13:46,319 uh we'll notice that the middle section 5721 04:13:44,560 --> 04:13:48,640 is still a little bit too narrow 5722 04:13:46,319 --> 04:13:50,880 compared to our design. 5723 04:13:48,640 --> 04:13:53,680 So let's increase the max width here. 5724 04:13:50,880 --> 04:13:55,760 So, let's increase it to 400 pixels. See 5725 04:13:53,680 --> 04:13:58,319 how that looks. 5726 04:13:55,760 --> 04:14:02,080 Okay, so it's still bigger. Let's 5727 04:13:58,319 --> 04:14:04,399 increase it to 500 pixels. 5728 04:14:02,080 --> 04:14:07,600 See how that looks. Okay, so I think 5729 04:14:04,399 --> 04:14:10,080 that looks close enough to our design. 5730 04:14:07,600 --> 04:14:12,560 So, this middle section in pink is 5731 04:14:10,080 --> 04:14:14,800 roughly equal to this middle section 5732 04:14:12,560 --> 04:14:16,720 over here. 5733 04:14:14,800 --> 04:14:18,800 So, that's the end of this lesson. We 5734 04:14:16,720 --> 04:14:21,760 learned about flexbox and we used it to 5735 04:14:18,800 --> 04:14:23,600 create the layout for our header. So in 5736 04:14:21,760 --> 04:14:26,000 this situation, we were mostly focused 5737 04:14:23,600 --> 04:14:28,640 on our content size. We wanted to make 5738 04:14:26,000 --> 04:14:31,279 sure the middle section had a max width 5739 04:14:28,640 --> 04:14:33,600 and at least some space in between. So 5740 04:14:31,279 --> 04:14:36,000 that's why we used a flexbox because we 5741 04:14:33,600 --> 04:14:37,840 were focused on our content size first 5742 04:14:36,000 --> 04:14:40,239 and then the layout doesn't matter as 5743 04:14:37,840 --> 04:14:42,479 much. We just use a flexbox to spread 5744 04:14:40,239 --> 04:14:45,359 out our content evenly across the 5745 04:14:42,479 --> 04:14:48,399 horizontal space. So when we focus on 5746 04:14:45,359 --> 04:14:50,399 content size first, we use a flexbox. 5747 04:14:48,399 --> 04:14:53,040 When we want to create a grid, we use 5748 04:14:50,399 --> 04:14:55,199 grid. And for most other situations, for 5749 04:14:53,040 --> 04:14:57,359 example, this horizontal layout that we 5750 04:14:55,199 --> 04:15:00,080 created in the nested layouts technique, 5751 04:14:57,359 --> 04:15:04,760 we can use either grid or flexbox. In 5752 04:15:00,080 --> 04:15:04,760 most situations, they do the same thing. 5753 04:15:06,319 --> 04:15:10,560 So here are some exercises that you can 5754 04:15:08,159 --> 04:15:14,880 practice using flexbox to get yourself 5755 04:15:10,560 --> 04:15:14,880 more familiar with how it works. 5756 04:15:24,720 --> 04:15:28,239 And now that we have the general layout, 5757 04:15:26,560 --> 04:15:30,479 we're going to finish up the rest of the 5758 04:15:28,239 --> 04:15:32,720 header. Before we do that, we're going 5759 04:15:30,479 --> 04:15:35,120 to download all of these icons and 5760 04:15:32,720 --> 04:15:38,720 images that you see here. To do that, 5761 04:15:35,120 --> 04:15:41,359 we're going to rightclick, inspect, and 5762 04:15:38,720 --> 04:15:43,439 then click this in the top left, and 5763 04:15:41,359 --> 04:15:45,920 then click the icon we want to download, 5764 04:15:43,439 --> 04:15:48,159 and then we can find the URL down here. 5765 04:15:45,920 --> 04:15:50,800 I'm going to hover over it, and then 5766 04:15:48,159 --> 04:15:54,080 click this link to open in a new tab, 5767 04:15:50,800 --> 04:15:56,000 and then save it with Ctrl S. So, I'm 5768 04:15:54,080 --> 04:15:59,520 going to save this in the folder that 5769 04:15:56,000 --> 04:16:01,840 contains our code, which is this one. 5770 04:15:59,520 --> 04:16:03,920 So, I'm going to save it. And then in 5771 04:16:01,840 --> 04:16:06,640 our code editor, we should see this 5772 04:16:03,920 --> 04:16:09,439 icon. So we can collapse this by 5773 04:16:06,640 --> 04:16:11,520 pressing that. And then now we have our 5774 04:16:09,439 --> 04:16:13,359 icon right here called the hamburger 5775 04:16:11,520 --> 04:16:15,199 menu. 5776 04:16:13,359 --> 04:16:17,840 Now looking at our header, we have a lot 5777 04:16:15,199 --> 04:16:19,840 of icons to download. So let's organize 5778 04:16:17,840 --> 04:16:23,279 them using a folder. We're going to 5779 04:16:19,840 --> 04:16:25,359 create a new folder and let's call this 5780 04:16:23,279 --> 04:16:26,960 icons. 5781 04:16:25,359 --> 04:16:28,960 And we're going to put the icon we 5782 04:16:26,960 --> 04:16:33,560 downloaded into that folder. So, this 5783 04:16:28,960 --> 04:16:33,560 one right here into this folder. 5784 04:16:33,600 --> 04:16:37,520 And now we're going to do the same steps 5785 04:16:35,040 --> 04:16:40,239 to download all of these other icons and 5786 04:16:37,520 --> 04:16:41,520 this image that we see here. 5787 04:16:40,239 --> 04:16:43,840 So, we're going to do the same steps. 5788 04:16:41,520 --> 04:16:45,920 Click the top left and then click the 5789 04:16:43,840 --> 04:16:48,800 icon we want to download and we can find 5790 04:16:45,920 --> 04:16:50,560 the link here. I'm going to fast forward 5791 04:16:48,800 --> 04:16:52,720 the video here because it's just a bunch 5792 04:16:50,560 --> 04:16:57,080 of repetitive steps. And we'll continue 5793 04:16:52,720 --> 04:16:57,080 after we downloaded all the icons. 5794 04:16:58,800 --> 04:17:01,840 So, when you get to the notification 5795 04:17:00,399 --> 04:17:03,439 icon, don't worry about this 5796 04:17:01,840 --> 04:17:04,880 notification number here. We're going to 5797 04:17:03,439 --> 04:17:07,439 learn how to do that in the next 5798 04:17:04,880 --> 04:17:09,439 section. And for this channel profile 5799 04:17:07,439 --> 04:17:10,800 picture, when I download it, I'm 5800 04:17:09,439 --> 04:17:13,040 actually going to save it in a different 5801 04:17:10,800 --> 04:17:16,000 folder from the other icons. So, if I 5802 04:17:13,040 --> 04:17:17,920 download this here and save it, I'm 5803 04:17:16,000 --> 04:17:19,760 going to put this in the channel 5804 04:17:17,920 --> 04:17:22,080 pictures folder instead of the icons 5805 04:17:19,760 --> 04:17:25,399 folder because technically it's a 5806 04:17:22,080 --> 04:17:25,399 channel picture. 5807 04:17:26,080 --> 04:17:30,399 So once we have all of that downloaded, 5808 04:17:28,080 --> 04:17:32,319 let's check in our code editor. And we 5809 04:17:30,399 --> 04:17:35,120 should see all of the icons that we need 5810 04:17:32,319 --> 04:17:36,880 for the header inside the icons folder, 5811 04:17:35,120 --> 04:17:39,120 as well as the channel profile picture 5812 04:17:36,880 --> 04:17:40,640 on the right in the channel pictures 5813 04:17:39,120 --> 04:17:42,479 folder. 5814 04:17:40,640 --> 04:17:45,680 And now we're ready to complete our 5815 04:17:42,479 --> 04:17:48,560 header in our current project. 5816 04:17:45,680 --> 04:17:50,800 So in our left section, we have this, 5817 04:17:48,560 --> 04:17:54,800 which is called a hamburger menu, and 5818 04:17:50,800 --> 04:17:57,600 the YouTube logo. So, in our HTML, 5819 04:17:54,800 --> 04:18:00,960 in this file, in our left section, we're 5820 04:17:57,600 --> 04:18:02,960 going to have an image, 5821 04:18:00,960 --> 04:18:05,120 and we're going to tell it what to load. 5822 04:18:02,960 --> 04:18:07,279 So, loading an SVG is the same thing as 5823 04:18:05,120 --> 04:18:08,640 any other image. We're going to go into 5824 04:18:07,279 --> 04:18:12,239 the icons folder, and we're going to 5825 04:18:08,640 --> 04:18:14,960 load the hamburger menu.svg. 5826 04:18:12,239 --> 04:18:19,359 And then, we're also going to load the 5827 04:18:14,960 --> 04:18:23,040 YouTube logo, which is right here. 5828 04:18:19,359 --> 04:18:25,760 So, YouTube logo.svg. SVG. 5829 04:18:23,040 --> 04:18:27,760 Save that and look at our web page and 5830 04:18:25,760 --> 04:18:29,439 refresh. 5831 04:18:27,760 --> 04:18:32,800 So the images are loaded, but they're 5832 04:18:29,439 --> 04:18:34,239 way too big. Let's make them smaller. 5833 04:18:32,800 --> 04:18:37,760 We're going to set a class so that we 5834 04:18:34,239 --> 04:18:40,000 can target them with CSS. So hamburger- 5835 04:18:37,760 --> 04:18:43,359 menu. 5836 04:18:40,000 --> 04:18:46,560 And for this one, let's set a class of 5837 04:18:43,359 --> 04:18:50,560 YouTube- logo. 5838 04:18:46,560 --> 04:18:53,840 And now in our CSS, let's go in here 5839 04:18:50,560 --> 04:18:56,560 and target the hamburger 5840 04:18:53,840 --> 04:18:59,040 menu class. 5841 04:18:56,560 --> 04:19:03,920 And let's set the height to something 5842 04:18:59,040 --> 04:19:06,239 like 20 pixels. And same thing for the 5843 04:19:03,920 --> 04:19:11,479 YouTube logo. 5844 04:19:06,239 --> 04:19:11,479 We'll set the height to 20 pixels. 5845 04:19:11,680 --> 04:19:15,840 Okay, so that looks pretty good. Now, if 5846 04:19:14,000 --> 04:19:18,239 we look at our design, we'll notice that 5847 04:19:15,840 --> 04:19:20,720 these images are actually aligned 5848 04:19:18,239 --> 04:19:23,120 vertically in the center. So, in our 5849 04:19:20,720 --> 04:19:27,600 flexbox practice file, we learned how to 5850 04:19:23,120 --> 04:19:30,000 do this. If we look at our code again, 5851 04:19:27,600 --> 04:19:31,520 if we look at our flexbox code, we 5852 04:19:30,000 --> 04:19:33,600 scroll all the way down to the last 5853 04:19:31,520 --> 04:19:37,040 example. 5854 04:19:33,600 --> 04:19:38,880 We did this using align items center. 5855 04:19:37,040 --> 04:19:41,199 So, that aligns them vertically in the 5856 04:19:38,880 --> 04:19:43,840 center like this. We'll go back to our 5857 04:19:41,199 --> 04:19:45,840 header CSS and just have this as a 5858 04:19:43,840 --> 04:19:47,359 reference. 5859 04:19:45,840 --> 04:19:53,680 So for our left section, we're going to 5860 04:19:47,359 --> 04:19:55,359 set align dash items colon center. 5861 04:19:53,680 --> 04:19:57,199 However, you'll notice that it didn't do 5862 04:19:55,359 --> 04:20:01,520 anything. And that's because if we look 5863 04:19:57,199 --> 04:20:03,520 at our HTML, the header is a flexbox. 5864 04:20:01,520 --> 04:20:06,080 But this left section here is still a 5865 04:20:03,520 --> 04:20:08,560 regular div. It's a element inside the 5866 04:20:06,080 --> 04:20:10,720 flexbox, but this itself is not a 5867 04:20:08,560 --> 04:20:12,319 flexbox. So align items doesn't do 5868 04:20:10,720 --> 04:20:13,760 anything. 5869 04:20:12,319 --> 04:20:16,800 Now to fix this, we can actually turn 5870 04:20:13,760 --> 04:20:18,479 the left section into a flexbox using 5871 04:20:16,800 --> 04:20:20,319 display 5872 04:20:18,479 --> 04:20:22,560 flex. 5873 04:20:20,319 --> 04:20:25,279 And if we save it, now the left section 5874 04:20:22,560 --> 04:20:28,800 is a flexbox. So align items will align 5875 04:20:25,279 --> 04:20:31,120 it vertically in the center. So flexbox 5876 04:20:28,800 --> 04:20:33,520 doesn't actually go down two layers. It 5877 04:20:31,120 --> 04:20:36,319 only affects elements on the first layer 5878 04:20:33,520 --> 04:20:38,800 like this div and this div. If we go 5879 04:20:36,319 --> 04:20:41,040 down another level like here, flexbox 5880 04:20:38,800 --> 04:20:43,920 doesn't affect it. That's why we have to 5881 04:20:41,040 --> 04:20:46,319 turn this into a flexbox as well in 5882 04:20:43,920 --> 04:20:49,040 order to use properties like align items 5883 04:20:46,319 --> 04:20:51,680 center. So this situation of putting a 5884 04:20:49,040 --> 04:20:53,920 flexbox inside another flexbox is 5885 04:20:51,680 --> 04:20:57,439 totally valid if we want to target 5886 04:20:53,920 --> 04:21:00,640 another level of elements like this. 5887 04:20:57,439 --> 04:21:03,120 Let's go into our design and compare it. 5888 04:21:00,640 --> 04:21:05,040 And you can see that for our design 5889 04:21:03,120 --> 04:21:08,319 there is some spacing on the left and 5890 04:21:05,040 --> 04:21:11,120 the right of the hamburger menu. So we 5891 04:21:08,319 --> 04:21:17,279 can create that right now 5892 04:21:11,120 --> 04:21:20,239 using margin- left 20 pixels and margin- 5893 04:21:17,279 --> 04:21:22,560 right of 20 pixels. 5894 04:21:20,239 --> 04:21:26,000 So we'll add 20 pixels on both of these 5895 04:21:22,560 --> 04:21:27,760 sides. So if I go back and forth, you'll 5896 04:21:26,000 --> 04:21:30,239 notice that this icon is a little bit 5897 04:21:27,760 --> 04:21:32,239 bigger than our project. So, we can 5898 04:21:30,239 --> 04:21:34,880 actually adjust our height here to make 5899 04:21:32,239 --> 04:21:37,600 our icon a little bit bigger. We can 5900 04:21:34,880 --> 04:21:40,159 maybe set this to 24. 5901 04:21:37,600 --> 04:21:42,479 And let's compare it. Okay. So, that 5902 04:21:40,159 --> 04:21:44,880 looks pretty close. 5903 04:21:42,479 --> 04:21:47,199 So, now I notice that this icon is a 5904 04:21:44,880 --> 04:21:49,279 little bit to the right of our website, 5905 04:21:47,199 --> 04:21:51,120 which is here. So, you notice that it's 5906 04:21:49,279 --> 04:21:53,920 a little bit to the right. We need to 5907 04:21:51,120 --> 04:21:57,040 add more spacing. So, let's add margin 5908 04:21:53,920 --> 04:22:01,439 left of maybe 24 pixels. 5909 04:21:57,040 --> 04:22:03,199 Save it. And now if we compare the two. 5910 04:22:01,439 --> 04:22:04,960 So that looks pretty much close to what 5911 04:22:03,199 --> 04:22:06,880 we need. And the YouTube logo is also in 5912 04:22:04,960 --> 04:22:09,279 the same place. So that's a bonus for 5913 04:22:06,880 --> 04:22:11,359 us. So now it looks like the left 5914 04:22:09,279 --> 04:22:13,040 section is pretty much done in our 5915 04:22:11,359 --> 04:22:14,640 project. And we can get rid of this 5916 04:22:13,040 --> 04:22:17,120 background color that we were practicing 5917 04:22:14,640 --> 04:22:18,399 with. 5918 04:22:17,120 --> 04:22:21,520 First, we're actually going to remove 5919 04:22:18,399 --> 04:22:23,760 the width. So this width of 150 pixels 5920 04:22:21,520 --> 04:22:27,120 is forcing the left section to only end 5921 04:22:23,760 --> 04:22:29,199 up here. However, if we remove this, the 5922 04:22:27,120 --> 04:22:31,840 left section will stretch to contain all 5923 04:22:29,199 --> 04:22:34,080 of its content. So, if we save it, you 5924 04:22:31,840 --> 04:22:36,880 can see that it stretches. Now, we can 5925 04:22:34,080 --> 04:22:39,040 remove the background color, 5926 04:22:36,880 --> 04:22:40,560 and that's done. 5927 04:22:39,040 --> 04:22:43,040 Next, we're going to work on this middle 5928 04:22:40,560 --> 04:22:46,319 section. So, for this middle section in 5929 04:22:43,040 --> 04:22:49,359 our design, we have an icon here, a 5930 04:22:46,319 --> 04:22:51,920 button here, and if we resize, you'll 5931 04:22:49,359 --> 04:22:55,040 notice that the search box also resizes. 5932 04:22:51,920 --> 04:22:57,279 So this search box is going to grow with 5933 04:22:55,040 --> 04:23:00,000 the rest of the page. So we already 5934 04:22:57,279 --> 04:23:03,920 learned how to do that. As a reminder, 5935 04:23:00,000 --> 04:23:05,680 it's flex one. So first, let's go in and 5936 04:23:03,920 --> 04:23:08,000 create these two buttons first because 5937 04:23:05,680 --> 04:23:10,960 that's the easy part. 5938 04:23:08,000 --> 04:23:13,760 Let's go into our code in the middle 5939 04:23:10,960 --> 04:23:15,680 section here after the search bar. We're 5940 04:23:13,760 --> 04:23:18,880 going to create two buttons. So let's 5941 04:23:15,680 --> 04:23:21,439 create one button here 5942 04:23:18,880 --> 04:23:23,199 and another button down here. 5943 04:23:21,439 --> 04:23:25,840 So inside this first button, we're going 5944 04:23:23,199 --> 04:23:28,399 to have this search icon. So if we go 5945 04:23:25,840 --> 04:23:30,560 into our icons folder, it's this icon 5946 04:23:28,399 --> 04:23:34,479 here, search.svg. 5947 04:23:30,560 --> 04:23:39,080 So we can create an image element source 5948 04:23:34,479 --> 04:23:39,080 and icons/ search.svg. 5949 04:23:39,359 --> 04:23:42,960 In the second button, we're going to 5950 04:23:40,640 --> 04:23:46,880 have our voice search icon, which is 5951 04:23:42,960 --> 04:23:48,720 this one. And we're going to create 5952 04:23:46,880 --> 04:23:52,479 another image element. and we're going 5953 04:23:48,720 --> 04:23:55,359 to load icons slashvoice 5954 04:23:52,479 --> 04:23:57,040 search icon. 5955 04:23:55,359 --> 04:23:59,840 Now, let's save it and see how that 5956 04:23:57,040 --> 04:24:01,920 looks. Okay, so that didn't work out 5957 04:23:59,840 --> 04:24:03,920 very well. Probably because if you 5958 04:24:01,920 --> 04:24:06,399 remember when we loaded this icon here, 5959 04:24:03,920 --> 04:24:08,399 it was super big. So, the two icons we 5960 04:24:06,399 --> 04:24:10,479 loaded are probably super big and we 5961 04:24:08,399 --> 04:24:13,040 only see the top left corner which is 5962 04:24:10,479 --> 04:24:14,800 empty. So, first let's make our icon 5963 04:24:13,040 --> 04:24:18,080 smaller and make our buttons a little 5964 04:24:14,800 --> 04:24:20,159 bigger. Let's go into our HTML. We're 5965 04:24:18,080 --> 04:24:22,800 going to add some classes so that we can 5966 04:24:20,159 --> 04:24:25,840 target it with CSS. So class, let's call 5967 04:24:22,800 --> 04:24:30,159 this the search-button. 5968 04:24:25,840 --> 04:24:33,159 And let's call this one the uh voice- 5969 04:24:30,159 --> 04:24:33,159 search-button. 5970 04:24:34,560 --> 04:24:39,040 So we're going to go to the middle 5971 04:24:35,680 --> 04:24:41,840 section here. We're going to target the 5972 04:24:39,040 --> 04:24:45,120 search button first. 5973 04:24:41,840 --> 04:24:48,479 Let's set the height to something like 5974 04:24:45,120 --> 04:24:50,960 40 pixels and set the width to something 5975 04:24:48,479 --> 04:24:53,199 like 60 pixels. 5976 04:24:50,960 --> 04:24:55,040 And for the voice search button, if we 5977 04:24:53,199 --> 04:24:57,120 look at our design, it's pretty much 5978 04:24:55,040 --> 04:25:01,479 round. 5979 04:24:57,120 --> 04:25:01,479 So, let's target voice search button. 5980 04:25:02,399 --> 04:25:08,479 Let's set a height of 40 pixels 5981 04:25:05,600 --> 04:25:09,760 and we'll set the width to 40 pixels as 5982 04:25:08,479 --> 04:25:12,720 well. 5983 04:25:09,760 --> 04:25:14,239 So, let's save it. Okay, so that looks 5984 04:25:12,720 --> 04:25:16,479 super weird, but we're going to fix this 5985 04:25:14,239 --> 04:25:18,960 right now. So, remember that we want to 5986 04:25:16,479 --> 04:25:21,680 align these in the center vertically 5987 04:25:18,960 --> 04:25:24,720 just like this. To do that, our middle 5988 04:25:21,680 --> 04:25:27,600 section is also going to be a flexbox. 5989 04:25:24,720 --> 04:25:29,520 And then we can use the align items 5990 04:25:27,600 --> 04:25:32,000 property that we used for the left 5991 04:25:29,520 --> 04:25:34,640 section. So, let's make this middle 5992 04:25:32,000 --> 04:25:38,800 section a flexbox. And we're going to 5993 04:25:34,640 --> 04:25:40,960 set display to flex. And we're going to 5994 04:25:38,800 --> 04:25:43,840 set align 5995 04:25:40,960 --> 04:25:47,359 dash items 5996 04:25:43,840 --> 04:25:49,279 to center just like our left section. So 5997 04:25:47,359 --> 04:25:50,960 now if we save you'll see that 5998 04:25:49,279 --> 04:25:53,359 everything is aligned to the center and 5999 04:25:50,960 --> 04:25:55,279 now it's ready for us to style. So there 6000 04:25:53,359 --> 04:25:58,800 is one thing that I left out which is 6001 04:25:55,279 --> 04:26:00,720 flex direction row. So this tells a 6002 04:25:58,800 --> 04:26:02,960 flexbox to lay out our content 6003 04:26:00,720 --> 04:26:04,720 horizontally and this is actually the 6004 04:26:02,960 --> 04:26:07,520 default value. So we don't actually need 6005 04:26:04,720 --> 04:26:10,239 it. I put it here just for our practice 6006 04:26:07,520 --> 04:26:12,399 code, but for our header, we can be safe 6007 04:26:10,239 --> 04:26:14,960 actually leaving that line out and just 6008 04:26:12,399 --> 04:26:16,479 having display flex and align item 6009 04:26:14,960 --> 04:26:18,239 center. 6010 04:26:16,479 --> 04:26:19,680 So, now that the layout is good, we're 6011 04:26:18,239 --> 04:26:22,640 going to go back to our triedand-rue 6012 04:26:19,680 --> 04:26:24,880 method of styling this one by one with 6013 04:26:22,640 --> 04:26:26,319 CSS. 6014 04:26:24,880 --> 04:26:28,399 The first thing I'm going to adjust is 6015 04:26:26,319 --> 04:26:30,399 this search bar. So, notice that it 6016 04:26:28,399 --> 04:26:32,720 stretches to fill up the content when we 6017 04:26:30,399 --> 04:26:34,880 resize the page. To do that, we're going 6018 04:26:32,720 --> 04:26:37,120 to go into our code. We're going to 6019 04:26:34,880 --> 04:26:38,960 target the search bar. So, dot 6020 04:26:37,120 --> 04:26:42,479 search-bar 6021 04:26:38,960 --> 04:26:44,479 right here. And remember to stretch it 6022 04:26:42,479 --> 04:26:50,239 to take up the remaining space. We're 6023 04:26:44,479 --> 04:26:51,920 going to set flex one and save. 6024 04:26:50,239 --> 04:26:54,880 Now, let's make the search box similar 6025 04:26:51,920 --> 04:26:57,920 to the design. So, I'm actually going to 6026 04:26:54,880 --> 04:27:00,239 move this here side by side so that it's 6027 04:26:57,920 --> 04:27:02,479 easier to copy from. 6028 04:27:00,239 --> 04:27:04,560 So, I'll go back into my code and the 6029 04:27:02,479 --> 04:27:08,720 first thing I'll adjust is the height. 6030 04:27:04,560 --> 04:27:11,199 So, let's set a height of 40 pixels. 6031 04:27:08,720 --> 04:27:13,680 Okay, that looks a little too much. 6032 04:27:11,199 --> 04:27:15,840 Let's set the height to 36. See how that 6033 04:27:13,680 --> 04:27:18,720 looks. So, I think it's still a little 6034 04:27:15,840 --> 04:27:21,680 too much. Let's set it to 34. 6035 04:27:18,720 --> 04:27:24,319 And that looks pretty good to me. Next, 6036 04:27:21,680 --> 04:27:26,479 let's adjust this placeholder text. So, 6037 04:27:24,319 --> 04:27:28,960 to adjust the placeholder, we actually 6038 04:27:26,479 --> 04:27:32,000 need another sort of pseudo class. So, 6039 04:27:28,960 --> 04:27:33,760 we're going to type dot search bar to 6040 04:27:32,000 --> 04:27:38,720 target the search bar. And then we're 6041 04:27:33,760 --> 04:27:40,399 going to type colon colon placeholder. 6042 04:27:38,720 --> 04:27:43,120 So, this is how you target the 6043 04:27:40,399 --> 04:27:47,040 placeholder on an input element like 6044 04:27:43,120 --> 04:27:49,199 this. So, first let's set the font-f 6045 04:27:47,040 --> 04:27:51,520 family 6046 04:27:49,199 --> 04:27:54,000 to the one we're using for this page. If 6047 04:27:51,520 --> 04:27:56,560 we go to general.css, we're using 6048 04:27:54,000 --> 04:27:59,600 roboto, aerial. So, we're going to set 6049 04:27:56,560 --> 04:28:03,279 that to Roboto, 6050 04:27:59,600 --> 04:28:04,960 Ariel. Save it. So, the font changed a 6051 04:28:03,279 --> 04:28:07,760 little bit. We're going to change the 6052 04:28:04,960 --> 04:28:09,359 font size to make it bigger. Font dash 6053 04:28:07,760 --> 04:28:12,399 size 6054 04:28:09,359 --> 04:28:15,040 to 16 pixels, let's say. Okay, I think 6055 04:28:12,399 --> 04:28:16,960 that looks a little bigger. 6056 04:28:15,040 --> 04:28:19,199 And then next, we notice that on the 6057 04:28:16,960 --> 04:28:20,720 inside of this input, we have a little 6058 04:28:19,199 --> 04:28:22,800 bit of space. Well, we don't have that 6059 04:28:20,720 --> 04:28:24,880 much space here. So, we're going to set 6060 04:28:22,800 --> 04:28:25,840 some padding on the left of our search 6061 04:28:24,880 --> 04:28:29,760 bar. 6062 04:28:25,840 --> 04:28:33,359 So, let's set the padding dash left to 6063 04:28:29,760 --> 04:28:34,960 12 pixels. Save it. Okay, that looks 6064 04:28:33,359 --> 04:28:36,640 okay. Let's actually set it to 10 6065 04:28:34,960 --> 04:28:38,239 pixels. 6066 04:28:36,640 --> 04:28:40,159 And then when we start typing into the 6067 04:28:38,239 --> 04:28:42,399 search bar, notice that the font is 6068 04:28:40,159 --> 04:28:47,040 bigger. But for here, we still have the 6069 04:28:42,399 --> 04:28:50,960 small font. So, we can set the font size 6070 04:28:47,040 --> 04:28:52,800 to 16 pixels. See how that looks. Okay, 6071 04:28:50,960 --> 04:28:54,560 so that looks pretty close to what we 6072 04:28:52,800 --> 04:28:55,920 have. 6073 04:28:54,560 --> 04:28:58,800 And next, I'm going to change the 6074 04:28:55,920 --> 04:29:03,279 border. So, I'll set the border dash 6075 04:28:58,800 --> 04:29:05,439 width to 1 pixels. The border style, we 6076 04:29:03,279 --> 04:29:07,439 want it to be solid. 6077 04:29:05,439 --> 04:29:10,800 And finally, I'm going to set a border 6078 04:29:07,439 --> 04:29:13,840 dash color of gray. Let's see how that 6079 04:29:10,800 --> 04:29:15,920 looks. Okay. So, I can't really tell the 6080 04:29:13,840 --> 04:29:17,840 color because of the background. We're 6081 04:29:15,920 --> 04:29:21,040 going to remove this light pink 6082 04:29:17,840 --> 04:29:22,720 background cuz we don't need it anymore. 6083 04:29:21,040 --> 04:29:24,960 And that looks a little too dark. So, 6084 04:29:22,720 --> 04:29:29,479 I'm going to pick something lighter. 6085 04:29:24,960 --> 04:29:29,479 Maybe something like this. 6086 04:29:30,239 --> 04:29:34,720 Save. And I think that's close enough to 6087 04:29:32,479 --> 04:29:36,479 that. 6088 04:29:34,720 --> 04:29:38,000 Next, let's adjust the height again 6089 04:29:36,479 --> 04:29:39,920 because when we set the border, it 6090 04:29:38,000 --> 04:29:42,960 actually made it a little bit smaller. 6091 04:29:39,920 --> 04:29:46,399 So, we'll set the height to 36. 6092 04:29:42,960 --> 04:29:48,159 And now it aligns with the buttons. 6093 04:29:46,399 --> 04:29:51,439 And I'm also going to create rounded 6094 04:29:48,159 --> 04:29:56,720 corners. So that property is border dash 6095 04:29:51,439 --> 04:29:58,159 radius. Let's set it to 2 pixels. 6096 04:29:56,720 --> 04:30:01,040 Now the last style we're going to adjust 6097 04:29:58,159 --> 04:30:03,040 for this is the shadow. So if we zoom 6098 04:30:01,040 --> 04:30:05,040 into this search box, there's actually a 6099 04:30:03,040 --> 04:30:07,359 little bit of shadow in the inside. 6100 04:30:05,040 --> 04:30:09,760 While our search box does not have that. 6101 04:30:07,359 --> 04:30:12,000 So we'll go back into our code and we're 6102 04:30:09,760 --> 04:30:14,399 going to add a shadow. We're going to 6103 04:30:12,000 --> 04:30:19,279 use this from one of the very early 6104 04:30:14,399 --> 04:30:21,120 lessons. box dash shadow. 6105 04:30:19,279 --> 04:30:23,279 And if we want a shadow on the inside of 6106 04:30:21,120 --> 04:30:26,399 the element instead of the outside, we 6107 04:30:23,279 --> 04:30:28,319 just need to set inset at the beginning. 6108 04:30:26,399 --> 04:30:29,920 So this will put this box shadow in the 6109 04:30:28,319 --> 04:30:31,920 inside. 6110 04:30:29,920 --> 04:30:34,880 Now we have our usual values, which is 6111 04:30:31,920 --> 04:30:37,120 the horizontal position. So let's set it 6112 04:30:34,880 --> 04:30:39,120 to 1 pixels. So it's going to be moved 6113 04:30:37,120 --> 04:30:41,279 one pixels to the right. And the 6114 04:30:39,120 --> 04:30:43,199 vertical position, let's set it to 2 6115 04:30:41,279 --> 04:30:45,760 pixels. The shadow will be moved 2 6116 04:30:43,199 --> 04:30:49,199 pixels to the bottom. Let's set a blur 6117 04:30:45,760 --> 04:30:53,279 of maybe 5 pixels. And we'll set the 6118 04:30:49,199 --> 04:30:55,840 shadow color to RGBA 6119 04:30:53,279 --> 04:30:59,680 000, which is black. And then 6120 04:30:55,840 --> 04:31:02,640 transparency set to only 0.15 6121 04:30:59,680 --> 04:31:05,120 to get a very transparent black. So, 6122 04:31:02,640 --> 04:31:07,120 let's save this. 6123 04:31:05,120 --> 04:31:10,640 So, that's way too much. Let's actually 6124 04:31:07,120 --> 04:31:13,439 reduce the blur to 3 pixels, maybe. And 6125 04:31:10,640 --> 04:31:15,439 then change this to 0.05. 6126 04:31:13,439 --> 04:31:18,159 So, we're doing a lot of trial and error 6127 04:31:15,439 --> 04:31:19,840 with CSS, which is normal. Okay, so I 6128 04:31:18,159 --> 04:31:22,720 think this looks pretty close to our 6129 04:31:19,840 --> 04:31:24,000 design. I think it looks close enough. 6130 04:31:22,720 --> 04:31:27,279 For now, we're going to move on and 6131 04:31:24,000 --> 04:31:30,000 style the buttons. 6132 04:31:27,279 --> 04:31:32,239 So, first, let's resize this icon inside 6133 04:31:30,000 --> 04:31:35,520 the button. 6134 04:31:32,239 --> 04:31:38,239 So, let's give this a class of search 6135 04:31:35,520 --> 04:31:42,159 dash icon. 6136 04:31:38,239 --> 04:31:45,279 Save it. And then in here in the dot 6137 04:31:42,159 --> 04:31:47,199 search icon, we're going to make it a 6138 04:31:45,279 --> 04:31:51,199 little smaller. So let's set the height 6139 04:31:47,199 --> 04:31:52,720 to 20 pixels. See how that looks. Okay, 6140 04:31:51,199 --> 04:31:55,439 so that looks too small. I'm going to 6141 04:31:52,720 --> 04:31:56,960 try 25 pixels. 6142 04:31:55,439 --> 04:31:58,640 All right, so that size looks pretty 6143 04:31:56,960 --> 04:32:00,640 similar. Now, you'll notice that this 6144 04:31:58,640 --> 04:32:03,040 one is vertically aligned while ours is 6145 04:32:00,640 --> 04:32:06,159 not. So we can either turn the search 6146 04:32:03,040 --> 04:32:08,399 button into a flex box or we can just do 6147 04:32:06,159 --> 04:32:10,880 a simpler solution. We're going to add 6148 04:32:08,399 --> 04:32:15,359 some spacing to the top of this icon to 6149 04:32:10,880 --> 04:32:18,640 push it down. So, margin dash top of 6150 04:32:15,359 --> 04:32:20,880 maybe four pixels to push that down just 6151 04:32:18,640 --> 04:32:23,359 a little bit. Okay, so I think that 6152 04:32:20,880 --> 04:32:26,000 looks close enough. 6153 04:32:23,359 --> 04:32:29,600 Let's finish off this button. 6154 04:32:26,000 --> 04:32:32,159 We're going to set a background color 6155 04:32:29,600 --> 04:32:34,640 of gray and then I'm going to adjust it 6156 04:32:32,159 --> 04:32:39,279 to match that. So, I'm going to pick 6157 04:32:34,640 --> 04:32:41,680 something like this. Maybe 240. 6158 04:32:39,279 --> 04:32:43,680 And then save it. That looks pretty 6159 04:32:41,680 --> 04:32:45,840 good. But now our borders are messed up. 6160 04:32:43,680 --> 04:32:47,359 So, we're going to set the border. 6161 04:32:45,840 --> 04:32:53,120 Border 6162 04:32:47,359 --> 04:32:57,359 width of one pixel. Border dash style of 6163 04:32:53,120 --> 04:33:00,000 solid color. And border color is going 6164 04:32:57,359 --> 04:33:05,399 to be the same as our text box. So, we 6165 04:33:00,000 --> 04:33:05,399 can go up here and just copy that 6166 04:33:05,680 --> 04:33:12,400 and right there. Save it. And there we 6167 04:33:09,039 --> 04:33:14,639 go. That looks pretty close right now. 6168 04:33:12,400 --> 04:33:16,639 So, now we want to move this button into 6169 04:33:14,639 --> 04:33:19,520 this input element a little bit like you 6170 04:33:16,639 --> 04:33:22,000 see here. So that we only have one edge. 6171 04:33:19,520 --> 04:33:24,400 To do that, here's a little trick. We 6172 04:33:22,000 --> 04:33:26,561 can set some spacing on the left. So, 6173 04:33:24,400 --> 04:33:29,359 margin left. Except this time, we're 6174 04:33:26,561 --> 04:33:31,760 going to add negative spacing. So, we're 6175 04:33:29,359 --> 04:33:33,840 going to add negative one spacing. 6176 04:33:31,760 --> 04:33:36,320 Normal margin adds space and it pushes 6177 04:33:33,840 --> 04:33:38,320 the element. Negative margin subtracts 6178 04:33:36,320 --> 04:33:40,480 space and pulls the element to that 6179 04:33:38,320 --> 04:33:42,879 side. So, margin left of a negative 6180 04:33:40,480 --> 04:33:45,600 number will pull it to the left. So, 6181 04:33:42,879 --> 04:33:48,561 let's pull it to the left by one pixel. 6182 04:33:45,600 --> 04:33:50,320 Save it. And that looks really good. 6183 04:33:48,561 --> 04:33:52,480 Now, we're going to make our button a 6184 04:33:50,320 --> 04:33:56,359 little bit longer. 6185 04:33:52,480 --> 04:33:56,359 Let's change it to 66. 6186 04:33:56,639 --> 04:34:01,439 Finally, we're going to style this voice 6187 04:33:58,561 --> 04:34:02,719 search icon. First, we notice that 6188 04:34:01,439 --> 04:34:05,680 there's a little bit of space between 6189 04:34:02,719 --> 04:34:07,840 these two. So, let's set a margin on the 6190 04:34:05,680 --> 04:34:10,000 right side of the button. So, this time 6191 04:34:07,840 --> 04:34:15,600 it's normal margin. 6192 04:34:10,000 --> 04:34:17,119 Margin right of maybe 8 pixels. 6193 04:34:15,600 --> 04:34:20,080 I think that looks pretty close. I'm 6194 04:34:17,119 --> 04:34:21,840 actually going to set it to 10. Okay. 6195 04:34:20,080 --> 04:34:24,160 And then for this button, I'm first 6196 04:34:21,840 --> 04:34:27,199 going to make it round. So, let's go 6197 04:34:24,160 --> 04:34:29,039 into the styles of this button. And to 6198 04:34:27,199 --> 04:34:31,680 make it round, we just have to make the 6199 04:34:29,039 --> 04:34:35,199 corners as round as possible. Let's set 6200 04:34:31,680 --> 04:34:37,359 the border radius. 6201 04:34:35,199 --> 04:34:39,119 And I'm going to set it to 20 pixels. 6202 04:34:37,359 --> 04:34:41,359 So, a trick here is that if you set this 6203 04:34:39,119 --> 04:34:44,080 to half the width of the height, it will 6204 04:34:41,359 --> 04:34:45,920 make it round. So, let's save this. And 6205 04:34:44,080 --> 04:34:48,240 now we have a round button, but we have 6206 04:34:45,920 --> 04:34:50,879 a weird border. Let's actually get rid 6207 04:34:48,240 --> 04:34:54,000 of it cuz it's not in our design. So 6208 04:34:50,879 --> 04:34:56,561 border and none to get rid of the 6209 04:34:54,000 --> 04:34:58,561 border. 6210 04:34:56,561 --> 04:35:00,879 So it's looking really close. Our icon 6211 04:34:58,561 --> 04:35:04,160 is a little bit bigger than this one. So 6212 04:35:00,879 --> 04:35:06,719 we're going to target it in here. Class 6213 04:35:04,160 --> 04:35:10,561 equals voice- 6214 04:35:06,719 --> 04:35:15,920 search- icon. And then in our CSS, we'll 6215 04:35:10,561 --> 04:35:18,719 target that. So voice- search- icon. 6216 04:35:15,920 --> 04:35:21,359 So, for this, let's set a height of 6217 04:35:18,719 --> 04:35:23,279 maybe 20 pixels. See how that looks? 6218 04:35:21,359 --> 04:35:26,080 It's a little bit small. Let's increase 6219 04:35:23,279 --> 04:35:27,920 it to 24. I think that looks pretty 6220 04:35:26,080 --> 04:35:29,840 good. And next, we're going to try to 6221 04:35:27,920 --> 04:35:32,240 vertically align it. We're going to add 6222 04:35:29,840 --> 04:35:36,000 a little bit of margin on the top to 6223 04:35:32,240 --> 04:35:38,719 push it down. So, margin- top and four 6224 04:35:36,000 --> 04:35:40,879 pixels. 6225 04:35:38,719 --> 04:35:43,039 Okay, that looks pretty good. The last 6226 04:35:40,879 --> 04:35:45,439 thing is to change the background color. 6227 04:35:43,039 --> 04:35:47,199 So, we're going to change the background 6228 04:35:45,439 --> 04:35:49,439 color 6229 04:35:47,199 --> 04:35:53,039 to let's say gray. And then I'll pick 6230 04:35:49,439 --> 04:35:56,160 another color. So, this time let's pick 6231 04:35:53,039 --> 04:35:58,719 maybe 245. 6232 04:35:56,160 --> 04:36:00,639 And then save. 6233 04:35:58,719 --> 04:36:02,160 Oh, so I accidentally put it on the 6234 04:36:00,639 --> 04:36:05,359 icon. We actually want to put this on 6235 04:36:02,160 --> 04:36:07,359 the entire button. So, I'm going to 6236 04:36:05,359 --> 04:36:10,959 cut and paste this onto the button 6237 04:36:07,359 --> 04:36:12,719 styles. Let's save. And I think that 6238 04:36:10,959 --> 04:36:14,561 looks pretty close. 6239 04:36:12,719 --> 04:36:16,240 So, this color is a little bit off from 6240 04:36:14,561 --> 04:36:18,480 this, but I think it's okay if we look 6241 04:36:16,240 --> 04:36:20,320 at the bigger picture. 6242 04:36:18,480 --> 04:36:24,879 So, now we've completed the middle 6243 04:36:20,320 --> 04:36:26,879 section, and you can compare it here to 6244 04:36:24,879 --> 04:36:28,879 here. So, we're looking really good so 6245 04:36:26,879 --> 04:36:30,480 far. Next, we're going to finish the 6246 04:36:28,879 --> 04:36:32,719 right section. So, I'm going to put them 6247 04:36:30,480 --> 04:36:35,840 side by side again so it's easier for us 6248 04:36:32,719 --> 04:36:38,400 to copy. 6249 04:36:35,840 --> 04:36:40,240 So, the right section has three icons 6250 04:36:38,400 --> 04:36:43,199 and an image. So, we're going to add 6251 04:36:40,240 --> 04:36:46,719 them to our HTML first. So, let's go 6252 04:36:43,199 --> 04:36:49,600 into the right section here 6253 04:36:46,719 --> 04:36:52,639 and we're going to create an image and 6254 04:36:49,600 --> 04:36:56,480 we're going to load this which is the 6255 04:36:52,639 --> 04:36:58,320 upload icon. So, icons 6256 04:36:56,480 --> 04:36:59,920 slash 6257 04:36:58,320 --> 04:37:01,920 upload. 6258 04:36:59,920 --> 04:37:04,080 SVG. 6259 04:37:01,920 --> 04:37:06,240 And then we'll add another one. So, 6260 04:37:04,080 --> 04:37:09,359 image. 6261 04:37:06,240 --> 04:37:14,119 And this one is going to be icons slash 6262 04:37:09,359 --> 04:37:14,119 this one is called YouTube apps.svg. 6263 04:37:14,719 --> 04:37:19,680 And then the last one is the 6264 04:37:16,400 --> 04:37:22,160 notification icon which is here. So 6265 04:37:19,680 --> 04:37:26,480 image element and we're going to load 6266 04:37:22,160 --> 04:37:28,080 icons slash notifications. 6267 04:37:26,480 --> 04:37:29,600 SVG. 6268 04:37:28,080 --> 04:37:32,160 And finally we're going to create 6269 04:37:29,600 --> 04:37:35,680 another image and we're going to load 6270 04:37:32,160 --> 04:37:37,600 this channel profile picture. So, source 6271 04:37:35,680 --> 04:37:39,439 and this one is located in a different 6272 04:37:37,600 --> 04:37:43,600 folder. It's in the channel pictures 6273 04:37:39,439 --> 04:37:47,119 folder and it's called my channel.jpeg. 6274 04:37:43,600 --> 04:37:50,000 So, let's save it. Refresh. And again, 6275 04:37:47,119 --> 04:37:53,520 our SVGs are massive. So, let's go ahead 6276 04:37:50,000 --> 04:37:55,439 and resize them in our CSS. 6277 04:37:53,520 --> 04:37:57,359 So, first let's add classes to all of 6278 04:37:55,439 --> 04:38:01,439 these images. So, we're going to set 6279 04:37:57,359 --> 04:38:03,680 this one to upload- icon. So, upload- 6280 04:38:01,439 --> 04:38:06,719 icon. The next one is going to be 6281 04:38:03,680 --> 04:38:08,879 YouTube apps icon. So class equals 6282 04:38:06,719 --> 04:38:12,320 YouTube-apps- 6283 04:38:08,879 --> 04:38:16,240 icon. Next one we'll do notifications 6284 04:38:12,320 --> 04:38:17,760 icon. So class equals notifications 6285 04:38:16,240 --> 04:38:19,279 icon. 6286 04:38:17,760 --> 04:38:20,959 And lastly, we're going to name this a 6287 04:38:19,279 --> 04:38:24,719 little bit different. Let's give it a 6288 04:38:20,959 --> 04:38:27,840 class. And let's call this one current- 6289 04:38:24,719 --> 04:38:31,959 user- picture. So it's a little more 6290 04:38:27,840 --> 04:38:31,959 clear that this is different. 6291 04:38:32,400 --> 04:38:38,000 and we can target it with CSS. So, let's 6292 04:38:34,799 --> 04:38:40,639 go down into this right section here and 6293 04:38:38,000 --> 04:38:44,480 we'll scroll up. We'll first resize the 6294 04:38:40,639 --> 04:38:48,480 icons. Let's resize the upload icon. 6295 04:38:44,480 --> 04:38:51,119 Let's set a height of 24 pixels and then 6296 04:38:48,480 --> 04:38:53,439 we'll do the 6297 04:38:51,119 --> 04:38:57,760 YouTube-apps 6298 04:38:53,439 --> 04:39:00,879 icon. Let's set a height of 24 pixels. 6299 04:38:57,760 --> 04:39:03,199 And then the notifications icon, which 6300 04:39:00,879 --> 04:39:06,400 is right here 6301 04:39:03,199 --> 04:39:08,799 icon. Let's set a height of this 24 6302 04:39:06,400 --> 04:39:10,879 pixels again. 6303 04:39:08,799 --> 04:39:13,680 And the current user picture. So notice 6304 04:39:10,879 --> 04:39:17,439 it's a little bit taller. Let's target 6305 04:39:13,680 --> 04:39:19,600 that. Current- user-picture. 6306 04:39:17,439 --> 04:39:22,959 And we're going to set a height of 32 6307 04:39:19,600 --> 04:39:25,840 pixels to make it a little bit taller. 6308 04:39:22,959 --> 04:39:29,039 So, let's save it. And now we have the 6309 04:39:25,840 --> 04:39:31,439 icons we're going to use. 6310 04:39:29,039 --> 04:39:33,840 Again, we want to align these vertically 6311 04:39:31,439 --> 04:39:35,680 in the center. Remember to do that, 6312 04:39:33,840 --> 04:39:39,760 we're going to scroll up to our middle 6313 04:39:35,680 --> 04:39:42,160 section, which is all the way up here. 6314 04:39:39,760 --> 04:39:44,480 We first have to turn this container 6315 04:39:42,160 --> 04:39:48,320 into a flexbox. And then we can use 6316 04:39:44,480 --> 04:39:51,360 align item center. So, inside our HTML, 6317 04:39:48,320 --> 04:39:54,160 we have to turn this into a flexbox. 6318 04:39:51,360 --> 04:39:57,280 Let's scroll down. 6319 04:39:54,160 --> 04:40:00,240 to the right section styles here. We're 6320 04:39:57,280 --> 04:40:03,878 going to turn this display 6321 04:40:00,240 --> 04:40:03,878 colon flex 6322 04:40:04,080 --> 04:40:10,240 and then we're going to set align dash 6323 04:40:06,718 --> 04:40:13,280 items colon center to align them 6324 04:40:10,240 --> 04:40:15,600 vertically. Let's save it. 6325 04:40:13,280 --> 04:40:18,400 Okay. Next, we want to distribute them 6326 04:40:15,600 --> 04:40:20,718 evenly across the horizontal space. And 6327 04:40:18,400 --> 04:40:24,878 remember from our practice code, that 6328 04:40:20,718 --> 04:40:29,120 one's called justify-content 6329 04:40:24,878 --> 04:40:31,440 space dash between. Let's save it. And 6330 04:40:29,120 --> 04:40:33,600 now these icons are spaced evenly across 6331 04:40:31,440 --> 04:40:34,878 the space. 6332 04:40:33,600 --> 04:40:36,878 So it looks like they're a little bit 6333 04:40:34,878 --> 04:40:39,120 too far apart from each other. We can 6334 04:40:36,878 --> 04:40:40,878 adjust that by adjusting the width. So 6335 04:40:39,120 --> 04:40:42,958 let's decrease the width to bring 6336 04:40:40,878 --> 04:40:45,958 everything closer together to match our 6337 04:40:42,958 --> 04:40:45,958 design. 6338 04:40:46,240 --> 04:40:51,200 And I actually think this like all the 6339 04:40:48,320 --> 04:40:52,958 icons look good enough. The only last 6340 04:40:51,200 --> 04:40:54,878 thing we're going to change is this 6341 04:40:52,958 --> 04:40:57,440 picture here. So notice it's still a 6342 04:40:54,878 --> 04:40:59,280 square. We want to make it a circle. So 6343 04:40:57,440 --> 04:41:03,480 as a review, we're going to use border 6344 04:40:59,280 --> 04:41:03,480 radius to make it a circle. 6345 04:41:04,000 --> 04:41:09,520 So let's set it to border dash radius. 6346 04:41:07,600 --> 04:41:13,120 And the trick we learned is half of this 6347 04:41:09,520 --> 04:41:15,440 will make it round. So 16 pixels. Save 6348 04:41:13,120 --> 04:41:17,920 it. And now we have a round channel 6349 04:41:15,440 --> 04:41:19,360 profile picture. Lastly, we're pretty 6350 04:41:17,920 --> 04:41:21,760 much done with this. So, we can get rid 6351 04:41:19,360 --> 04:41:26,920 of the blue background color. So, we'll 6352 04:41:21,760 --> 04:41:26,920 scroll up and get rid of this. 6353 04:41:27,840 --> 04:41:32,320 Now, I actually noticed that we have 6354 04:41:29,840 --> 04:41:34,480 spacing to the right here in our design. 6355 04:41:32,320 --> 04:41:36,718 So, that's one thing I missed. So, let's 6356 04:41:34,480 --> 04:41:39,840 add that right now. 6357 04:41:36,718 --> 04:41:43,840 So, we're going to add margin right to 6358 04:41:39,840 --> 04:41:46,718 this section of maybe 24 pixels. Save 6359 04:41:43,840 --> 04:41:48,798 it. And I think that's a little too 6360 04:41:46,718 --> 04:41:51,120 much. I can't really tell. Let's set it 6361 04:41:48,798 --> 04:41:54,240 to 20 just to be safe. Okay. So, I'm 6362 04:41:51,120 --> 04:41:55,920 happy with how this looks. 6363 04:41:54,240 --> 04:41:58,560 All right. So, that's basically the 6364 04:41:55,920 --> 04:42:00,798 content and our header. If we look at it 6365 04:41:58,560 --> 04:42:02,400 right now, it looks really professional. 6366 04:42:00,798 --> 04:42:04,000 So, I know that while we were working on 6367 04:42:02,400 --> 04:42:05,680 it, it looked a little bit weird. It 6368 04:42:04,000 --> 04:42:07,760 looked unfinished, but you just got to 6369 04:42:05,680 --> 04:42:09,920 trust the process and at the end we have 6370 04:42:07,760 --> 04:42:12,000 a really professional result that looks 6371 04:42:09,920 --> 04:42:14,000 like our design. 6372 04:42:12,000 --> 04:42:16,560 Now, there's going to be one last case 6373 04:42:14,000 --> 04:42:19,840 I'm going to show you. And this is a 6374 04:42:16,560 --> 04:42:23,120 weird behavior of flexbox. So, if I 6375 04:42:19,840 --> 04:42:25,360 resize my browser and I make it smaller, 6376 04:42:23,120 --> 04:42:28,560 notice that these icons start to get 6377 04:42:25,360 --> 04:42:30,958 closer to each other. 6378 04:42:28,560 --> 04:42:33,120 So, this happens because flexbox is 6379 04:42:30,958 --> 04:42:35,440 flexible. when we start not having 6380 04:42:33,120 --> 04:42:37,520 enough space, it'll start shrinking the 6381 04:42:35,440 --> 04:42:40,320 items inside. 6382 04:42:37,520 --> 04:42:42,878 But if we look at our final project and 6383 04:42:40,320 --> 04:42:45,120 we shrink the browser, notice that this 6384 04:42:42,878 --> 04:42:48,718 doesn't shrink and we sort of forced 6385 04:42:45,120 --> 04:42:50,560 only the search bar to shrink. 6386 04:42:48,718 --> 04:42:53,520 So, let's go back into our project and 6387 04:42:50,560 --> 04:42:55,840 into our code. And flexbox has a special 6388 04:42:53,520 --> 04:42:57,840 property to prevent certain items from 6389 04:42:55,840 --> 04:43:01,040 shrinking. So, we're going to scroll 6390 04:42:57,840 --> 04:43:02,958 down to the right section here. 6391 04:43:01,040 --> 04:43:05,120 And to prevent the right section from 6392 04:43:02,958 --> 04:43:06,878 shrinking, we're just going to set this 6393 04:43:05,120 --> 04:43:11,600 property 6394 04:43:06,878 --> 04:43:13,440 flex dash shrink colon zero. So this 6395 04:43:11,600 --> 04:43:15,040 means that no matter what happens, we're 6396 04:43:13,440 --> 04:43:16,958 going to keep this width and we're not 6397 04:43:15,040 --> 04:43:19,760 going to shrink. So zero means don't 6398 04:43:16,958 --> 04:43:23,600 shrink. If we save it, now you're going 6399 04:43:19,760 --> 04:43:25,680 to see that it doesn't shrink. 6400 04:43:23,600 --> 04:43:27,440 But now when we resize it, notice that 6401 04:43:25,680 --> 04:43:30,878 the search bar doesn't actually shrink 6402 04:43:27,440 --> 04:43:34,560 all the way like our design. So, the way 6403 04:43:30,878 --> 04:43:37,200 to achieve this is to go into our HTML 6404 04:43:34,560 --> 04:43:41,280 and then we're going to go into our 6405 04:43:37,200 --> 04:43:43,360 search bar, which is right here. 6406 04:43:41,280 --> 04:43:45,360 So, normally search bars have a default 6407 04:43:43,360 --> 04:43:48,400 width, and we can't really see that 6408 04:43:45,360 --> 04:43:50,080 because we set flex to one. 6409 04:43:48,400 --> 04:43:51,760 So, it's sort of growing with the page, 6410 04:43:50,080 --> 04:43:53,200 but as soon as it hits that default 6411 04:43:51,760 --> 04:43:55,760 width, it's not going to go down 6412 04:43:53,200 --> 04:44:00,480 anymore. So to remove that default 6413 04:43:55,760 --> 04:44:02,560 width, we can just set width to zero. We 6414 04:44:00,480 --> 04:44:05,040 save it. And now you can see that the 6415 04:44:02,560 --> 04:44:07,520 search box will start shrinking as much 6416 04:44:05,040 --> 04:44:10,400 as possible. 6417 04:44:07,520 --> 04:44:12,400 So to recap, we set flex shrink of zero 6418 04:44:10,400 --> 04:44:14,958 to this right section so it doesn't 6419 04:44:12,400 --> 04:44:16,878 shrink. And then we set a width of zero 6420 04:44:14,958 --> 04:44:19,120 to the search bar so that it does 6421 04:44:16,878 --> 04:44:21,280 shrink. 6422 04:44:19,120 --> 04:44:22,798 Here 6423 04:44:21,280 --> 04:44:25,120 are some exercises to get yourself 6424 04:44:22,798 --> 04:44:28,840 familiar with using flexbox to create 6425 04:44:25,120 --> 04:44:28,840 flexible layouts. 6426 04:44:39,680 --> 04:44:43,360 Now, we're going to learn the last major 6427 04:44:41,520 --> 04:44:45,360 skill that we need to finish off our 6428 04:44:43,360 --> 04:44:47,760 project. We're going to learn CSS 6429 04:44:45,360 --> 04:44:49,600 position. So position helps us do things 6430 04:44:47,760 --> 04:44:52,160 like keep the header at the top of the 6431 04:44:49,600 --> 04:44:54,798 page while we scroll. It also helps us 6432 04:44:52,160 --> 04:44:56,718 keep the sidebar at the top of the page. 6433 04:44:54,798 --> 04:44:59,040 And lastly, whenever we see an element 6434 04:44:56,718 --> 04:45:01,760 on top of another element that's using 6435 04:44:59,040 --> 04:45:04,320 CSS position, for example, here the 6436 04:45:01,760 --> 04:45:06,480 video time is on top of the thumbnail, 6437 04:45:04,320 --> 04:45:08,718 the notification number is on top of the 6438 04:45:06,480 --> 04:45:12,240 icon. And when I hover over this, we 6439 04:45:08,718 --> 04:45:14,560 have a tool tip on top of the page. So 6440 04:45:12,240 --> 04:45:16,240 CSS position adds another dimension to 6441 04:45:14,560 --> 04:45:17,760 our page. 6442 04:45:16,240 --> 04:45:19,920 So, just like the previous lessons, 6443 04:45:17,760 --> 04:45:22,320 we're going to create a new HTML file 6444 04:45:19,920 --> 04:45:25,040 just to practice position. I'm going to 6445 04:45:22,320 --> 04:45:28,240 go into my code editor. Um, we're going 6446 04:45:25,040 --> 04:45:30,958 to create a new file. And let's put it 6447 04:45:28,240 --> 04:45:35,400 right here beside the other ones. New 6448 04:45:30,958 --> 04:45:35,400 file. Let's call this position.html. 6449 04:45:36,878 --> 04:45:40,798 Now, as always, we're going to start 6450 04:45:38,240 --> 04:45:43,280 with the HTML structure. So we're going 6451 04:45:40,798 --> 04:45:47,520 to have dock type 6452 04:45:43,280 --> 04:45:50,638 at the top and then an HTML element. 6453 04:45:47,520 --> 04:45:54,600 Inside we have a head element and then 6454 04:45:50,638 --> 04:45:54,600 we have a body element. 6455 04:45:55,040 --> 04:45:59,360 Now we can rightclick and open with live 6456 04:45:57,760 --> 04:46:02,080 server 6457 04:45:59,360 --> 04:46:05,440 and we're ready to begin. So first let's 6458 04:46:02,080 --> 04:46:07,920 add a title so that we know what this 6459 04:46:05,440 --> 04:46:11,440 HTML file is for. Let's call this 6460 04:46:07,920 --> 04:46:11,440 position practice. 6461 04:46:12,000 --> 04:46:18,000 save it and then it should show up here. 6462 04:46:15,440 --> 04:46:20,718 We're going to start in the body again 6463 04:46:18,000 --> 04:46:24,878 and we're going to create two divs. 6464 04:46:20,718 --> 04:46:27,040 Let's call this div one and another div 6465 04:46:24,878 --> 04:46:28,878 div 2. 6466 04:46:27,040 --> 04:46:30,798 And I'm just going to resize this a 6467 04:46:28,878 --> 04:46:33,798 little bit so we can see it side by 6468 04:46:30,798 --> 04:46:33,798 side. 6469 04:46:37,440 --> 04:46:41,360 So, just like before, we're going to use 6470 04:46:38,958 --> 04:46:44,000 inline styles so that our CSS is close 6471 04:46:41,360 --> 04:46:46,718 to our HTML code. I'm going to set a 6472 04:46:44,000 --> 04:46:48,560 style. 6473 04:46:46,718 --> 04:46:53,840 And then we're going to set this one to 6474 04:46:48,560 --> 04:46:55,200 background dash color and light blue. 6475 04:46:53,840 --> 04:46:58,400 And we're going to set the height and 6476 04:46:55,200 --> 04:47:02,958 the width to 200 pixels. So, height 200 6477 04:46:58,400 --> 04:47:04,878 pixels and width 200 pixels. 6478 04:47:02,958 --> 04:47:06,878 Next, we're going to set the second div 6479 04:47:04,878 --> 04:47:09,440 to be the same size but with background 6480 04:47:06,878 --> 04:47:11,520 color light pink. So again, we set a 6481 04:47:09,440 --> 04:47:14,400 style 6482 04:47:11,520 --> 04:47:17,040 and then we set a background dash color 6483 04:47:14,400 --> 04:47:21,520 of light pink, 6484 04:47:17,040 --> 04:47:24,400 height of 200 pixels, and width of 200 6485 04:47:21,520 --> 04:47:26,798 pixels. 6486 04:47:24,400 --> 04:47:28,878 So CSS position is just the position 6487 04:47:26,798 --> 04:47:31,360 property. So let's go into our first 6488 04:47:28,878 --> 04:47:32,878 div. I'm going to set the position 6489 04:47:31,360 --> 04:47:36,718 property 6490 04:47:32,878 --> 04:47:40,160 to to static 6491 04:47:36,718 --> 04:47:42,400 and then save. So position static is the 6492 04:47:40,160 --> 04:47:45,600 default position. It's the same thing as 6493 04:47:42,400 --> 04:47:47,040 if you don't have this line at all. 6494 04:47:45,600 --> 04:47:49,600 Now we're going to learn a second 6495 04:47:47,040 --> 04:47:51,680 position property that allows us to 6496 04:47:49,600 --> 04:47:54,480 stick an element to the top of the page 6497 04:47:51,680 --> 04:47:56,798 like this while we scroll. And that is 6498 04:47:54,480 --> 04:48:00,000 called position fixed. So we're going to 6499 04:47:56,798 --> 04:48:02,080 create a new element at the top here. 6500 04:48:00,000 --> 04:48:03,280 and let's call this our header. So, 6501 04:48:02,080 --> 04:48:07,040 we're going to learn how to create 6502 04:48:03,280 --> 04:48:08,878 something that works like this. 6503 04:48:07,040 --> 04:48:11,280 So, for this div, we're going to set a 6504 04:48:08,878 --> 04:48:14,480 style 6505 04:48:11,280 --> 04:48:20,280 of background color 6506 04:48:14,480 --> 04:48:20,280 black and a text color of white. 6507 04:48:21,600 --> 04:48:25,920 And now we're going to learn how to 6508 04:48:23,040 --> 04:48:27,360 stick this to the top of the page. So, 6509 04:48:25,920 --> 04:48:28,958 first of all, we need to be able to 6510 04:48:27,360 --> 04:48:31,520 scroll. And right now I don't have 6511 04:48:28,958 --> 04:48:33,840 enough content to make the page scroll. 6512 04:48:31,520 --> 04:48:36,958 So what I'll do is we'll go to the body 6513 04:48:33,840 --> 04:48:38,560 here and we're going to set a style. 6514 04:48:36,958 --> 04:48:41,520 And then inside the body we're going to 6515 04:48:38,560 --> 04:48:45,840 set a style of height and something 6516 04:48:41,520 --> 04:48:47,360 really big like 3,000 pixels. 6517 04:48:45,840 --> 04:48:50,480 So we just need to make sure that we're 6518 04:48:47,360 --> 04:48:51,920 able to scroll this page. Next we're 6519 04:48:50,480 --> 04:48:54,240 going to make this header stick at the 6520 04:48:51,920 --> 04:48:56,240 top. To do that we're going to use the 6521 04:48:54,240 --> 04:49:00,718 position property. And this time we're 6522 04:48:56,240 --> 04:49:02,400 going to set a position of fixed. 6523 04:49:00,718 --> 04:49:04,718 Now when I save it and I start 6524 04:49:02,400 --> 04:49:07,440 scrolling, notice how the header element 6525 04:49:04,718 --> 04:49:10,400 is sticking to the page when I scroll. 6526 04:49:07,440 --> 04:49:12,240 So that's how we make it stick. 6527 04:49:10,400 --> 04:49:14,638 So the first thing to note is that when 6528 04:49:12,240 --> 04:49:16,000 we set position fixed like this, it 6529 04:49:14,638 --> 04:49:19,200 doesn't take up space on the page 6530 04:49:16,000 --> 04:49:21,920 anymore. So before we had this and if I 6531 04:49:19,200 --> 04:49:23,920 save it, so notice that it takes up the 6532 04:49:21,920 --> 04:49:26,480 top of the page and then these two divs 6533 04:49:23,920 --> 04:49:29,040 up appear below this header. But when we 6534 04:49:26,480 --> 04:49:31,040 add position fixed, 6535 04:49:29,040 --> 04:49:32,878 it no longer takes up that space at the 6536 04:49:31,040 --> 04:49:35,280 top of the page because it's sort of 6537 04:49:32,878 --> 04:49:37,680 floating above the page now. So that's 6538 04:49:35,280 --> 04:49:39,520 one way to think about it. So the 6539 04:49:37,680 --> 04:49:41,680 position property has four special 6540 04:49:39,520 --> 04:49:44,320 properties we can use to move this 6541 04:49:41,680 --> 04:49:45,840 element around. The first one is called 6542 04:49:44,320 --> 04:49:47,600 top. 6543 04:49:45,840 --> 04:49:49,920 The way that top works is that we can 6544 04:49:47,600 --> 04:49:52,480 set a pixel measurement. For example, if 6545 04:49:49,920 --> 04:49:54,480 we set 0 pixels, 6546 04:49:52,480 --> 04:49:57,280 this is going to make the top of our 6547 04:49:54,480 --> 04:50:01,120 element 0 pixels from the top of our 6548 04:49:57,280 --> 04:50:02,878 browser window here. So, if I save it, 6549 04:50:01,120 --> 04:50:05,120 notice that the top of our element is 6550 04:50:02,878 --> 04:50:09,120 right on the top edge of the browser 6551 04:50:05,120 --> 04:50:11,440 window. If I set top to 10 pixels, 6552 04:50:09,120 --> 04:50:14,160 the top of our element is now 10 pixels 6553 04:50:11,440 --> 04:50:16,958 from the top of the browser window. So 6554 04:50:14,160 --> 04:50:20,798 top specifies how far away our element 6555 04:50:16,958 --> 04:50:24,240 is from the top of the window. 6556 04:50:20,798 --> 04:50:27,760 The next property we can set is left. So 6557 04:50:24,240 --> 04:50:29,600 if we set left to 0 pixels, 6558 04:50:27,760 --> 04:50:32,638 then the left side of our element will 6559 04:50:29,600 --> 04:50:36,160 be on the left edge of our window. If we 6560 04:50:32,638 --> 04:50:37,920 set left to 50 pixels, for example, 6561 04:50:36,160 --> 04:50:40,400 now the left side of our element will be 6562 04:50:37,920 --> 04:50:42,480 50 pixels from the left of our window. 6563 04:50:40,400 --> 04:50:44,798 So left tells us how much space is 6564 04:50:42,480 --> 04:50:46,798 between the element and the left edge of 6565 04:50:44,798 --> 04:50:48,480 the window. 6566 04:50:46,798 --> 04:50:51,920 So we can set this in all four 6567 04:50:48,480 --> 04:50:55,360 directions. We've seen top left. We can 6568 04:50:51,920 --> 04:50:57,920 also set bottom and right. Now a special 6569 04:50:55,360 --> 04:50:59,920 feature of these properties is that if 6570 04:50:57,920 --> 04:51:02,958 we set it in opposite directions, the 6571 04:50:59,920 --> 04:51:05,520 element will stretch. So for example, if 6572 04:51:02,958 --> 04:51:07,600 we set it to left and right, so these 6573 04:51:05,520 --> 04:51:10,480 two are opposite directions and we set 6574 04:51:07,600 --> 04:51:13,360 the right to 50 pixels. Notice that the 6575 04:51:10,480 --> 04:51:16,240 element stretches. So now this element 6576 04:51:13,360 --> 04:51:18,958 is 50 pixels from the left of the page 6577 04:51:16,240 --> 04:51:21,440 right here. And it is also 50 pixels 6578 04:51:18,958 --> 04:51:23,600 from the right of the page. So it will 6579 04:51:21,440 --> 04:51:25,920 stretch the element to meet these two 6580 04:51:23,600 --> 04:51:28,400 conditions. 6581 04:51:25,920 --> 04:51:32,638 Same thing with top and bottom. So if I 6582 04:51:28,400 --> 04:51:34,560 set bottom to 100 pixels and save it, 6583 04:51:32,638 --> 04:51:37,200 the element will stretch so that it is 6584 04:51:34,560 --> 04:51:40,718 10 pixels from the top and it is 100 6585 04:51:37,200 --> 04:51:42,638 pixels from the bottom. 6586 04:51:40,718 --> 04:51:45,040 So this is how we move this element 6587 04:51:42,638 --> 04:51:48,560 around and resize it with position 6588 04:51:45,040 --> 04:51:51,280 fixed. Now let's try creating the header 6589 04:51:48,560 --> 04:51:53,360 that we see here. So as you can see for 6590 04:51:51,280 --> 04:51:56,160 this header, it's at the top edge of the 6591 04:51:53,360 --> 04:51:59,200 page. It's also on the left edge and on 6592 04:51:56,160 --> 04:52:02,160 the right edge. So that means that it's 6593 04:51:59,200 --> 04:52:04,958 0 pixels from the top. As a shorthand, 6594 04:52:02,160 --> 04:52:07,680 we can just write zero. It's zero pixels 6595 04:52:04,958 --> 04:52:10,160 from the left and it's zero pixels from 6596 04:52:07,680 --> 04:52:12,638 the right. 6597 04:52:10,160 --> 04:52:14,878 Now for the bottom, we might first try 6598 04:52:12,638 --> 04:52:17,120 to calculate how far the bottom of this 6599 04:52:14,878 --> 04:52:18,560 element is from the bottom of the page. 6600 04:52:17,120 --> 04:52:20,718 Now that's not going to work if we 6601 04:52:18,560 --> 04:52:24,000 resize the page. So we need a different 6602 04:52:20,718 --> 04:52:26,638 approach. So first let's save this file 6603 04:52:24,000 --> 04:52:28,000 and go into our practice file. So now 6604 04:52:26,638 --> 04:52:30,240 you can see that this element is 6605 04:52:28,000 --> 04:52:31,760 sticking to the top, the left and the 6606 04:52:30,240 --> 04:52:33,760 right, which is what we have in our 6607 04:52:31,760 --> 04:52:36,240 code. Now we have to figure out the 6608 04:52:33,760 --> 04:52:38,718 height of this div. So in this case 6609 04:52:36,240 --> 04:52:41,760 instead of using bottom because remember 6610 04:52:38,718 --> 04:52:47,320 the bottom can resize 6611 04:52:41,760 --> 04:52:47,320 we want to use simply height. 6612 04:52:47,440 --> 04:52:51,920 So in addition to these properties we 6613 04:52:49,360 --> 04:52:54,240 can simply use height and width to also 6614 04:52:51,920 --> 04:52:56,400 resize this element. It all depends on 6615 04:52:54,240 --> 04:52:58,320 what situation you're in. If you want 6616 04:52:56,400 --> 04:53:00,718 this fixed element to resize with the 6617 04:52:58,320 --> 04:53:02,560 page then you would use top, left, 6618 04:53:00,718 --> 04:53:04,798 right, and bottom. If you just want it 6619 04:53:02,560 --> 04:53:06,638 to have a specific height or width and 6620 04:53:04,798 --> 04:53:08,798 you don't want it to resize, then you 6621 04:53:06,638 --> 04:53:12,560 use height and width. So here we're 6622 04:53:08,798 --> 04:53:14,080 going to set the height to 50 pixels and 6623 04:53:12,560 --> 04:53:16,000 we don't want it to resize with the 6624 04:53:14,080 --> 04:53:18,480 page. So that's exactly what we have 6625 04:53:16,000 --> 04:53:20,798 here. Now when we start scrolling, 6626 04:53:18,480 --> 04:53:22,798 you'll notice that our header sticks to 6627 04:53:20,798 --> 04:53:25,120 the top of the page. So that's how we 6628 04:53:22,798 --> 04:53:27,600 create something like the YouTube header 6629 04:53:25,120 --> 04:53:29,440 that we see here. 6630 04:53:27,600 --> 04:53:31,680 Now, one last problem is that if we go 6631 04:53:29,440 --> 04:53:33,840 to our practice file, notice that if we 6632 04:53:31,680 --> 04:53:36,240 scroll right to the top, the header is 6633 04:53:33,840 --> 04:53:39,040 covering our first div. So, we need to 6634 04:53:36,240 --> 04:53:42,240 add some spacing at the top to push our 6635 04:53:39,040 --> 04:53:44,718 content down below the header. 6636 04:53:42,240 --> 04:53:46,480 To do that, we can go into our code and 6637 04:53:44,718 --> 04:53:49,760 the first thing you might think to do is 6638 04:53:46,480 --> 04:53:51,600 to add margin to the top. So, we're 6639 04:53:49,760 --> 04:53:53,520 going to add spacing to the top and 6640 04:53:51,600 --> 04:53:56,000 let's add a little more than 50 pixels. 6641 04:53:53,520 --> 04:53:58,638 So, 60 pixels. 6642 04:53:56,000 --> 04:54:00,638 So, if we save it and make sure you 6643 04:53:58,638 --> 04:54:03,040 scroll up all the way to the top of the 6644 04:54:00,638 --> 04:54:05,360 page, you'll notice that we have 60 6645 04:54:03,040 --> 04:54:08,878 pixels of space at the top. And now our 6646 04:54:05,360 --> 04:54:10,560 content is not covered by the header. 6647 04:54:08,878 --> 04:54:13,280 Now, this is not the best solution 6648 04:54:10,560 --> 04:54:15,600 because if our content order changes, 6649 04:54:13,280 --> 04:54:17,120 for example, if I move this div down 6650 04:54:15,600 --> 04:54:19,360 here, 6651 04:54:17,120 --> 04:54:21,360 notice that it doesn't work anymore. So, 6652 04:54:19,360 --> 04:54:23,760 what we want instead is to always have 6653 04:54:21,360 --> 04:54:26,080 space at the top of our page regardless 6654 04:54:23,760 --> 04:54:29,520 of what the content is. So, if I move 6655 04:54:26,080 --> 04:54:31,760 this to the top here 6656 04:54:29,520 --> 04:54:36,120 and remove margin top, I'm going to show 6657 04:54:31,760 --> 04:54:36,120 you the proper way to do this. 6658 04:54:36,718 --> 04:54:40,958 So, to properly handle this situation, 6659 04:54:38,638 --> 04:54:43,120 we need to add spacing to the body 6660 04:54:40,958 --> 04:54:45,920 element. So, let's scroll up to the 6661 04:54:43,120 --> 04:54:48,080 body. So, we have two choices for adding 6662 04:54:45,920 --> 04:54:52,000 space to the top of our page. We can 6663 04:54:48,080 --> 04:54:53,920 either use margin or we can use padding. 6664 04:54:52,000 --> 04:54:56,878 Generally, the best practice is to use 6665 04:54:53,920 --> 04:54:59,520 padding at the top. So, we're just going 6666 04:54:56,878 --> 04:55:04,000 to add spacing on the inside of our web 6667 04:54:59,520 --> 04:55:07,120 page at the top of 60 pixels. Let's save 6668 04:55:04,000 --> 04:55:09,040 it and scroll all the way up. 6669 04:55:07,120 --> 04:55:10,958 And now we have plenty of space at the 6670 04:55:09,040 --> 04:55:14,240 top of the page. And our header is not 6671 04:55:10,958 --> 04:55:16,160 covering our contents. 6672 04:55:14,240 --> 04:55:17,920 So, now that we learned position fixed 6673 04:55:16,160 --> 04:55:20,080 and how to move this element around and 6674 04:55:17,920 --> 04:55:22,240 resize it, we're going to go into the 6675 04:55:20,080 --> 04:55:25,120 project we were currently working on. 6676 04:55:22,240 --> 04:55:27,600 And we're going to put our header and 6677 04:55:25,120 --> 04:55:30,160 stick it to the top of the page. So, 6678 04:55:27,600 --> 04:55:31,840 let's learn how to do that. First, I'm 6679 04:55:30,160 --> 04:55:34,160 going to resize my windows a little bit 6680 04:55:31,840 --> 04:55:36,400 so it's easier to work with. I'm going 6681 04:55:34,160 --> 04:55:39,120 to put it right here. And then, we're 6682 04:55:36,400 --> 04:55:42,000 going to open the YouTube.html file, 6683 04:55:39,120 --> 04:55:44,000 which is our project. 6684 04:55:42,000 --> 04:55:45,760 So, remember we put our CSS into 6685 04:55:44,000 --> 04:55:48,638 separate files. So, I'm going to open 6686 04:55:45,760 --> 04:55:50,638 the header.css file and I'll put it on 6687 04:55:48,638 --> 04:55:52,560 the side so you guys can see it side by 6688 04:55:50,638 --> 04:55:54,480 side. 6689 04:55:52,560 --> 04:55:56,798 So, just like we learned, we're going to 6690 04:55:54,480 --> 04:56:01,040 go into the header here. We're going to 6691 04:55:56,798 --> 04:56:03,040 set a style of position fixed. And 6692 04:56:01,040 --> 04:56:06,560 remember to move this. We're going to 6693 04:56:03,040 --> 04:56:08,958 use top, left, bottom, and right. So, 6694 04:56:06,560 --> 04:56:10,718 top. We want our header to stick to the 6695 04:56:08,958 --> 04:56:12,718 top of the page. We're going to set that 6696 04:56:10,718 --> 04:56:15,200 to zero. 6697 04:56:12,718 --> 04:56:17,360 We want our header 0 pixels from the 6698 04:56:15,200 --> 04:56:21,958 left, so on the left edge of the page, 6699 04:56:17,360 --> 04:56:21,958 and also 0 pixels from the right. 6700 04:56:22,080 --> 04:56:25,840 And finally, we're going to set a 6701 04:56:23,360 --> 04:56:29,920 height. So, we already have it up here. 6702 04:56:25,840 --> 04:56:31,520 So, let's save it and see how it looks. 6703 04:56:29,920 --> 04:56:33,840 So, the first thing we notice is that we 6704 04:56:31,520 --> 04:56:35,520 lost our background color. Now, the only 6705 04:56:33,840 --> 04:56:37,440 reason we had a background color was 6706 04:56:35,520 --> 04:56:39,840 because if we didn't have position 6707 04:56:37,440 --> 04:56:42,000 fixed, this header takes space on the 6708 04:56:39,840 --> 04:56:43,760 page and the page just happens to be 6709 04:56:42,000 --> 04:56:46,320 white. So, the header appears to be 6710 04:56:43,760 --> 04:56:47,920 white. But now that it's floating above 6711 04:56:46,320 --> 04:56:50,240 the page, we'll notice that it's 6712 04:56:47,920 --> 04:56:52,320 actually transparent. 6713 04:56:50,240 --> 04:56:54,718 So, to add our background color again, 6714 04:56:52,320 --> 04:56:56,320 we just need to set the background color 6715 04:56:54,718 --> 04:57:00,000 property. 6716 04:56:56,320 --> 04:57:02,798 So, let's set this to white. Save it. 6717 04:57:00,000 --> 04:57:04,638 And now we're back to where we were. 6718 04:57:02,798 --> 04:57:06,638 Now, if we go to our project and we 6719 04:57:04,638 --> 04:57:08,160 start scrolling, you'll notice that our 6720 04:57:06,638 --> 04:57:11,040 header sticks to the top while we 6721 04:57:08,160 --> 04:57:12,400 scroll. So, that's exactly what we want. 6722 04:57:11,040 --> 04:57:15,600 Next, we have this problem where the 6723 04:57:12,400 --> 04:57:17,760 header is covering our content. 6724 04:57:15,600 --> 04:57:20,798 So, remember the way to fix this is to 6725 04:57:17,760 --> 04:57:22,958 add padding to the top of our body. 6726 04:57:20,798 --> 04:57:25,840 We're going to go into our code and 6727 04:57:22,958 --> 04:57:27,520 we're going to go into this file, 6728 04:57:25,840 --> 04:57:29,280 general.css. 6729 04:57:27,520 --> 04:57:30,878 That's where we have styles for the 6730 04:57:29,280 --> 04:57:32,160 body. 6731 04:57:30,878 --> 04:57:33,760 And then we're going to set a 6732 04:57:32,160 --> 04:57:37,760 padding-ash 6733 04:57:33,760 --> 04:57:41,360 top of maybe 60 pixels. Let's take a 6734 04:57:37,760 --> 04:57:43,520 look. Okay, so that looks pretty good. 6735 04:57:41,360 --> 04:57:46,320 Let's compare to our design. If I scroll 6736 04:57:43,520 --> 04:57:48,240 to the top here and just compare it a 6737 04:57:46,320 --> 04:57:51,040 little bit, I notice that our videos are 6738 04:57:48,240 --> 04:57:52,480 appearing at a higher position than our 6739 04:57:51,040 --> 04:57:56,240 design. So, we're going to push them 6740 04:57:52,480 --> 04:57:59,440 down a little more. Let's set this to 6741 04:57:56,240 --> 04:58:02,000 maybe 80 pixels. Save it. So, we push 6742 04:57:59,440 --> 04:58:03,680 them down even more. 6743 04:58:02,000 --> 04:58:06,560 And I think that looks close enough to 6744 04:58:03,680 --> 04:58:08,000 our design. 6745 04:58:06,560 --> 04:58:10,400 So, the last thing I notice is that 6746 04:58:08,000 --> 04:58:12,240 we're missing the border at the bottom 6747 04:58:10,400 --> 04:58:15,718 of our header here. So, let's go ahead 6748 04:58:12,240 --> 04:58:15,718 and add that. 6749 04:58:15,920 --> 04:58:19,440 So, let's go back into our header CSS. 6750 04:58:18,160 --> 04:58:21,600 We're going to add a border to the 6751 04:58:19,440 --> 04:58:23,920 bottom. So, we can actually add borders 6752 04:58:21,600 --> 04:58:26,638 to one side at a time. We don't have to 6753 04:58:23,920 --> 04:58:28,798 add borders to all four sides. To do 6754 04:58:26,638 --> 04:58:30,480 that, we're going to set the same border 6755 04:58:28,798 --> 04:58:33,280 properties we had before. So, we're 6756 04:58:30,480 --> 04:58:34,878 going to start with border width, but in 6757 04:58:33,280 --> 04:58:38,480 the middle, we're going to tell it a 6758 04:58:34,878 --> 04:58:40,718 direction. So, we can tell it bottom. We 6759 04:58:38,480 --> 04:58:43,120 can also tell it top, left, and right. 6760 04:58:40,718 --> 04:58:44,878 So, we have all these four directions. 6761 04:58:43,120 --> 04:58:47,120 In this case, we want a border at the 6762 04:58:44,878 --> 04:58:49,840 bottom. And we're going to set it to 1 6763 04:58:47,120 --> 04:58:53,200 pixels. And the other border properties 6764 04:58:49,840 --> 04:58:55,360 are the same. So border style, it's 6765 04:58:53,200 --> 04:58:56,798 going to be solid, but we only want it 6766 04:58:55,360 --> 04:58:59,120 at the bottom. So it's going to be 6767 04:58:56,798 --> 04:59:02,560 border bottom style. 6768 04:58:59,120 --> 04:59:06,000 And then lastly, border dashbottom dash 6769 04:59:02,560 --> 04:59:08,638 color. And let's set it to gray. And I'm 6770 04:59:06,000 --> 04:59:11,920 going to pick a lighter shade of gray. 6771 04:59:08,638 --> 04:59:14,480 So maybe right there. 6772 04:59:11,920 --> 04:59:16,080 Save it. Let's compare it to our design. 6773 04:59:14,480 --> 04:59:18,160 So looks like it's a little darker than 6774 04:59:16,080 --> 04:59:20,400 what we have. Just going to adjust the 6775 04:59:18,160 --> 04:59:22,400 color to match our design. 6776 04:59:20,400 --> 04:59:24,400 It's not going to be perfect, but 6777 04:59:22,400 --> 04:59:27,040 remember, you can always inspect the 6778 04:59:24,400 --> 04:59:29,280 design and then make it perfect. 6779 04:59:27,040 --> 04:59:31,520 Okay, so now if I compare it, I think 6780 04:59:29,280 --> 04:59:33,920 that looks pretty close enough. And now 6781 04:59:31,520 --> 04:59:35,760 if I scroll, you notice that the header 6782 04:59:33,920 --> 04:59:38,400 is sticking to the top, which is exactly 6783 04:59:35,760 --> 04:59:39,760 what we want. 6784 04:59:38,400 --> 04:59:42,320 Next, we're going to learn how to create 6785 04:59:39,760 --> 04:59:44,000 this sidebar. So the sidebar is just 6786 04:59:42,320 --> 04:59:45,760 like the header. It sticks while we 6787 04:59:44,000 --> 04:59:48,080 scroll. 6788 04:59:45,760 --> 04:59:50,000 So this is another example of position 6789 04:59:48,080 --> 04:59:53,440 fixed. We're going to go back to our 6790 04:59:50,000 --> 04:59:56,000 practice file and I'll resize my pages 6791 04:59:53,440 --> 04:59:59,440 here 6792 04:59:56,000 --> 05:00:01,920 and I'm going to open position.html we 6793 04:59:59,440 --> 05:00:03,520 were practicing with and this time below 6794 05:00:01,920 --> 05:00:06,878 the header we're going to create our 6795 05:00:03,520 --> 05:00:10,718 sidebar. So let's create a div and this 6796 05:00:06,878 --> 05:00:14,160 div is going to be our sidebar. 6797 05:00:10,718 --> 05:00:15,920 Now, for the sidebar, let's set a style. 6798 05:00:14,160 --> 05:00:18,878 And then inside, we're going to set a 6799 05:00:15,920 --> 05:00:22,400 background color of green this time. So, 6800 05:00:18,878 --> 05:00:24,878 a background dash color green and a text 6801 05:00:22,400 --> 05:00:26,400 color of white so that it's easier to 6802 05:00:24,878 --> 05:00:29,600 distinguish between all of these 6803 05:00:26,400 --> 05:00:31,360 different elements. 6804 05:00:29,600 --> 05:00:33,440 Next, we're going to stick the sidebar 6805 05:00:31,360 --> 05:00:36,000 to our browser. So, remember to do that, 6806 05:00:33,440 --> 05:00:39,440 we're going to use position fixed. So, 6807 05:00:36,000 --> 05:00:42,000 position fixed 6808 05:00:39,440 --> 05:00:43,520 and save it. And now, when we scroll, 6809 05:00:42,000 --> 05:00:47,520 you'll notice that the sidebar is 6810 05:00:43,520 --> 05:00:49,200 sticking to our browser while we scroll. 6811 05:00:47,520 --> 05:00:51,280 Lastly, we're going to put the sidebar 6812 05:00:49,200 --> 05:00:54,160 in the right place using top, left, 6813 05:00:51,280 --> 05:00:56,638 right, height, or width. So, let's look 6814 05:00:54,160 --> 05:00:58,958 at our sidebar in our design. We notice 6815 05:00:56,638 --> 05:01:01,200 that the sidebar is sticking to the 6816 05:00:58,958 --> 05:01:03,120 bottom, so we want bottom zero. It's 6817 05:01:01,200 --> 05:01:05,440 sticking to the left, so we want left 6818 05:01:03,120 --> 05:01:07,200 zero. And for the top, it's actually not 6819 05:01:05,440 --> 05:01:10,400 reaching to the top of the page. 6820 05:01:07,200 --> 05:01:11,840 Otherwise, it would cover up the header. 6821 05:01:10,400 --> 05:01:14,160 So, there's quite a difference between 6822 05:01:11,840 --> 05:01:15,920 the sidebar here and the top of the 6823 05:01:14,160 --> 05:01:17,920 page. So, let's go back into our 6824 05:01:15,920 --> 05:01:20,920 practice file and learn how to position 6825 05:01:17,920 --> 05:01:20,920 that. 6826 05:01:20,958 --> 05:01:24,878 Let's start with left. We want the 6827 05:01:23,200 --> 05:01:27,040 sidebar to stick to the left side of the 6828 05:01:24,878 --> 05:01:30,240 page. So, we're going to say 0 pixels 6829 05:01:27,040 --> 05:01:32,080 from the left. Save it. Now, we want our 6830 05:01:30,240 --> 05:01:35,280 sidebar to stick to the bottom of the 6831 05:01:32,080 --> 05:01:38,560 page. So, we're going to say bottom and 6832 05:01:35,280 --> 05:01:40,400 zero pixels from the bottom. 6833 05:01:38,560 --> 05:01:42,638 And finally, we want it to be at the top 6834 05:01:40,400 --> 05:01:45,840 of the page, but not cover the header. 6835 05:01:42,638 --> 05:01:48,240 So, let's set the top to 6836 05:01:45,840 --> 05:01:50,638 uh 50 pixels, right? So, it's going to 6837 05:01:48,240 --> 05:01:53,200 meet right where the header ends. We're 6838 05:01:50,638 --> 05:01:55,920 going to set this to 50 pixels 6839 05:01:53,200 --> 05:01:57,920 and then save. 6840 05:01:55,920 --> 05:02:00,240 And finally, we want to set the width of 6841 05:01:57,920 --> 05:02:03,600 the sidebar. So for the sidebar, we 6842 05:02:00,240 --> 05:02:05,360 don't want it to resize with the page. 6843 05:02:03,600 --> 05:02:08,320 So that's why we're going to use the 6844 05:02:05,360 --> 05:02:10,320 width property instead of something like 6845 05:02:08,320 --> 05:02:12,798 right. 6846 05:02:10,320 --> 05:02:14,798 So let's go back into our practice file 6847 05:02:12,798 --> 05:02:19,920 and we're going to set the width to 6848 05:02:14,798 --> 05:02:21,760 maybe 72 pixels. Save it. And that looks 6849 05:02:19,920 --> 05:02:24,000 like what we have in our design. So 6850 05:02:21,760 --> 05:02:26,878 that's perfect. Now we have the same 6851 05:02:24,000 --> 05:02:29,040 problem again where our fixed element is 6852 05:02:26,878 --> 05:02:32,080 covering our content. 6853 05:02:29,040 --> 05:02:33,920 So let's scroll back to the top. 6854 05:02:32,080 --> 05:02:35,760 We're going to add padding to our body 6855 05:02:33,920 --> 05:02:37,680 so that these elements are not covered 6856 05:02:35,760 --> 05:02:39,760 by the sidebar. 6857 05:02:37,680 --> 05:02:42,480 So in this case, we want extra space on 6858 05:02:39,760 --> 05:02:47,280 the left side. So we're going to set 6859 05:02:42,480 --> 05:02:50,080 padding dash left and let's set it to 80 6860 05:02:47,280 --> 05:02:53,840 pixels, which is more than the sidebar's 6861 05:02:50,080 --> 05:02:55,840 width of 72 pixels. So now if we save 6862 05:02:53,840 --> 05:02:57,760 this, 6863 05:02:55,840 --> 05:03:00,080 we have 80 pixels of padding on the left 6864 05:02:57,760 --> 05:03:03,120 side of the page. And now the sidebar is 6865 05:03:00,080 --> 05:03:07,000 not covering our content. So that's how 6866 05:03:03,120 --> 05:03:07,000 we position a sidebar. 6867 05:03:07,680 --> 05:03:13,680 Now we're going to create the sidebar in 6868 05:03:10,638 --> 05:03:15,680 our project here. So let's go back into 6869 05:03:13,680 --> 05:03:17,760 YouTube.html. 6870 05:03:15,680 --> 05:03:20,240 Going to resize my page so that we can 6871 05:03:17,760 --> 05:03:23,360 see it better. and we're going to create 6872 05:03:20,240 --> 05:03:26,000 a sidebar on the left. So, let's go into 6873 05:03:23,360 --> 05:03:28,240 our code and we're going to put the 6874 05:03:26,000 --> 05:03:31,120 sidebar right below our header. So, 6875 05:03:28,240 --> 05:03:34,000 let's scroll down below our header here. 6876 05:03:31,120 --> 05:03:35,920 I'm going to create a div. This is going 6877 05:03:34,000 --> 05:03:40,958 to be our sidebar. 6878 05:03:35,920 --> 05:03:44,240 And I'm going to give a class of sidebar 6879 05:03:40,958 --> 05:03:46,080 so that we can target it in our CSS. 6880 05:03:44,240 --> 05:03:49,040 Now, for these styles, let's actually 6881 05:03:46,080 --> 05:03:51,360 put them in a separate CSS file. So, if 6882 05:03:49,040 --> 05:03:54,320 we scroll up to the top, we have CSS 6883 05:03:51,360 --> 05:03:56,080 files for our header, for our videos. 6884 05:03:54,320 --> 05:03:58,560 So, it makes sense to split up our 6885 05:03:56,080 --> 05:04:01,040 sidebar styles into their own file so 6886 05:03:58,560 --> 05:04:03,120 that we organize our code better. We're 6887 05:04:01,040 --> 05:04:05,680 going to go into our code editor and 6888 05:04:03,120 --> 05:04:07,760 then go into the styles folder here. 6889 05:04:05,680 --> 05:04:12,040 We're going to create a new file and 6890 05:04:07,760 --> 05:04:12,040 we're going to call it sidebar.css. 6891 05:04:13,600 --> 05:04:18,120 And I'm going to put it on the side like 6892 05:04:15,120 --> 05:04:18,120 this. 6893 05:04:18,400 --> 05:04:23,760 Next, we're going to load sidebar.css 6894 05:04:21,040 --> 05:04:25,840 into our HTML. So, we just have to do 6895 05:04:23,760 --> 05:04:28,878 one of these. Again, just going to copy 6896 05:04:25,840 --> 05:04:33,000 them. And then, instead of video.css, 6897 05:04:28,878 --> 05:04:33,000 we're going to load sidebar.css. 6898 05:04:33,440 --> 05:04:40,200 And now we're ready to style this 6899 05:04:36,160 --> 05:04:40,200 sidebar that we just created. 6900 05:04:40,400 --> 05:04:47,920 So, let's target the sidebar class. 6901 05:04:44,560 --> 05:04:50,080 and we're going to set position to fixed 6902 05:04:47,920 --> 05:04:52,240 to make it stick. 6903 05:04:50,080 --> 05:04:54,958 Now for the sidebar, we want it to be 0 6904 05:04:52,240 --> 05:04:58,400 pixels from the left of our browser. So 6905 05:04:54,958 --> 05:04:59,920 let's set left to zero. And we also want 6906 05:04:58,400 --> 05:05:04,240 it to stick to the bottom of our 6907 05:04:59,920 --> 05:05:06,000 browser. So bottom to zero. 6908 05:05:04,240 --> 05:05:07,600 And finally, we want it to stretch to 6909 05:05:06,000 --> 05:05:11,520 the top, but we don't want it to cover 6910 05:05:07,600 --> 05:05:13,760 our header. So let's set the top to 6911 05:05:11,520 --> 05:05:16,958 whatever the height of our header is. 6912 05:05:13,760 --> 05:05:19,200 So, if we go to header.css, 6913 05:05:16,958 --> 05:05:22,000 which is here, we can check the height 6914 05:05:19,200 --> 05:05:24,320 of our header is 55 pixels. So, we're 6915 05:05:22,000 --> 05:05:26,638 going to go into our sidebar here, and 6916 05:05:24,320 --> 05:05:29,840 we're going to get the sidebar to end 50 6917 05:05:26,638 --> 05:05:32,480 pixels or 55 pixels from the top. So, 6918 05:05:29,840 --> 05:05:34,638 let's set that to 55 pixels. 6919 05:05:32,480 --> 05:05:36,400 Save it. 6920 05:05:34,638 --> 05:05:38,080 So, remember with position fixed, the 6921 05:05:36,400 --> 05:05:39,680 element is no longer on the page 6922 05:05:38,080 --> 05:05:41,760 anymore, and it doesn't have a 6923 05:05:39,680 --> 05:05:45,120 background color. So, we just have to 6924 05:05:41,760 --> 05:05:48,080 set that again. background dash color. 6925 05:05:45,120 --> 05:05:50,958 We're going to set it to white. 6926 05:05:48,080 --> 05:05:52,718 Save it. And now we have our sidebar. 6927 05:05:50,958 --> 05:05:54,638 The final thing is to make our sidebar 6928 05:05:52,718 --> 05:05:57,120 as wide as our design, which is right 6929 05:05:54,638 --> 05:06:00,480 here. 6930 05:05:57,120 --> 05:06:02,080 So, we're going to set the width to 72 6931 05:06:00,480 --> 05:06:04,958 pixels. 6932 05:06:02,080 --> 05:06:07,840 Save it. And let's compare it to our 6933 05:06:04,958 --> 05:06:09,520 design. And I think it's hard to see 6934 05:06:07,840 --> 05:06:11,120 because it's white here and it's a 6935 05:06:09,520 --> 05:06:14,080 little bit gray here, but I think that's 6936 05:06:11,120 --> 05:06:14,080 close enough. 6937 05:06:15,120 --> 05:06:19,440 Now, the next problem we have is that 6938 05:06:16,878 --> 05:06:20,718 the sidebar is covering our content. So, 6939 05:06:19,440 --> 05:06:23,280 as we learned, we're going to add some 6940 05:06:20,718 --> 05:06:26,560 padding to the left to push our content 6941 05:06:23,280 --> 05:06:29,280 over. So, let's go into our general 6942 05:06:26,560 --> 05:06:32,480 styles. So, general.css 6943 05:06:29,280 --> 05:06:35,200 and we're going to style the body. 6944 05:06:32,480 --> 05:06:39,360 We're going to add padding to the left 6945 05:06:35,200 --> 05:06:41,920 of our body. And let's add padding of 80 6946 05:06:39,360 --> 05:06:43,760 pixels again. 6947 05:06:41,920 --> 05:06:45,680 And now our sidebar is no longer 6948 05:06:43,760 --> 05:06:47,440 covering our content because we added a 6949 05:06:45,680 --> 05:06:49,120 bunch of padding to the left of our 6950 05:06:47,440 --> 05:06:51,440 page. 6951 05:06:49,120 --> 05:06:53,360 So that's how we use position fixed to 6952 05:06:51,440 --> 05:06:55,680 create elements that stick to the page 6953 05:06:53,360 --> 05:06:58,680 while we scroll like our header and our 6954 05:06:55,680 --> 05:06:58,680 sidebar. 6955 05:06:59,200 --> 05:07:02,638 For now, here's some exercises that you 6956 05:07:00,798 --> 05:07:07,320 can do on your own to get a better 6957 05:07:02,638 --> 05:07:07,320 understanding of CSS position. 6958 05:07:17,600 --> 05:07:21,520 Now, we're going to learn another 6959 05:07:18,958 --> 05:07:24,240 position property that we can use. Let's 6960 05:07:21,520 --> 05:07:26,400 go into our position practice file and 6961 05:07:24,240 --> 05:07:29,120 the same in our code editor. We're going 6962 05:07:26,400 --> 05:07:31,920 to open up position.html 6963 05:07:29,120 --> 05:07:33,440 and then close all of these files. So, 6964 05:07:31,920 --> 05:07:36,840 I'm going to resize it so that we can 6965 05:07:33,440 --> 05:07:36,840 see it better. 6966 05:07:37,280 --> 05:07:41,840 So this time we're going to learn 6967 05:07:38,798 --> 05:07:44,160 position absolute. Let's do an example 6968 05:07:41,840 --> 05:07:46,240 to see how it works. So let's scroll 6969 05:07:44,160 --> 05:07:48,638 down and we're going to create a div 6970 05:07:46,240 --> 05:07:52,000 below our sidebar to practice position 6971 05:07:48,638 --> 05:07:55,280 absolute. Let's create a div. And then 6972 05:07:52,000 --> 05:07:56,718 let's call this absolute. 6973 05:07:55,280 --> 05:08:00,878 And now we're going to set some styles 6974 05:07:56,718 --> 05:08:03,520 on this div. So style equals. 6975 05:08:00,878 --> 05:08:08,480 And then inside here, we're going to set 6976 05:08:03,520 --> 05:08:10,000 position with a value of absolute. 6977 05:08:08,480 --> 05:08:12,560 And we're also going to set a background 6978 05:08:10,000 --> 05:08:15,440 color of red so that it's easier to see. 6979 05:08:12,560 --> 05:08:17,680 So background color of red. And then the 6980 05:08:15,440 --> 05:08:21,920 text color is going to be white. So 6981 05:08:17,680 --> 05:08:24,878 color of white. Save it. And now we have 6982 05:08:21,920 --> 05:08:26,798 our position absolute element. 6983 05:08:24,878 --> 05:08:29,120 So before we continue, make sure we 6984 05:08:26,798 --> 05:08:30,718 scroll all the way up to the top of our 6985 05:08:29,120 --> 05:08:33,120 page. 6986 05:08:30,718 --> 05:08:36,400 Now, position absolute also takes the 6987 05:08:33,120 --> 05:08:38,480 same values as position fixed. So, top, 6988 05:08:36,400 --> 05:08:40,560 left, bottom, and right, as well as 6989 05:08:38,480 --> 05:08:42,798 width and height, but they behave a 6990 05:08:40,560 --> 05:08:44,958 little bit differently. So, first we're 6991 05:08:42,798 --> 05:08:47,920 going to set left. So, let's set the 6992 05:08:44,958 --> 05:08:50,798 left property to zero. And let's save 6993 05:08:47,920 --> 05:08:53,120 it. And now the left side of our element 6994 05:08:50,798 --> 05:08:55,440 is 0 pixels from the left side of our 6995 05:08:53,120 --> 05:08:57,520 page. So, this works the same way as 6996 05:08:55,440 --> 05:09:01,520 position fixed. 6997 05:08:57,520 --> 05:09:03,600 If we set the left to 10 pixels, 6998 05:09:01,520 --> 05:09:07,200 now there will be 10 pixels between our 6999 05:09:03,600 --> 05:09:09,120 element and the left side of our page. 7000 05:09:07,200 --> 05:09:13,200 Now let's try setting top. So we're 7001 05:09:09,120 --> 05:09:15,280 going to set the top to 10 pixels. Save 7002 05:09:13,200 --> 05:09:17,520 it and make sure you scroll all the way 7003 05:09:15,280 --> 05:09:21,040 up. So you'll notice that our element is 7004 05:09:17,520 --> 05:09:23,120 now 10 pixels from the top of the page. 7005 05:09:21,040 --> 05:09:25,520 So mostly these properties work the same 7006 05:09:23,120 --> 05:09:27,040 as position fixed, but with one key 7007 05:09:25,520 --> 05:09:29,120 difference. 7008 05:09:27,040 --> 05:09:31,680 For position fixed, the elements are 7009 05:09:29,120 --> 05:09:33,760 placed in the browser window. While for 7010 05:09:31,680 --> 05:09:36,240 position absolute, the elements are 7011 05:09:33,760 --> 05:09:39,440 placed on the page. Now what I mean by 7012 05:09:36,240 --> 05:09:42,400 this is that when we scroll the browser 7013 05:09:39,440 --> 05:09:44,878 window or just this visible part is not 7014 05:09:42,400 --> 05:09:48,000 moving only the page is moving up and 7015 05:09:44,878 --> 05:09:49,680 down. So for position fixed, we're going 7016 05:09:48,000 --> 05:09:51,280 to put these elements on the browser 7017 05:09:49,680 --> 05:09:53,520 window which doesn't move when we 7018 05:09:51,280 --> 05:09:58,080 scroll. So if we scroll up to the 7019 05:09:53,520 --> 05:10:00,480 header, if I say top and 10 pixels, this 7020 05:09:58,080 --> 05:10:02,320 puts a header 10 pixels from the top of 7021 05:10:00,480 --> 05:10:04,000 the browser window, not from the top of 7022 05:10:02,320 --> 05:10:07,520 the page, which is constantly moving up 7023 05:10:04,000 --> 05:10:09,920 and down. But for position absolute, if 7024 05:10:07,520 --> 05:10:12,080 we scroll down to there, 7025 05:10:09,920 --> 05:10:14,400 we're putting it 10 pixels from the top 7026 05:10:12,080 --> 05:10:16,958 of the page, which scrolls up and down 7027 05:10:14,400 --> 05:10:18,480 when we move. 7028 05:10:16,958 --> 05:10:20,958 So that's a key difference between the 7029 05:10:18,480 --> 05:10:22,718 two. Position fixed positions the 7030 05:10:20,958 --> 05:10:24,798 element in the browser which doesn't 7031 05:10:22,718 --> 05:10:26,878 move when we scroll. And position 7032 05:10:24,798 --> 05:10:31,520 absolute positions the element on the 7033 05:10:26,878 --> 05:10:35,360 page which does move when we scroll. 7034 05:10:31,520 --> 05:10:37,440 So let's go back up and reset this to 7035 05:10:35,360 --> 05:10:39,440 zero so that we have our proper header 7036 05:10:37,440 --> 05:10:41,920 again and do some more practice with 7037 05:10:39,440 --> 05:10:43,920 position absolute. 7038 05:10:41,920 --> 05:10:46,878 So, for example, if I wanted to put this 7039 05:10:43,920 --> 05:10:49,200 absolute element in the top right corner 7040 05:10:46,878 --> 05:10:50,878 here on our page, we can do something 7041 05:10:49,200 --> 05:10:53,520 like 7042 05:10:50,878 --> 05:10:55,200 right and we'll put it 10 pixels from 7043 05:10:53,520 --> 05:10:57,600 the right. 7044 05:10:55,200 --> 05:11:00,080 And then top, 7045 05:10:57,600 --> 05:11:03,520 we can put it maybe 60 pixels from the 7046 05:11:00,080 --> 05:11:06,878 top. So, 60. 7047 05:11:03,520 --> 05:11:08,718 Save it. And we scroll all the way up. 7048 05:11:06,878 --> 05:11:13,120 And that's how we place an element on a 7049 05:11:08,718 --> 05:11:13,120 precise location on our page like this. 7050 05:11:13,200 --> 05:11:17,920 And because it's on our page, when we 7051 05:11:15,440 --> 05:11:19,920 scroll, the page will move up and this 7052 05:11:17,920 --> 05:11:22,240 absolute element will move up with the 7053 05:11:19,920 --> 05:11:24,400 page. Now, one thing that's weird is 7054 05:11:22,240 --> 05:11:27,760 that this element is appearing above our 7055 05:11:24,400 --> 05:11:30,080 header. And that's because this element 7056 05:11:27,760 --> 05:11:32,958 was written in our code below our 7057 05:11:30,080 --> 05:11:35,200 header. So, generally an element that is 7058 05:11:32,958 --> 05:11:36,958 written below is going to appear in 7059 05:11:35,200 --> 05:11:39,760 front of elements that are written above 7060 05:11:36,958 --> 05:11:42,878 it. Now we can actually override this if 7061 05:11:39,760 --> 05:11:46,600 we scroll up by adding another property 7062 05:11:42,878 --> 05:11:46,600 called z-index. 7063 05:11:47,200 --> 05:11:51,440 So z-index determines which elements 7064 05:11:49,440 --> 05:11:54,718 appear in front and which elements 7065 05:11:51,440 --> 05:11:57,120 appear behind. So the default zindex is 7066 05:11:54,718 --> 05:11:59,760 zero. This is the same thing as if you 7067 05:11:57,120 --> 05:12:02,560 didn't have this at all. But an element 7068 05:11:59,760 --> 05:12:05,920 with a higher z-index will appear in 7069 05:12:02,560 --> 05:12:08,638 front of elements with a lower z-index. 7070 05:12:05,920 --> 05:12:10,798 So, if we set the z-index of the header 7071 05:12:08,638 --> 05:12:13,520 to one, it's going to have a higher 7072 05:12:10,798 --> 05:12:16,320 z-index than the absolute element, which 7073 05:12:13,520 --> 05:12:19,040 has a default z-index of zero. If we 7074 05:12:16,320 --> 05:12:21,440 save it, now the header will appear in 7075 05:12:19,040 --> 05:12:24,080 front. 7076 05:12:21,440 --> 05:12:27,280 Just as an example, if we scroll down 7077 05:12:24,080 --> 05:12:29,360 and we set the z-index 7078 05:12:27,280 --> 05:12:32,000 of this absolute element and we set it 7079 05:12:29,360 --> 05:12:34,560 to two, now it's going to appear in 7080 05:12:32,000 --> 05:12:37,280 front again because our z-index here is 7081 05:12:34,560 --> 05:12:39,200 greater than our z-index here. So, 7082 05:12:37,280 --> 05:12:41,360 usually we set this to something like 7083 05:12:39,200 --> 05:12:43,520 100 so that we can have a lot of 7084 05:12:41,360 --> 05:12:46,000 elements in between if our page has a 7085 05:12:43,520 --> 05:12:47,520 lot of layers. 7086 05:12:46,000 --> 05:12:49,920 And usually if we don't care about the 7087 05:12:47,520 --> 05:12:53,798 Z-index, we can just remove it and have 7088 05:12:49,920 --> 05:12:53,798 a default of zero. 7089 05:12:54,000 --> 05:12:58,400 Now that we learned position absolute, 7090 05:12:56,080 --> 05:13:00,400 where do we use this? The truth is we 7091 05:12:58,400 --> 05:13:02,080 don't use it like this very much. This 7092 05:13:00,400 --> 05:13:04,878 is not a common situation that we run 7093 05:13:02,080 --> 05:13:06,958 into when we're creating websites. 7094 05:13:04,878 --> 05:13:08,798 However, position absolute has another 7095 05:13:06,958 --> 05:13:11,600 key feature that makes it really, really 7096 05:13:08,798 --> 05:13:13,520 useful. To demonstrate, we're going to 7097 05:13:11,600 --> 05:13:15,840 take this element and we're going to 7098 05:13:13,520 --> 05:13:18,958 make a copy of it and we're going to put 7099 05:13:15,840 --> 05:13:20,638 it inside the sidebar. So like right 7100 05:13:18,958 --> 05:13:22,160 here. 7101 05:13:20,638 --> 05:13:26,878 So we're going to put a position 7102 05:13:22,160 --> 05:13:29,520 absolute inside a position fixed. 7103 05:13:26,878 --> 05:13:31,840 So now when we save, you'll notice that 7104 05:13:29,520 --> 05:13:34,000 this element is not being placed on the 7105 05:13:31,840 --> 05:13:37,040 page anymore. What it's actually doing 7106 05:13:34,000 --> 05:13:39,920 is placing this element relative to this 7107 05:13:37,040 --> 05:13:42,718 position fixed element. So now right of 7108 05:13:39,920 --> 05:13:44,718 10 pixels is actually 10 pixels from the 7109 05:13:42,718 --> 05:13:48,480 right of the fixed element which is the 7110 05:13:44,718 --> 05:13:51,040 sidebar. Top of 60 pixels is 60 pixels 7111 05:13:48,480 --> 05:13:53,440 from the top of the sidebar not from the 7112 05:13:51,040 --> 05:13:56,560 top of the page. So whenever position 7113 05:13:53,440 --> 05:13:58,958 absolute is inside a position fixed 7114 05:13:56,560 --> 05:14:02,638 element it's going to be placed relative 7115 05:13:58,958 --> 05:14:04,798 to this position fixed element. 7116 05:14:02,638 --> 05:14:06,958 So this is the most important feature of 7117 05:14:04,798 --> 05:14:09,200 position absolute. So let me show you 7118 05:14:06,958 --> 05:14:11,280 why it's so useful. Let's say that we 7119 05:14:09,200 --> 05:14:13,280 wanted a close button on the top right 7120 05:14:11,280 --> 05:14:15,920 of our sidebar. We want to be able to 7121 05:14:13,280 --> 05:14:18,798 close our sidebar if we want to. I'm 7122 05:14:15,920 --> 05:14:21,120 going to change this to an X so that 7123 05:14:18,798 --> 05:14:22,958 it's kind of like a close button. And 7124 05:14:21,120 --> 05:14:26,080 then to put it in the top right of our 7125 05:14:22,958 --> 05:14:29,920 sidebar, we just have to set the top to 7126 05:14:26,080 --> 05:14:32,400 zero and the right to zero. So if I save 7127 05:14:29,920 --> 05:14:35,040 that, now this element is in the top 7128 05:14:32,400 --> 05:14:38,160 right. And that's because if position 7129 05:14:35,040 --> 05:14:40,798 absolute is inside position fixed, top 7130 05:14:38,160 --> 05:14:43,920 zero means 0 pixels from the top of the 7131 05:14:40,798 --> 05:14:46,480 position fixed element. Right zero means 7132 05:14:43,920 --> 05:14:49,440 0 pixels from the right of the position 7133 05:14:46,480 --> 05:14:52,080 fixed element. 7134 05:14:49,440 --> 05:14:55,120 So this is how we attach elements to the 7135 05:14:52,080 --> 05:14:57,200 corners or the sides of other elements. 7136 05:14:55,120 --> 05:14:59,920 If we look at our final project, we can 7137 05:14:57,200 --> 05:15:02,400 see that going on in our videos. Here we 7138 05:14:59,920 --> 05:15:05,200 have the video time in the corner of our 7139 05:15:02,400 --> 05:15:07,680 thumbnail. Here we have the notification 7140 05:15:05,200 --> 05:15:11,680 count in the top right corner of this 7141 05:15:07,680 --> 05:15:13,920 icon. And using position absolute, it 7142 05:15:11,680 --> 05:15:16,240 allows us to put elements in the corner 7143 05:15:13,920 --> 05:15:17,840 like this. 7144 05:15:16,240 --> 05:15:20,560 So there's one last thing we need to 7145 05:15:17,840 --> 05:15:22,798 learn here. We have a position absolute 7146 05:15:20,560 --> 05:15:24,638 inside a position fixed element. That's 7147 05:15:22,798 --> 05:15:26,320 why we can put it in the corner. But 7148 05:15:24,638 --> 05:15:28,958 notice that this is still a position 7149 05:15:26,320 --> 05:15:31,600 fixed element and it sticks to the page. 7150 05:15:28,958 --> 05:15:33,280 But in our final project, these videos 7151 05:15:31,600 --> 05:15:35,280 are not sticking to the page. They're 7152 05:15:33,280 --> 05:15:38,400 scrolling with the page, and we're still 7153 05:15:35,280 --> 05:15:41,360 able to put stuff in the corners. 7154 05:15:38,400 --> 05:15:42,878 So, how do we achieve this? 7155 05:15:41,360 --> 05:15:45,040 And to do this, we're going to learn 7156 05:15:42,878 --> 05:15:48,320 another value for the position property 7157 05:15:45,040 --> 05:15:50,240 called position relative. 7158 05:15:48,320 --> 05:15:52,480 We're going to scroll down to our two 7159 05:15:50,240 --> 05:15:54,240 divs at the bottom. 7160 05:15:52,480 --> 05:15:56,320 And for our second div, we're going to 7161 05:15:54,240 --> 05:15:59,040 set the position 7162 05:15:56,320 --> 05:16:01,680 to relative. 7163 05:15:59,040 --> 05:16:04,160 and save it. Now, if we go back to our 7164 05:16:01,680 --> 05:16:05,680 page, we'll notice that nothing actually 7165 05:16:04,160 --> 05:16:07,760 changed. 7166 05:16:05,680 --> 05:16:11,200 And that's how position relative works. 7167 05:16:07,760 --> 05:16:13,760 It still displays the element as normal, 7168 05:16:11,200 --> 05:16:16,400 except if we put position absolute in 7169 05:16:13,760 --> 05:16:18,400 here, it will position it relative to 7170 05:16:16,400 --> 05:16:20,400 this element instead of relative to the 7171 05:16:18,400 --> 05:16:23,360 page. So, let's go through an example to 7172 05:16:20,400 --> 05:16:25,840 see what I mean. If I scroll up here, 7173 05:16:23,360 --> 05:16:29,760 let's copy this absolute element. Let's 7174 05:16:25,840 --> 05:16:33,680 copy it and then paste it inside this 7175 05:16:29,760 --> 05:16:36,400 position relative element. 7176 05:16:33,680 --> 05:16:39,680 Save it and then reformat it a bit. 7177 05:16:36,400 --> 05:16:42,000 Press tab. And if we save this, you'll 7178 05:16:39,680 --> 05:16:44,080 notice that we get the same effect as 7179 05:16:42,000 --> 05:16:46,560 when we put position absolute in 7180 05:16:44,080 --> 05:16:49,520 position fixed. 7181 05:16:46,560 --> 05:16:51,680 Right of 10 pixels now means 10 pixels 7182 05:16:49,520 --> 05:16:54,000 from the right of the position relative 7183 05:16:51,680 --> 05:16:57,600 element, not 10 pixels from the right of 7184 05:16:54,000 --> 05:16:59,920 the page. Top of 60 pixels means 60 7185 05:16:57,600 --> 05:17:02,718 pixels from the top of the position 7186 05:16:59,920 --> 05:17:05,920 relative element, not 60 pixels from the 7187 05:17:02,718 --> 05:17:08,000 top of the page. 7188 05:17:05,920 --> 05:17:10,480 So two things are happening here. When 7189 05:17:08,000 --> 05:17:13,680 position absolute is inside position 7190 05:17:10,480 --> 05:17:16,000 relative, this will be positioned on the 7191 05:17:13,680 --> 05:17:18,080 element, not on the page. So that's what 7192 05:17:16,000 --> 05:17:19,600 we just talked about. The second thing 7193 05:17:18,080 --> 05:17:22,320 that happens here is that position 7194 05:17:19,600 --> 05:17:24,560 relative causes this whole element to 7195 05:17:22,320 --> 05:17:27,520 display normally. So that's what we get 7196 05:17:24,560 --> 05:17:29,360 in our final project. Notice that these 7197 05:17:27,520 --> 05:17:31,360 videos are displayed normally. They 7198 05:17:29,360 --> 05:17:34,000 scroll with the page, but we have 7199 05:17:31,360 --> 05:17:36,560 something in the bottom right corner. So 7200 05:17:34,000 --> 05:17:38,080 these are all position relative. And 7201 05:17:36,560 --> 05:17:39,840 then to put something in the bottom 7202 05:17:38,080 --> 05:17:43,440 right corner, we're going to put a 7203 05:17:39,840 --> 05:17:45,120 position absolute inside. 7204 05:17:43,440 --> 05:17:47,840 So let's actually go through an example 7205 05:17:45,120 --> 05:17:49,760 here. So we have our position relative 7206 05:17:47,840 --> 05:17:51,920 element. We have position absolute 7207 05:17:49,760 --> 05:17:53,680 inside. I'm going to put this in the 7208 05:17:51,920 --> 05:17:57,840 bottom right corner just like our 7209 05:17:53,680 --> 05:18:00,000 design. So, let's change this to 7210 05:17:57,840 --> 05:18:01,520 five minutes. 7211 05:18:00,000 --> 05:18:03,520 And pretend this is like our final 7212 05:18:01,520 --> 05:18:07,440 project. Let's change the background 7213 05:18:03,520 --> 05:18:09,120 color to black. 7214 05:18:07,440 --> 05:18:11,520 And now we're going to put this on the 7215 05:18:09,120 --> 05:18:14,798 bottom right corner. So, let's get rid 7216 05:18:11,520 --> 05:18:17,040 of this first. 7217 05:18:14,798 --> 05:18:20,240 And we're going to put this 10 pixels 7218 05:18:17,040 --> 05:18:22,480 from the bottom of the position relative 7219 05:18:20,240 --> 05:18:24,480 element. So we're going to say bottom 10 7220 05:18:22,480 --> 05:18:26,160 pixels. 7221 05:18:24,480 --> 05:18:28,400 And we're also going to put it 10 pixels 7222 05:18:26,160 --> 05:18:33,200 from the right of this position relative 7223 05:18:28,400 --> 05:18:35,040 element. So right of 10 pixels. 7224 05:18:33,200 --> 05:18:37,840 And that's how we position this in the 7225 05:18:35,040 --> 05:18:40,480 corner. And because this is position 7226 05:18:37,840 --> 05:18:43,760 relative, if we scroll the page, it acts 7227 05:18:40,480 --> 05:18:45,440 like normal content. 7228 05:18:43,760 --> 05:18:47,680 So now that we learned the technique of 7229 05:18:45,440 --> 05:18:49,600 position absolute inside position 7230 05:18:47,680 --> 05:18:53,200 relative, we're going to apply that to 7231 05:18:49,600 --> 05:18:56,240 our project and create the video time as 7232 05:18:53,200 --> 05:18:59,120 well as the notification number here. 7233 05:18:56,240 --> 05:19:00,958 So let's go back to our project 7234 05:18:59,120 --> 05:19:05,120 and we're going to add video times 7235 05:19:00,958 --> 05:19:07,600 first. So let's go to YouTube.html 7236 05:19:05,120 --> 05:19:10,560 and we're also going to open the 7237 05:19:07,600 --> 05:19:13,120 video.css file. I'm going to put it down 7238 05:19:10,560 --> 05:19:15,440 here because we're working with styles 7239 05:19:13,120 --> 05:19:16,718 for the videos. 7240 05:19:15,440 --> 05:19:19,360 So, first we're going to find our 7241 05:19:16,718 --> 05:19:21,760 thumbnail which is right here. And now 7242 05:19:19,360 --> 05:19:24,560 remember to put something in the corner, 7243 05:19:21,760 --> 05:19:27,600 we're going to need position absolute 7244 05:19:24,560 --> 05:19:30,080 inside a position relative element. So, 7245 05:19:27,600 --> 05:19:32,560 if we look at our code, what could be 7246 05:19:30,080 --> 05:19:34,400 our position relative element? Well, it 7247 05:19:32,560 --> 05:19:36,080 can't really be the image element 7248 05:19:34,400 --> 05:19:37,600 because image elements aren't really 7249 05:19:36,080 --> 05:19:40,798 containers. We can't put something 7250 05:19:37,600 --> 05:19:43,440 inside it. So what we could use is this 7251 05:19:40,798 --> 05:19:45,840 thumbnail row element. This could be our 7252 05:19:43,440 --> 05:19:48,320 relative element and then the video time 7253 05:19:45,840 --> 05:19:50,480 will be the absolute element inside of 7254 05:19:48,320 --> 05:19:52,798 here. 7255 05:19:50,480 --> 05:19:56,000 So first let's create our video time. 7256 05:19:52,798 --> 05:20:00,878 We're going to create a div 7257 05:19:56,000 --> 05:20:02,958 and let's give it a class of video-time. 7258 05:20:00,878 --> 05:20:04,638 And then inside we're going to put a 7259 05:20:02,958 --> 05:20:06,718 video time. So let's go to our final 7260 05:20:04,638 --> 05:20:09,120 project and we're going to copy one of 7261 05:20:06,718 --> 05:20:13,600 these. So 1420. 7262 05:20:09,120 --> 05:20:16,480 Then inside I'm going to put 14 col 20. 7263 05:20:13,600 --> 05:20:19,120 Let's save it and go back. 7264 05:20:16,480 --> 05:20:21,360 So right now it's just a normal div. 7265 05:20:19,120 --> 05:20:23,920 Let's go to our CSS file and we're going 7266 05:20:21,360 --> 05:20:26,000 to style this. Let's scroll all the way 7267 05:20:23,920 --> 05:20:29,120 down 7268 05:20:26,000 --> 05:20:31,360 and we're going to target video-time 7269 05:20:29,120 --> 05:20:34,080 class 7270 05:20:31,360 --> 05:20:38,638 and let's set the background dash color 7271 05:20:34,080 --> 05:20:41,280 to black and the text color to white. So 7272 05:20:38,638 --> 05:20:43,040 just like our final project. 7273 05:20:41,280 --> 05:20:45,120 So now we're ready to position it 7274 05:20:43,040 --> 05:20:48,400 properly. We're going to need position 7275 05:20:45,120 --> 05:20:50,320 absolute inside position relative. So 7276 05:20:48,400 --> 05:20:53,280 first let's set the position relative on 7277 05:20:50,320 --> 05:20:56,400 here. We're going to scroll up to 7278 05:20:53,280 --> 05:20:58,718 thumbnail row, which is right here. 7279 05:20:56,400 --> 05:21:01,718 We're going to set position 7280 05:20:58,718 --> 05:21:01,718 relative. 7281 05:21:02,718 --> 05:21:05,920 And remember, position relative doesn't 7282 05:21:04,480 --> 05:21:08,000 really change anything. Everything 7283 05:21:05,920 --> 05:21:12,638 appears normal. That's one of the 7284 05:21:08,000 --> 05:21:16,080 benefits of it. And if we scroll down, 7285 05:21:12,638 --> 05:21:18,560 we're going to change this to position 7286 05:21:16,080 --> 05:21:21,200 absolute. 7287 05:21:18,560 --> 05:21:23,520 And now top, bottom, left and right will 7288 05:21:21,200 --> 05:21:26,878 be placed inside our position relative 7289 05:21:23,520 --> 05:21:28,400 element. So if we save it and now if we 7290 05:21:26,878 --> 05:21:32,480 want to put it in the bottom right 7291 05:21:28,400 --> 05:21:35,760 corner, we just have to say bottom 0 7292 05:21:32,480 --> 05:21:38,958 pixels from the bottom and also 0 pixels 7293 05:21:35,760 --> 05:21:40,560 from the right. 7294 05:21:38,958 --> 05:21:44,320 So let's set the position from the 7295 05:21:40,560 --> 05:21:46,480 bottom to maybe 10 pixels. Save it. 7296 05:21:44,320 --> 05:21:49,840 Okay. And let's set the position from 7297 05:21:46,480 --> 05:21:52,240 the right side to maybe 5 pixels. Save 7298 05:21:49,840 --> 05:21:53,760 it. Okay. Let's change this to maybe 8 7299 05:21:52,240 --> 05:21:55,040 pixels. 7300 05:21:53,760 --> 05:21:57,040 Okay. So, I think that looks pretty 7301 05:21:55,040 --> 05:21:58,798 good. 7302 05:21:57,040 --> 05:22:01,680 And if we compare it to our final 7303 05:21:58,798 --> 05:22:03,520 design, it's in the right position. So, 7304 05:22:01,680 --> 05:22:05,840 that's how we put an element in the 7305 05:22:03,520 --> 05:22:08,560 corner of another element. We need a 7306 05:22:05,840 --> 05:22:10,560 position absolute inside a position 7307 05:22:08,560 --> 05:22:12,878 relative. 7308 05:22:10,560 --> 05:22:15,520 So finally, let's style this one by one 7309 05:22:12,878 --> 05:22:17,120 until it matches our design. I'm 7310 05:22:15,520 --> 05:22:18,718 actually going to move this to the 7311 05:22:17,120 --> 05:22:21,718 bottom here so that it's easier to 7312 05:22:18,718 --> 05:22:21,718 compare. 7313 05:22:23,200 --> 05:22:27,200 The first thing we're going to do is to 7314 05:22:24,718 --> 05:22:32,400 change the font. So we're going to set 7315 05:22:27,200 --> 05:22:38,200 font dash family to Roboto, 7316 05:22:32,400 --> 05:22:38,200 Ariel, like the rest of our fonts. 7317 05:22:38,480 --> 05:22:44,480 And next, let's change the font size. 7318 05:22:41,440 --> 05:22:47,440 Let's change it to font dash size of 7319 05:22:44,480 --> 05:22:49,520 maybe 12 pixels. 7320 05:22:47,440 --> 05:22:52,160 Okay, that looks pretty good. Let's make 7321 05:22:49,520 --> 05:22:56,638 it a little bit bolder. Let's change the 7322 05:22:52,160 --> 05:22:58,958 font dash weight to 500. 7323 05:22:56,638 --> 05:23:02,718 And remember, a font weight of 400 is 7324 05:22:58,958 --> 05:23:06,160 normal, 700 is bold, and 500 is 7325 05:23:02,718 --> 05:23:08,480 semibold. Let's save that. That looks 7326 05:23:06,160 --> 05:23:10,638 pretty good. And next, we need spacing 7327 05:23:08,480 --> 05:23:12,320 on the inside of this element. So that's 7328 05:23:10,638 --> 05:23:15,280 padding. 7329 05:23:12,320 --> 05:23:19,280 So let's add some padding 7330 05:23:15,280 --> 05:23:21,760 on the left of maybe two pixels. 7331 05:23:19,280 --> 05:23:25,520 And same for padding on the right two 7332 05:23:21,760 --> 05:23:28,000 pixels. And then padding on the top of 7333 05:23:25,520 --> 05:23:32,638 four pixels. And then padding on the 7334 05:23:28,000 --> 05:23:34,638 bottom of four pixels. Save that. That 7335 05:23:32,638 --> 05:23:36,638 looks pretty good. Uh, let's add some 7336 05:23:34,638 --> 05:23:40,480 more padding on the left and right. 7337 05:23:36,638 --> 05:23:42,638 Change this to 4 pixels and four pixels. 7338 05:23:40,480 --> 05:23:44,240 Okay, so I'm pretty happy with that. 7339 05:23:42,638 --> 05:23:47,120 Next, we're going to make our corner 7340 05:23:44,240 --> 05:23:48,718 rounded. Kind of like this. 7341 05:23:47,120 --> 05:23:50,798 So, to do that, we're going to use 7342 05:23:48,718 --> 05:23:54,400 border radius. 7343 05:23:50,798 --> 05:23:58,080 Change the border dash radius to 2 7344 05:23:54,400 --> 05:23:59,680 pixels. Save it. 7345 05:23:58,080 --> 05:24:02,400 And I think that looks pretty close to 7346 05:23:59,680 --> 05:24:04,160 our design. 7347 05:24:02,400 --> 05:24:06,160 And there we go. We created the video 7348 05:24:04,160 --> 05:24:07,920 time in the bottom right corner of the 7349 05:24:06,160 --> 05:24:09,200 thumbnail. 7350 05:24:07,920 --> 05:24:11,040 Now, to give you guys a bit more 7351 05:24:09,200 --> 05:24:13,040 practice, I'm going to get you to add 7352 05:24:11,040 --> 05:24:16,000 the video time to all of our other 7353 05:24:13,040 --> 05:24:18,798 videos. So, inside our HTML, you're 7354 05:24:16,000 --> 05:24:21,280 going to add this video time to the next 7355 05:24:18,798 --> 05:24:23,440 video here and all the videos in the 7356 05:24:21,280 --> 05:24:25,200 HTML. 7357 05:24:23,440 --> 05:24:29,160 So, take some time to complete that and 7358 05:24:25,200 --> 05:24:29,160 then we'll continue the lesson. 7359 05:24:30,798 --> 05:24:34,480 So, now that we have the video time for 7360 05:24:32,798 --> 05:24:36,718 all of our videos, we're going to run 7361 05:24:34,480 --> 05:24:38,798 into another problem. If we start 7362 05:24:36,718 --> 05:24:40,798 scrolling up on this page, you'll notice 7363 05:24:38,798 --> 05:24:43,360 that the thumbnails appear above our 7364 05:24:40,798 --> 05:24:45,200 header. But another thing is that the 7365 05:24:43,360 --> 05:24:47,360 other content like this text and the 7366 05:24:45,200 --> 05:24:50,240 channel image will appear below our 7367 05:24:47,360 --> 05:24:52,080 header. So, what exactly is going on? 7368 05:24:50,240 --> 05:24:55,040 So, we mentioned this briefly in the 7369 05:24:52,080 --> 05:24:58,000 practice file. If an element like this 7370 05:24:55,040 --> 05:25:01,440 video preview is written below another 7371 05:24:58,000 --> 05:25:03,280 element like the header up here, the 7372 05:25:01,440 --> 05:25:05,680 element that is written below will 7373 05:25:03,280 --> 05:25:07,680 appear in front. 7374 05:25:05,680 --> 05:25:10,080 That's what's happening here. We have a 7375 05:25:07,680 --> 05:25:11,760 header and then below that we have the 7376 05:25:10,080 --> 05:25:13,920 thumbnail which is going to appear on 7377 05:25:11,760 --> 05:25:15,600 top of the header. 7378 05:25:13,920 --> 05:25:18,000 However, what I didn't mention is that 7379 05:25:15,600 --> 05:25:20,080 this rule doesn't apply to position 7380 05:25:18,000 --> 05:25:22,638 static or these elements with the 7381 05:25:20,080 --> 05:25:25,120 default position. position static will 7382 05:25:22,638 --> 05:25:26,798 always appear at the back. So that's why 7383 05:25:25,120 --> 05:25:28,958 you see that these always appear at the 7384 05:25:26,798 --> 05:25:30,638 back. As soon as we set it to something 7385 05:25:28,958 --> 05:25:33,280 that's not position static, like 7386 05:25:30,638 --> 05:25:35,200 position relative, the rules of which 7387 05:25:33,280 --> 05:25:38,480 element was written first start to 7388 05:25:35,200 --> 05:25:41,040 apply. So in this case, because if we 7389 05:25:38,480 --> 05:25:43,520 scroll up, the thumbnail row is 7390 05:25:41,040 --> 05:25:45,520 positioned relative and it's written 7391 05:25:43,520 --> 05:25:48,000 below the header in the code. It's going 7392 05:25:45,520 --> 05:25:50,798 to appear on top of the header, which is 7393 05:25:48,000 --> 05:25:53,840 what we see. And remember to fix this, 7394 05:25:50,798 --> 05:25:56,798 we need to set a property of Zindex. 7395 05:25:53,840 --> 05:26:00,000 Let's go into our header CSS file. Going 7396 05:25:56,798 --> 05:26:01,760 to open this file here. 7397 05:26:00,000 --> 05:26:05,360 And then inside the header, we need to 7398 05:26:01,760 --> 05:26:07,600 set a Z-index 7399 05:26:05,360 --> 05:26:10,878 to make the header appear above the 7400 05:26:07,600 --> 05:26:13,200 thumbnails. So let's set a Z-index of 7401 05:26:10,878 --> 05:26:16,240 100 so that we have room if we want to 7402 05:26:13,200 --> 05:26:19,040 put stuff between these two. 7403 05:26:16,240 --> 05:26:22,240 Now if I save it, the header has a 7404 05:26:19,040 --> 05:26:25,520 z-index of 100. The thumbnail row has a 7405 05:26:22,240 --> 05:26:28,480 default z-index of zero. 100 is greater 7406 05:26:25,520 --> 05:26:30,878 than zero. That means the header will 7407 05:26:28,480 --> 05:26:32,958 appear on top of all the thumbnails. So 7408 05:26:30,878 --> 05:26:37,360 if we go back and we start scrolling, 7409 05:26:32,958 --> 05:26:38,878 you'll notice that we're now all good. 7410 05:26:37,360 --> 05:26:40,958 The last thing we'll learn is how to 7411 05:26:38,878 --> 05:26:43,760 create this notification count in the 7412 05:26:40,958 --> 05:26:47,280 top right corner of this icon. So, let's 7413 05:26:43,760 --> 05:26:49,360 go into our HTML. So, YouTube.html 7414 05:26:47,280 --> 05:26:51,440 and find where the code for this 7415 05:26:49,360 --> 05:26:53,520 notification is. So, if we scroll down 7416 05:26:51,440 --> 05:26:56,878 to the header and then scroll down to 7417 05:26:53,520 --> 05:26:59,280 the right side, that's this code here, 7418 05:26:56,878 --> 05:27:00,958 notification icons. So, I'm going to 7419 05:26:59,280 --> 05:27:03,760 resize my windows so we can see it 7420 05:27:00,958 --> 05:27:05,440 properly here. 7421 05:27:03,760 --> 05:27:07,600 And now we want to put a notification 7422 05:27:05,440 --> 05:27:09,200 number in the top right corner. So 7423 05:27:07,600 --> 05:27:12,080 remember like we've been doing, we need 7424 05:27:09,200 --> 05:27:15,080 a position absolute inside a position 7425 05:27:12,080 --> 05:27:15,080 relative. 7426 05:27:15,280 --> 05:27:20,638 So if we look at our HTML, what could we 7427 05:27:17,920 --> 05:27:22,718 use as our position relative element? So 7428 05:27:20,638 --> 05:27:25,440 it can't really be this image because we 7429 05:27:22,718 --> 05:27:29,280 can't put stuff inside an image element. 7430 05:27:25,440 --> 05:27:32,558 So one option is this div up here. But a 7431 05:27:29,280 --> 05:27:35,360 better option is actually to wrap this 7432 05:27:32,558 --> 05:27:37,920 image element inside a div. So, we're 7433 05:27:35,360 --> 05:27:42,718 going to create a div here, and we're 7434 05:27:37,920 --> 05:27:45,040 going to put this image inside this div. 7435 05:27:42,718 --> 05:27:47,840 So, remember that the div just creates a 7436 05:27:45,040 --> 05:27:49,520 box around whatever is inside. So, it's 7437 05:27:47,840 --> 05:27:52,320 not going to change the appearance of 7438 05:27:49,520 --> 05:27:54,718 this image. However, by creating this 7439 05:27:52,320 --> 05:27:57,280 div, we can now make this position 7440 05:27:54,718 --> 05:28:01,280 relative, and that's going to help us 7441 05:27:57,280 --> 05:28:03,440 add stuff to the top right corner. 7442 05:28:01,280 --> 05:28:05,920 So let's give this div a class so that 7443 05:28:03,440 --> 05:28:07,760 we can style it later. Let's call it 7444 05:28:05,920 --> 05:28:11,480 notifications 7445 05:28:07,760 --> 05:28:11,480 dash icon-container. 7446 05:28:12,558 --> 05:28:16,718 And inside we're going to have our 7447 05:28:13,840 --> 05:28:19,200 notification count. Let's create a div 7448 05:28:16,718 --> 05:28:21,920 for our notification count. Let's give 7449 05:28:19,200 --> 05:28:25,120 it a count of three. 7450 05:28:21,920 --> 05:28:30,400 And let's set this class equals 7451 05:28:25,120 --> 05:28:32,240 notifications with an s dash count. 7452 05:28:30,400 --> 05:28:34,718 And now we're ready to style this and 7453 05:28:32,240 --> 05:28:37,520 put it in the corner. So let's go into 7454 05:28:34,718 --> 05:28:41,798 header.css. I'm going to put it on the 7455 05:28:37,520 --> 05:28:41,798 side so we can see it more clearly. 7456 05:28:42,080 --> 05:28:47,440 And now to start off, let's scroll down 7457 05:28:44,638 --> 05:28:50,080 to where we have our notification code. 7458 05:28:47,440 --> 05:28:53,040 So we'll scroll all the way down 7459 05:28:50,080 --> 05:28:54,798 and we'll find it right here. 7460 05:28:53,040 --> 05:28:57,120 And now remember we're going to have 7461 05:28:54,798 --> 05:28:59,920 position relative and then inside we're 7462 05:28:57,120 --> 05:29:04,840 going to have position absolute. So 7463 05:28:59,920 --> 05:29:04,840 let's style the notifications 7464 05:29:04,878 --> 05:29:08,360 dash icon-container 7465 05:29:08,718 --> 05:29:13,280 and set this to position 7466 05:29:11,280 --> 05:29:17,638 relative 7467 05:29:13,280 --> 05:29:17,638 and then the notifications count 7468 05:29:18,558 --> 05:29:24,840 and we'll set this to position 7469 05:29:21,840 --> 05:29:24,840 absolute. 7470 05:29:27,280 --> 05:29:32,718 So, we want to put this in the top right 7471 05:29:29,200 --> 05:29:37,120 corner. So, let's set the top 7472 05:29:32,718 --> 05:29:38,718 to 0 pixels and the right to 0 pixels. 7473 05:29:37,120 --> 05:29:41,120 And to see it better, let's set a 7474 05:29:38,718 --> 05:29:48,520 background color. So, background dash 7475 05:29:41,120 --> 05:29:48,520 color of red and a text color of white. 7476 05:29:48,798 --> 05:29:52,798 And now, if we save that, it's sort of 7477 05:29:51,120 --> 05:29:54,638 in the top right corner, but it's a 7478 05:29:52,798 --> 05:29:58,240 little bit too big. So, we're going to 7479 05:29:54,638 --> 05:30:00,240 style it just like our design here. So, 7480 05:29:58,240 --> 05:30:04,840 I'm going to move this up here actually 7481 05:30:00,240 --> 05:30:04,840 so that we have a better reference. 7482 05:30:06,320 --> 05:30:11,760 And now we're going to style it by first 7483 05:30:08,240 --> 05:30:16,878 changing the font. So, let's change the 7484 05:30:11,760 --> 05:30:20,160 font dash family to Roboto, 7485 05:30:16,878 --> 05:30:22,320 Ariel, like before. 7486 05:30:20,160 --> 05:30:24,000 Next, we'll change the font size. So, 7487 05:30:22,320 --> 05:30:28,878 this is pretty small. Let's change the 7488 05:30:24,000 --> 05:30:30,400 font dash size to maybe 10 pixels. 7489 05:30:28,878 --> 05:30:32,638 Okay, should be a little bit bigger. 7490 05:30:30,400 --> 05:30:35,040 Let's set it to 12 pixels. Okay, that 7491 05:30:32,638 --> 05:30:37,440 looks pretty good. And let's add some 7492 05:30:35,040 --> 05:30:41,440 spacing on the inside of the element. 7493 05:30:37,440 --> 05:30:44,878 Let's add some padding left of maybe 7494 05:30:41,440 --> 05:30:49,360 four pixels, padding right of four 7495 05:30:44,878 --> 05:30:54,440 pixels, padding top of two, and 7496 05:30:49,360 --> 05:30:54,440 padding-ash bottom of 2 pixels. 7497 05:30:54,638 --> 05:30:58,718 And remember to make this a circle, 7498 05:30:56,558 --> 05:31:02,558 we're going to give it round corners. So 7499 05:30:58,718 --> 05:31:05,558 let's set the border dash radius to 10 7500 05:31:02,558 --> 05:31:05,558 pixels. 7501 05:31:05,920 --> 05:31:09,360 So, it looks like we're a little bit too 7502 05:31:07,840 --> 05:31:11,520 tall here. We're going to stretch out 7503 05:31:09,360 --> 05:31:14,480 the sides by adding more padding to the 7504 05:31:11,520 --> 05:31:19,040 sides. Let's change this to maybe 5 7505 05:31:14,480 --> 05:31:21,760 pixels left and right. Save it. 7506 05:31:19,040 --> 05:31:23,920 Okay, maybe 6 pixels left and right. 7507 05:31:21,760 --> 05:31:26,080 Save it. Okay, so that looks like a 7508 05:31:23,920 --> 05:31:27,680 pretty good circle. Next, we'll change 7509 05:31:26,080 --> 05:31:30,160 the background color to something that 7510 05:31:27,680 --> 05:31:33,600 looks like that. So, I'm just going to 7511 05:31:30,160 --> 05:31:36,798 pick something like this, maybe. 7512 05:31:33,600 --> 05:31:38,958 Save. Perfect. 7513 05:31:36,798 --> 05:31:40,878 And I'm going to change the font size 7514 05:31:38,958 --> 05:31:43,200 down just a little bit more because this 7515 05:31:40,878 --> 05:31:44,718 is pretty small. Let's change this to 7516 05:31:43,200 --> 05:31:48,718 11. 7517 05:31:44,718 --> 05:31:51,600 Save that. And let's change the padding 7518 05:31:48,718 --> 05:31:55,040 left and the right because it's a little 7519 05:31:51,600 --> 05:31:57,680 bit long on the horizontal side. 7520 05:31:55,040 --> 05:31:59,600 And now we have a circle again. So 7521 05:31:57,680 --> 05:32:01,360 notice that we put this element in the 7522 05:31:59,600 --> 05:32:03,600 top right corner using these two 7523 05:32:01,360 --> 05:32:06,400 properties. But it's not enough. We 7524 05:32:03,600 --> 05:32:08,958 actually want it out even more. So we're 7525 05:32:06,400 --> 05:32:11,520 already at the top edge of our position 7526 05:32:08,958 --> 05:32:14,320 relative container. How can we go even 7527 05:32:11,520 --> 05:32:16,958 higher? So the trick here is to use 7528 05:32:14,320 --> 05:32:19,120 negative numbers. 7529 05:32:16,958 --> 05:32:21,440 So now this will be positioned beyond 7530 05:32:19,120 --> 05:32:24,798 the top edge of our container. So if I 7531 05:32:21,440 --> 05:32:27,280 save it here, this is now 5 pixels 7532 05:32:24,798 --> 05:32:29,760 beyond the top edge of our relative 7533 05:32:27,280 --> 05:32:32,878 container. Same thing with right. If we 7534 05:32:29,760 --> 05:32:35,520 set it to 5 pixels here, it's now 5 7535 05:32:32,878 --> 05:32:37,360 pixels beyond the right edge. So, I'm 7536 05:32:35,520 --> 05:32:40,160 just going to adjust the values here so 7537 05:32:37,360 --> 05:32:42,320 that it matches our design. 7538 05:32:40,160 --> 05:32:44,480 So, let's set the top to something like 7539 05:32:42,320 --> 05:32:46,000 -2. 7540 05:32:44,480 --> 05:32:47,760 Okay. So, I think that looks pretty 7541 05:32:46,000 --> 05:32:50,160 close to our design and I'm pretty happy 7542 05:32:47,760 --> 05:32:52,638 with it. So, in this lesson, we learned 7543 05:32:50,160 --> 05:32:55,040 CSS position, which is one of the most 7544 05:32:52,638 --> 05:32:56,718 important skills in CSS. 7545 05:32:55,040 --> 05:32:59,120 It allows us to create elements like 7546 05:32:56,718 --> 05:33:01,440 this header and sidebar that stick to 7547 05:32:59,120 --> 05:33:03,360 the page while we scroll. And it allows 7548 05:33:01,440 --> 05:33:05,760 us to add elements on top of other 7549 05:33:03,360 --> 05:33:07,360 elements. For example, the video time on 7550 05:33:05,760 --> 05:33:09,040 top of the thumbnail and the 7551 05:33:07,360 --> 05:33:12,000 notification count on top of the 7552 05:33:09,040 --> 05:33:13,760 notification icon. 7553 05:33:12,000 --> 05:33:17,120 So with that, we learned all the major 7554 05:33:13,760 --> 05:33:19,600 skills that we need in HTML and CSS to 7555 05:33:17,120 --> 05:33:21,440 complete our project. In the last 7556 05:33:19,600 --> 05:33:23,360 lesson, we're going to create all the 7557 05:33:21,440 --> 05:33:26,160 other features that we're missing, 7558 05:33:23,360 --> 05:33:28,958 including the sidebar, the tool tips, 7559 05:33:26,160 --> 05:33:33,400 and making our current project look like 7560 05:33:28,958 --> 05:33:33,400 the final design here. 7561 05:33:52,320 --> 05:33:55,760 In this lesson, we're going to finish 7562 05:33:53,760 --> 05:33:58,160 our final project. We're going to create 7563 05:33:55,760 --> 05:34:00,558 the sidebar. We'll resize our video so 7564 05:33:58,160 --> 05:34:02,160 that it looks like our design here. And 7565 05:34:00,558 --> 05:34:05,120 lastly, we're going to create the tool 7566 05:34:02,160 --> 05:34:07,440 tips when we hover over these icons. 7567 05:34:05,120 --> 05:34:09,200 We'll start off with the sidebar. So, 7568 05:34:07,440 --> 05:34:11,440 I'm going to rearrange my windows here 7569 05:34:09,200 --> 05:34:14,320 so that it's a little easier to copy. 7570 05:34:11,440 --> 05:34:16,400 So, I put the design on the left. I'm 7571 05:34:14,320 --> 05:34:19,040 going to put our current sidebar on the 7572 05:34:16,400 --> 05:34:21,920 right here. And I'll resize my windows 7573 05:34:19,040 --> 05:34:24,480 so we can see it better. 7574 05:34:21,920 --> 05:34:27,120 And now we're ready to begin. So, let's 7575 05:34:24,480 --> 05:34:29,840 open our code editor and we're going to 7576 05:34:27,120 --> 05:34:31,600 open YouTube.html. 7577 05:34:29,840 --> 05:34:36,160 And then we're going to scroll down to 7578 05:34:31,600 --> 05:34:38,718 the sidebar code, which is right here. 7579 05:34:36,160 --> 05:34:42,160 So, let's take a look at the design of 7580 05:34:38,718 --> 05:34:44,320 this sidebar, our reference design. If I 7581 05:34:42,160 --> 05:34:46,718 hover over it, you can see that it's 7582 05:34:44,320 --> 05:34:49,920 just a bunch of boxes. And inside each 7583 05:34:46,718 --> 05:34:51,920 box, we have an icon, some text, and 7584 05:34:49,920 --> 05:34:53,760 they're centered horizontally and 7585 05:34:51,920 --> 05:34:55,280 vertically. So, we're going to start 7586 05:34:53,760 --> 05:34:58,760 step by step. We're first going to 7587 05:34:55,280 --> 05:34:58,760 create the box. 7588 05:34:58,798 --> 05:35:04,240 Let's go into our code and instead of 7589 05:35:01,920 --> 05:35:05,760 this text, we're going to create six 7590 05:35:04,240 --> 05:35:08,558 boxes. 7591 05:35:05,760 --> 05:35:12,718 We're going to use a div to create each 7592 05:35:08,558 --> 05:35:14,558 box. Let's give this div a class of 7593 05:35:12,718 --> 05:35:17,120 sidebar 7594 05:35:14,558 --> 05:35:19,600 dashlink. 7595 05:35:17,120 --> 05:35:21,520 And I'm going to copy and paste this six 7596 05:35:19,600 --> 05:35:24,798 times. 7597 05:35:21,520 --> 05:35:26,878 Four. Five. Six. Next, we're going to 7598 05:35:24,798 --> 05:35:29,520 style these so that they have the same 7599 05:35:26,878 --> 05:35:33,520 size as these boxes. 7600 05:35:29,520 --> 05:35:37,280 We're going to go into our CSS. 7601 05:35:33,520 --> 05:35:39,360 So, let's go into sidebar.css. 7602 05:35:37,280 --> 05:35:41,840 I'm going to put this on the right side 7603 05:35:39,360 --> 05:35:44,638 here so we can see it better. And now 7604 05:35:41,840 --> 05:35:49,600 we're ready to style these. 7605 05:35:44,638 --> 05:35:51,440 Let's target the class sidebar link. 7606 05:35:49,600 --> 05:35:54,160 And for each of these, let's give it a 7607 05:35:51,440 --> 05:35:59,440 background color so that we can see 7608 05:35:54,160 --> 05:36:01,280 them. And let's set it to light gray. 7609 05:35:59,440 --> 05:36:03,600 And we'll also give them a height 7610 05:36:01,280 --> 05:36:06,400 because without any content in the divs, 7611 05:36:03,600 --> 05:36:08,080 they have a height of zero. So let's set 7612 05:36:06,400 --> 05:36:10,480 a height 7613 05:36:08,080 --> 05:36:13,280 of 50 pixels. 7614 05:36:10,480 --> 05:36:15,680 And let's save it. And let's see how 7615 05:36:13,280 --> 05:36:18,160 that looks. Okay. So it's hard to tell 7616 05:36:15,680 --> 05:36:20,160 the difference between them. So let's 7617 05:36:18,160 --> 05:36:22,558 add some spacing at the bottom of each 7618 05:36:20,160 --> 05:36:25,200 div so that we can differentiate them. 7619 05:36:22,558 --> 05:36:26,958 We're going to add margin 7620 05:36:25,200 --> 05:36:31,440 dashbottom 7621 05:36:26,958 --> 05:36:34,160 of one pixel. Save it. Okay. So from 7622 05:36:31,440 --> 05:36:35,920 this it looks like our boxes are a 7623 05:36:34,160 --> 05:36:39,280 little bit too short. So we're going to 7624 05:36:35,920 --> 05:36:42,320 make them taller. Let's try a height of 7625 05:36:39,280 --> 05:36:45,040 maybe 75. 7626 05:36:42,320 --> 05:36:47,600 Okay. So I think that's pretty close. We 7627 05:36:45,040 --> 05:36:50,878 can get rid of this margin at the bottom 7628 05:36:47,600 --> 05:36:52,798 and actually increase this to 76 so that 7629 05:36:50,878 --> 05:36:55,680 we compensate for the margin that we 7630 05:36:52,798 --> 05:36:58,240 removed. And next, when we look at the 7631 05:36:55,680 --> 05:37:00,000 design, these boxes are usually white, 7632 05:36:58,240 --> 05:37:04,000 but when we hover over them, they turn 7633 05:37:00,000 --> 05:37:06,878 gray. So instead of having this 7634 05:37:04,000 --> 05:37:09,120 background color gray here, we're just 7635 05:37:06,878 --> 05:37:11,440 going to set the background color when 7636 05:37:09,120 --> 05:37:16,360 we hover over this. So, let's set a 7637 05:37:11,440 --> 05:37:16,360 hover style dot sidebar-link 7638 05:37:16,798 --> 05:37:21,520 colon hover. 7639 05:37:19,760 --> 05:37:24,240 And when we hover, we're going to set 7640 05:37:21,520 --> 05:37:28,638 the background color 7641 05:37:24,240 --> 05:37:31,200 to light gray. 7642 05:37:28,638 --> 05:37:33,520 Let's save it. And now, when we hover, 7643 05:37:31,200 --> 05:37:35,840 it's light gray, but our design is 7644 05:37:33,520 --> 05:37:38,000 actually a lot lighter than that. So, 7645 05:37:35,840 --> 05:37:39,920 I'm going to change the color here. 7646 05:37:38,000 --> 05:37:44,080 Gonna pick something a little lighter 7647 05:37:39,920 --> 05:37:48,320 than this. Maybe something here. 7648 05:37:44,080 --> 05:37:50,798 Let's save that and check it out. And 7649 05:37:48,320 --> 05:37:52,798 yep, I think that looks pretty close. 7650 05:37:50,798 --> 05:37:55,360 Next, we're going to add the content in 7651 05:37:52,798 --> 05:37:57,200 each of these boxes. So, first we 7652 05:37:55,360 --> 05:37:59,360 actually need to download all of these 7653 05:37:57,200 --> 05:38:01,600 icons. So, we did it before for these 7654 05:37:59,360 --> 05:38:05,920 icons. And just a reminder to do that, 7655 05:38:01,600 --> 05:38:07,760 we're going to rightclick and inspect. 7656 05:38:05,920 --> 05:38:10,000 So you'll see that this actually covers 7657 05:38:07,760 --> 05:38:12,638 up the sidebar. What we can do is click 7658 05:38:10,000 --> 05:38:14,958 these three dots in the top right. And 7659 05:38:12,638 --> 05:38:16,878 then we can move the dev tools to 7660 05:38:14,958 --> 05:38:19,680 another side of the web page. So I'm 7661 05:38:16,878 --> 05:38:22,480 going to move it to the right side here. 7662 05:38:19,680 --> 05:38:24,080 And now we can see the full sidebar. 7663 05:38:22,480 --> 05:38:27,600 Then we're going to click this in the 7664 05:38:24,080 --> 05:38:29,360 top left. Click one of these icons and 7665 05:38:27,600 --> 05:38:32,718 you'll get the URL to download them 7666 05:38:29,360 --> 05:38:34,878 here. So hover over this URL and then 7667 05:38:32,718 --> 05:38:38,240 click this. 7668 05:38:34,878 --> 05:38:41,600 And now we can control S. And I'll save 7669 05:38:38,240 --> 05:38:44,798 it in the folder that contains my code 7670 05:38:41,600 --> 05:38:46,958 in the icons folder. So make sure you do 7671 05:38:44,798 --> 05:38:51,240 this for all six of these icons. And 7672 05:38:46,958 --> 05:38:51,240 I'll see you back after you're done. 7673 05:38:51,760 --> 05:38:56,080 All right. So once we've downloaded all 7674 05:38:53,680 --> 05:38:59,120 of the icons from the sidebar here, 7675 05:38:56,080 --> 05:39:01,120 we're going to add them to our HTML. So, 7676 05:38:59,120 --> 05:39:03,200 let's go into each of these and add our 7677 05:39:01,120 --> 05:39:05,120 icons. 7678 05:39:03,200 --> 05:39:07,520 Inside this first div, we're going to 7679 05:39:05,120 --> 05:39:10,240 add an image element. And we're going to 7680 05:39:07,520 --> 05:39:13,280 set a source attribute. 7681 05:39:10,240 --> 05:39:16,280 And we're going to load the icon 7682 05:39:13,280 --> 05:39:16,280 icons/home.svg 7683 05:39:16,798 --> 05:39:22,400 because this is the home icon. 7684 05:39:19,920 --> 05:39:24,080 And let's save it. And now we have our 7685 05:39:22,400 --> 05:39:26,480 icon. It's a little bit too big, but 7686 05:39:24,080 --> 05:39:30,558 we're going to resize it after. For now, 7687 05:39:26,480 --> 05:39:33,120 let's copy this and add the icons for 7688 05:39:30,558 --> 05:39:35,040 all of these other boxes. So, we're 7689 05:39:33,120 --> 05:39:36,878 going to add for this one, we're going 7690 05:39:35,040 --> 05:39:39,878 to add the explore icon. So, 7691 05:39:36,878 --> 05:39:39,878 explore.svg. 7692 05:39:40,240 --> 05:39:48,600 And for this one is the subscriptions. 7693 05:39:44,000 --> 05:39:48,600 Then for this one, it's originals. 7694 05:39:48,958 --> 05:39:53,600 And then for this one, it's 7695 05:39:50,878 --> 05:39:56,558 YouTube-music. 7696 05:39:53,600 --> 05:39:58,638 And the last one is library. 7697 05:39:56,558 --> 05:40:01,600 So we're going to go down here, change 7698 05:39:58,638 --> 05:40:03,360 this to library. 7699 05:40:01,600 --> 05:40:05,520 Perfect. 7700 05:40:03,360 --> 05:40:09,440 Next, we're going to make these icons 7701 05:40:05,520 --> 05:40:12,160 smaller. So, usually we would set a 7702 05:40:09,440 --> 05:40:14,638 class on these images so that we can 7703 05:40:12,160 --> 05:40:16,080 style them with CSS, but for this 7704 05:40:14,638 --> 05:40:18,878 lesson, I'm going to show you another 7705 05:40:16,080 --> 05:40:20,958 way that we can target these images. So, 7706 05:40:18,878 --> 05:40:22,558 let's go into our sidebar styles and 7707 05:40:20,958 --> 05:40:24,080 we're going to learn a new CSS 7708 05:40:22,558 --> 05:40:26,320 technique. 7709 05:40:24,080 --> 05:40:28,718 So, we already learned that this text 7710 05:40:26,320 --> 05:40:31,200 before the brackets here, this tells a 7711 05:40:28,718 --> 05:40:32,878 computer which elements we're styling. 7712 05:40:31,200 --> 05:40:35,440 In this case, the dot means we're 7713 05:40:32,878 --> 05:40:37,360 targeting a class and we're styling all 7714 05:40:35,440 --> 05:40:40,718 elements that have the class sidebar 7715 05:40:37,360 --> 05:40:43,360 link, which are these elements. 7716 05:40:40,718 --> 05:40:45,600 So, this bit of text is called a CSS 7717 05:40:43,360 --> 05:40:47,440 selector. And there's actually a lot of 7718 05:40:45,600 --> 05:40:49,760 different selectors that we can use in 7719 05:40:47,440 --> 05:40:51,520 CSS. 7720 05:40:49,760 --> 05:40:53,280 So, we already learned the class name 7721 05:40:51,520 --> 05:40:55,680 selector, which looks like this and 7722 05:40:53,280 --> 05:40:57,760 starts with a dot. And we learned the 7723 05:40:55,680 --> 05:41:00,558 element name selector, which just starts 7724 05:40:57,760 --> 05:41:02,558 with the elements name. 7725 05:41:00,558 --> 05:41:05,280 Another thing we can do with CSS is to 7726 05:41:02,558 --> 05:41:09,840 combine selectors together. For example, 7727 05:41:05,280 --> 05:41:12,878 if we said dot sidebar-link 7728 05:41:09,840 --> 05:41:15,360 and then wrote a comma down here, we can 7729 05:41:12,878 --> 05:41:17,680 add another selector. 7730 05:41:15,360 --> 05:41:19,440 So let's say we also want to target 7731 05:41:17,680 --> 05:41:21,360 header. 7732 05:41:19,440 --> 05:41:23,680 So now all of the styles inside the 7733 05:41:21,360 --> 05:41:26,638 brackets will target all elements with 7734 05:41:23,680 --> 05:41:29,520 the sidebar link class and all elements 7735 05:41:26,638 --> 05:41:31,600 with the header class. 7736 05:41:29,520 --> 05:41:35,280 This is an example of a more advanced 7737 05:41:31,600 --> 05:41:40,160 selector. Another selector we can use is 7738 05:41:35,280 --> 05:41:42,878 instead of a comma we can use a space 7739 05:41:40,160 --> 05:41:44,558 and then type another selector like 7740 05:41:42,878 --> 05:41:46,480 image. 7741 05:41:44,558 --> 05:41:49,040 So when we have a space between these 7742 05:41:46,480 --> 05:41:52,798 two this means that we're targeting all 7743 05:41:49,040 --> 05:41:54,558 images inside all sidebar links. So 7744 05:41:52,798 --> 05:41:56,958 we're going to target these images 7745 05:41:54,558 --> 05:42:00,718 inside sidebar links only. We're not 7746 05:41:56,958 --> 05:42:02,958 going to target all images on the page. 7747 05:42:00,718 --> 05:42:05,120 So, let's style these images and make 7748 05:42:02,958 --> 05:42:07,440 them smaller. We're going to set a 7749 05:42:05,120 --> 05:42:10,320 height 7750 05:42:07,440 --> 05:42:12,080 and let's try 24 pixels. Let's see how 7751 05:42:10,320 --> 05:42:14,080 that looks. 7752 05:42:12,080 --> 05:42:16,718 Okay, so I think that looks pretty close 7753 05:42:14,080 --> 05:42:18,798 to what we have in the design. Next, 7754 05:42:16,718 --> 05:42:20,958 we're going to center these horizontally 7755 05:42:18,798 --> 05:42:22,718 and vertically. And finally add the 7756 05:42:20,958 --> 05:42:24,480 text. 7757 05:42:22,718 --> 05:42:26,958 So, to center something vertically is 7758 05:42:24,480 --> 05:42:30,160 actually challenging in CSS. The best 7759 05:42:26,958 --> 05:42:32,240 way to do it is to use a flexbox. If we 7760 05:42:30,160 --> 05:42:35,520 look into our code editor and open our 7761 05:42:32,240 --> 05:42:38,160 flexbox example, so flexbox.html 7762 05:42:35,520 --> 05:42:41,120 and then we rightclick and open with 7763 05:42:38,160 --> 05:42:43,920 live server, we have a bunch of examples 7764 05:42:41,120 --> 05:42:47,040 of using flexbox. In the last example 7765 05:42:43,920 --> 05:42:50,320 here, we're doing vertical alignment. If 7766 05:42:47,040 --> 05:42:52,480 we scroll down to our example 7767 05:42:50,320 --> 05:42:55,440 in our HTML, 7768 05:42:52,480 --> 05:42:57,120 we have this property called align items 7769 05:42:55,440 --> 05:43:00,240 center. 7770 05:42:57,120 --> 05:43:02,480 So this vertically centers our content. 7771 05:43:00,240 --> 05:43:05,920 Here we also have an example of 7772 05:43:02,480 --> 05:43:08,480 horizontal centering. If we scroll up to 7773 05:43:05,920 --> 05:43:12,400 that example which is this one, we have 7774 05:43:08,480 --> 05:43:14,400 the property justify content center. 7775 05:43:12,400 --> 05:43:16,878 So using justify content center and 7776 05:43:14,400 --> 05:43:19,520 align item center, we can put it both 7777 05:43:16,878 --> 05:43:21,520 horizontally and vertically centered. So 7778 05:43:19,520 --> 05:43:24,558 let's go back into our project and use a 7779 05:43:21,520 --> 05:43:28,558 flexbox to center these. We're going to 7780 05:43:24,558 --> 05:43:30,480 go back to our CSS and we're going to 7781 05:43:28,558 --> 05:43:32,000 make each of these sidebar links a 7782 05:43:30,480 --> 05:43:35,360 flexbox. 7783 05:43:32,000 --> 05:43:37,440 So let's set the display property 7784 05:43:35,360 --> 05:43:41,120 to flex 7785 05:43:37,440 --> 05:43:43,120 and we're going to set justify 7786 05:43:41,120 --> 05:43:45,280 dashc content 7787 05:43:43,120 --> 05:43:47,760 to center. So this will center 7788 05:43:45,280 --> 05:43:50,080 horizontally. Let's save it. And now 7789 05:43:47,760 --> 05:43:52,958 they're horizontally centered. and then 7790 05:43:50,080 --> 05:43:57,200 align dash items 7791 05:43:52,958 --> 05:43:59,920 center for vertical centering. 7792 05:43:57,200 --> 05:44:02,798 So this is coming along great. Next, 7793 05:43:59,920 --> 05:44:05,680 we're going to add the text. So 7794 05:44:02,798 --> 05:44:09,840 underneath each of these, let's add a 7795 05:44:05,680 --> 05:44:12,400 div. So div. So for this first one, it's 7796 05:44:09,840 --> 05:44:14,958 going to be called home. And I'm just 7797 05:44:12,400 --> 05:44:17,120 going to copy these 7798 05:44:14,958 --> 05:44:19,600 and replace it with each of these text. 7799 05:44:17,120 --> 05:44:24,200 So explore 7800 05:44:19,600 --> 05:44:24,200 This one is subscriptions, 7801 05:44:26,638 --> 05:44:29,638 originals, 7802 05:44:30,878 --> 05:44:34,718 YouTube 7803 05:44:32,878 --> 05:44:36,400 music, 7804 05:44:34,718 --> 05:44:39,400 and 7805 05:44:36,400 --> 05:44:39,400 library. 7806 05:44:39,840 --> 05:44:43,680 Now, let's start styling this text a 7807 05:44:41,680 --> 05:44:46,638 little bit. I'm going to use this 7808 05:44:43,680 --> 05:44:50,000 advanced CSS selector again. We're going 7809 05:44:46,638 --> 05:44:51,680 to go into the sidebar link class and 7810 05:44:50,000 --> 05:44:54,160 then we're going to target all the divs 7811 05:44:51,680 --> 05:44:56,240 inside sidebar link. So we're going to 7812 05:44:54,160 --> 05:44:58,558 target divs. So this is not going to 7813 05:44:56,240 --> 05:45:02,240 target all divs on the page, only the 7814 05:44:58,558 --> 05:45:04,320 divs inside sidebar link. 7815 05:45:02,240 --> 05:45:07,440 Let's change the font here first. So 7816 05:45:04,320 --> 05:45:10,718 we'll set the font dash family 7817 05:45:07,440 --> 05:45:14,320 to rooto, 7818 05:45:10,718 --> 05:45:16,240 arial like before. And let's make the 7819 05:45:14,320 --> 05:45:22,080 text smaller. Next, we're going to set 7820 05:45:16,240 --> 05:45:24,480 the font dash size to maybe 12 pixels. 7821 05:45:22,080 --> 05:45:26,958 Okay, maybe 10 pixels. 7822 05:45:24,480 --> 05:45:29,280 Save it. And now the next problem we 7823 05:45:26,958 --> 05:45:32,080 have is that our elements are appearing 7824 05:45:29,280 --> 05:45:34,958 beside each other, not on top of each 7825 05:45:32,080 --> 05:45:36,718 other. So why is this happening? So 7826 05:45:34,958 --> 05:45:43,440 remember that we can set a property 7827 05:45:36,718 --> 05:45:46,240 called flex dash direction colon row. 7828 05:45:43,440 --> 05:45:48,160 If we go into our flexbox example, 7829 05:45:46,240 --> 05:45:50,958 flexbox.html, 7830 05:45:48,160 --> 05:45:52,240 and we scroll all the way to the top, 7831 05:45:50,958 --> 05:45:55,120 this was the first thing that we 7832 05:45:52,240 --> 05:45:59,440 learned, display flex and flex direction 7833 05:45:55,120 --> 05:46:02,718 row. So, if we open this in our browser 7834 05:45:59,440 --> 05:46:04,878 and we scroll to the first example, 7835 05:46:02,718 --> 05:46:07,520 flex direction row causes our elements 7836 05:46:04,878 --> 05:46:09,440 to be displayed horizontally. So, notice 7837 05:46:07,520 --> 05:46:11,520 that these two are divs, but they're 7838 05:46:09,440 --> 05:46:14,480 displayed next to each other, not on top 7839 05:46:11,520 --> 05:46:16,958 of each other. Now to change this, we're 7840 05:46:14,480 --> 05:46:19,440 actually going to go back 7841 05:46:16,958 --> 05:46:21,360 and we're going to use flex direction 7842 05:46:19,440 --> 05:46:23,600 column. 7843 05:46:21,360 --> 05:46:26,160 So where flex direction row displays 7844 05:46:23,600 --> 05:46:28,958 them horizontally, flex direction column 7845 05:46:26,160 --> 05:46:31,200 displays our elements vertically. So if 7846 05:46:28,958 --> 05:46:33,200 we save it, 7847 05:46:31,200 --> 05:46:35,600 now it's displaying our elements one on 7848 05:46:33,200 --> 05:46:37,680 top of each other. 7849 05:46:35,600 --> 05:46:40,878 So this is another direction that we can 7850 05:46:37,680 --> 05:46:43,120 use for our flex boxes. By default, flex 7851 05:46:40,878 --> 05:46:45,760 boxes are flex direction row. So they 7852 05:46:43,120 --> 05:46:47,920 will appear horizontally. But we can set 7853 05:46:45,760 --> 05:46:49,680 flex direction column when we don't want 7854 05:46:47,920 --> 05:46:52,160 that behavior. 7855 05:46:49,680 --> 05:46:54,240 So for flex direction column, these two 7856 05:46:52,160 --> 05:46:56,878 properties are actually switched. So if 7857 05:46:54,240 --> 05:47:01,400 I remove both of them first 7858 05:46:56,878 --> 05:47:01,400 and I first use justify-content 7859 05:47:01,440 --> 05:47:08,240 colon center. 7860 05:47:04,638 --> 05:47:10,400 Save it. Justify content now affects the 7861 05:47:08,240 --> 05:47:12,878 vertical direction instead of the 7862 05:47:10,400 --> 05:47:18,480 horizontal direction with flex direction 7863 05:47:12,878 --> 05:47:20,958 row. And if I use align- items center 7864 05:47:18,480 --> 05:47:23,920 align items now affects the horizontal 7865 05:47:20,958 --> 05:47:26,000 direction. So for flex direction column, 7866 05:47:23,920 --> 05:47:27,520 these two are reversed. It's a little 7867 05:47:26,000 --> 05:47:30,878 bit confusing, but the more that you use 7868 05:47:27,520 --> 05:47:32,400 flexbox, the more you'll get used to it. 7869 05:47:30,878 --> 05:47:34,000 All right, so we're almost done. We're 7870 05:47:32,400 --> 05:47:35,440 just going to add some space between 7871 05:47:34,000 --> 05:47:37,360 these two. 7872 05:47:35,440 --> 05:47:41,840 To add some space, let's add some margin 7873 05:47:37,360 --> 05:47:43,600 bottom to the image. So margin 7874 05:47:41,840 --> 05:47:46,480 dashbottom, 7875 05:47:43,600 --> 05:47:48,798 maybe four pixels. 7876 05:47:46,480 --> 05:47:51,440 Save it. 7877 05:47:48,798 --> 05:47:54,958 Okay, I think that looks pretty close to 7878 05:47:51,440 --> 05:47:57,840 me. And it looks like our elements are a 7879 05:47:54,958 --> 05:47:59,760 little bit too tall. 7880 05:47:57,840 --> 05:48:03,840 So I'm actually going to scroll up and 7881 05:47:59,760 --> 05:48:06,878 adjust the height here to maybe 74. 7882 05:48:03,840 --> 05:48:08,878 Save it. And okay, that looks pretty 7883 05:48:06,878 --> 05:48:10,798 good. 7884 05:48:08,878 --> 05:48:13,280 So, one last thing with the sidebar is 7885 05:48:10,798 --> 05:48:16,080 that I notice in our design it kind of 7886 05:48:13,280 --> 05:48:17,920 covers the header while ours does not. 7887 05:48:16,080 --> 05:48:22,160 So, to change that, remember we can 7888 05:48:17,920 --> 05:48:24,798 change the Z dash index to be higher 7889 05:48:22,160 --> 05:48:28,160 than whatever the header is. So, if we 7890 05:48:24,798 --> 05:48:31,200 go into our header styles, header.css, 7891 05:48:28,160 --> 05:48:33,200 notice that the Z-index is 100. So, 7892 05:48:31,200 --> 05:48:37,200 we're going to change our Z-index to 7893 05:48:33,200 --> 05:48:40,558 bigger than that. So, 200. Save it. And 7894 05:48:37,200 --> 05:48:42,878 now our sidebar is covering our header. 7895 05:48:40,558 --> 05:48:45,040 Next, I want to move all of these icons 7896 05:48:42,878 --> 05:48:47,520 down a little bit more so that it's 7897 05:48:45,040 --> 05:48:49,840 aligned. So, to do that, I'm going to 7898 05:48:47,520 --> 05:48:52,080 add some padding or spacing to the top 7899 05:48:49,840 --> 05:48:55,600 of this. 7900 05:48:52,080 --> 05:48:57,520 So, we're going to add some padding 7901 05:48:55,600 --> 05:48:59,440 dashtop 7902 05:48:57,520 --> 05:49:00,638 of maybe five pixels. Let's see how that 7903 05:48:59,440 --> 05:49:03,600 looks. 7904 05:49:00,638 --> 05:49:05,840 Okay, so that looks perfect. And 7905 05:49:03,600 --> 05:49:07,840 actually, one last thing is I'm going to 7906 05:49:05,840 --> 05:49:10,718 make the cursor a pointer when we hover 7907 05:49:07,840 --> 05:49:14,718 over it. So, let's go into our sidebar 7908 05:49:10,718 --> 05:49:16,958 link and we'll set the cursor 7909 05:49:14,718 --> 05:49:22,840 to a pointer. 7910 05:49:16,958 --> 05:49:22,840 Save it. And now, this looks good to go. 7911 05:49:22,878 --> 05:49:27,920 Next, we're going to resize these videos 7912 05:49:25,120 --> 05:49:32,240 to match the design. So, I'm going to 7913 05:49:27,920 --> 05:49:33,920 move this back into one window. 7914 05:49:32,240 --> 05:49:36,798 And I'm going to resize this so that we 7915 05:49:33,920 --> 05:49:38,878 have three videos in each row. And now 7916 05:49:36,798 --> 05:49:41,360 we can properly switch back and forth to 7917 05:49:38,878 --> 05:49:43,200 compare. So, as I switch back and forth 7918 05:49:41,360 --> 05:49:45,280 between these, you can see that there's 7919 05:49:43,200 --> 05:49:48,080 a size difference between the videos. 7920 05:49:45,280 --> 05:49:50,240 So, we're going to fix that. 7921 05:49:48,080 --> 05:49:53,040 So, for our website, I notice that the 7922 05:49:50,240 --> 05:49:55,360 left edge here can be moved to the right 7923 05:49:53,040 --> 05:49:58,638 a little more. So if we look at our 7924 05:49:55,360 --> 05:50:01,600 design, it's more to the right. Go back 7925 05:49:58,638 --> 05:50:04,878 to our current project design more to 7926 05:50:01,600 --> 05:50:07,120 the right. So to move this to the right, 7927 05:50:04,878 --> 05:50:09,520 we're actually using padding. So we have 7928 05:50:07,120 --> 05:50:12,798 to increase our padding on the left side 7929 05:50:09,520 --> 05:50:14,878 of the page. Let's go back into our code 7930 05:50:12,798 --> 05:50:17,360 and we're going to find the padding 7931 05:50:14,878 --> 05:50:19,360 which is in general.css. 7932 05:50:17,360 --> 05:50:22,000 So remember we added padding to the left 7933 05:50:19,360 --> 05:50:25,360 side of the body. That's what's pushing 7934 05:50:22,000 --> 05:50:30,958 these elements over here. So, let's 7935 05:50:25,360 --> 05:50:35,280 increase the padding to maybe 96. Save 7936 05:50:30,958 --> 05:50:36,400 it. And let's compare it to the design. 7937 05:50:35,280 --> 05:50:38,080 All right. So, I think that looks 7938 05:50:36,400 --> 05:50:40,638 perfect. 7939 05:50:38,080 --> 05:50:43,280 And we also have padding on the right 7940 05:50:40,638 --> 05:50:48,638 while our website does not. So, let's 7941 05:50:43,280 --> 05:50:51,280 actually also add padding dash 7942 05:50:48,638 --> 05:50:53,760 of 24 pixels. 7943 05:50:51,280 --> 05:50:56,160 So, if we save that there and compare it 7944 05:50:53,760 --> 05:50:58,638 to our design, our videos are now 7945 05:50:56,160 --> 05:51:01,200 exactly the right size. So, that looks 7946 05:50:58,638 --> 05:51:02,798 great to me. 7947 05:51:01,200 --> 05:51:05,120 The next thing we're going to tweak is 7948 05:51:02,798 --> 05:51:07,680 if we look at our design, the background 7949 05:51:05,120 --> 05:51:09,920 color here is a light gray, while our 7950 05:51:07,680 --> 05:51:11,600 background color is white. So, we're 7951 05:51:09,920 --> 05:51:14,320 going to make the background color of 7952 05:51:11,600 --> 05:51:18,160 our entire page a shade of gray like 7953 05:51:14,320 --> 05:51:21,760 this. So, let's go into our CSS 7954 05:51:18,160 --> 05:51:26,000 and in our body styles in general CSS, 7955 05:51:21,760 --> 05:51:28,798 let's set the background dash color 7956 05:51:26,000 --> 05:51:31,200 to light gray. 7957 05:51:28,798 --> 05:51:36,400 And I'm going to hover over this and 7958 05:51:31,200 --> 05:51:39,680 select a lighter color. Maybe 248. 7959 05:51:36,400 --> 05:51:41,920 Save it. And let's compare it to our 7960 05:51:39,680 --> 05:51:44,718 design. So this is our website and this 7961 05:51:41,920 --> 05:51:47,360 is the design. I think that looks pretty 7962 05:51:44,718 --> 05:51:48,878 close. 7963 05:51:47,360 --> 05:51:52,160 And the last few details I want to 7964 05:51:48,878 --> 05:51:55,280 adjust is this part. So if I look at my 7965 05:51:52,160 --> 05:51:57,040 design and I compare to my website, it 7966 05:51:55,280 --> 05:51:59,040 looks like our channel pictures are a 7967 05:51:57,040 --> 05:52:01,200 little bit too big. So if I look at the 7968 05:51:59,040 --> 05:52:04,000 design here, so we could make them a 7969 05:52:01,200 --> 05:52:07,200 little smaller. So, let's go into our 7970 05:52:04,000 --> 05:52:12,600 code and we're going to go into the 7971 05:52:07,200 --> 05:52:12,600 video styles. Let's open video.css. 7972 05:52:12,958 --> 05:52:19,760 We're going to find the profile picture. 7973 05:52:15,680 --> 05:52:21,680 So, if I scroll down, so this image here 7974 05:52:19,760 --> 05:52:23,760 is the channel picture. It has a class 7975 05:52:21,680 --> 05:52:27,840 of profile picture. We're going to 7976 05:52:23,760 --> 05:52:31,520 decrease the width to maybe 36. 7977 05:52:27,840 --> 05:52:33,600 Save it. Compare it to our design. Okay. 7978 05:52:31,520 --> 05:52:35,440 So, I think that's the right size. Next, 7979 05:52:33,600 --> 05:52:39,280 I'm going to adjust some of the spacing 7980 05:52:35,440 --> 05:52:40,878 here. So, if I compare to the design, 7981 05:52:39,280 --> 05:52:44,080 there's actually a little bit less 7982 05:52:40,878 --> 05:52:46,558 spacing here than our website. So, I'm 7983 05:52:44,080 --> 05:52:48,878 going to decrease that. So, for our 7984 05:52:46,558 --> 05:52:52,080 website, we're adding 7985 05:52:48,878 --> 05:52:54,958 some margin bottom to the thumbnail, the 7986 05:52:52,080 --> 05:52:57,680 thumbnail row. 7987 05:52:54,958 --> 05:53:00,480 I'm going to decrease this to maybe 8 7988 05:52:57,680 --> 05:53:02,958 pixels. Let's see how that looks. and 7989 05:53:00,480 --> 05:53:05,360 then compare it to our design. Okay, so 7990 05:53:02,958 --> 05:53:07,680 I'm pretty happy with that. And finally, 7991 05:53:05,360 --> 05:53:10,718 I'm going to adjust the spacing between 7992 05:53:07,680 --> 05:53:14,280 these two. So for our video title, if we 7993 05:53:10,718 --> 05:53:14,280 go into our code 7994 05:53:14,320 --> 05:53:19,520 and scroll up here, it has a margin 7995 05:53:16,958 --> 05:53:22,240 bottom of 12. I'm going to decrease it a 7996 05:53:19,520 --> 05:53:26,400 little bit to 10. 7997 05:53:22,240 --> 05:53:28,400 Save it and compare it. 7998 05:53:26,400 --> 05:53:29,760 Okay, so I think that's good enough. It 7999 05:53:28,400 --> 05:53:32,000 doesn't have to be perfect. It's a 8000 05:53:29,760 --> 05:53:34,400 little bit off, but I think that our 8001 05:53:32,000 --> 05:53:37,200 current website here looks really good 8002 05:53:34,400 --> 05:53:38,320 to me. Anyways, 8003 05:53:37,200 --> 05:53:40,320 the final thing we're going to do in 8004 05:53:38,320 --> 05:53:42,718 this lesson is we're going to create 8005 05:53:40,320 --> 05:53:45,760 these tool tips when we hover over these 8006 05:53:42,718 --> 05:53:48,000 icons. So, before we learn how to make 8007 05:53:45,760 --> 05:53:49,920 these appear when we hover over, let's 8008 05:53:48,000 --> 05:53:52,798 just create these tool tips and place 8009 05:53:49,920 --> 05:53:55,600 them below each icon. 8010 05:53:52,798 --> 05:53:57,760 So, let's go into our website and we're 8011 05:53:55,600 --> 05:53:59,520 going to add some tool tips to these. 8012 05:53:57,760 --> 05:54:01,280 So, we'll go into our code and I'm going 8013 05:53:59,520 --> 05:54:03,520 to resize the windows so we can see 8014 05:54:01,280 --> 05:54:05,600 better. 8015 05:54:03,520 --> 05:54:08,240 So, we're going to go into our HTML and 8016 05:54:05,600 --> 05:54:10,958 we're going to scroll up to our header 8017 05:54:08,240 --> 05:54:14,480 and let's first find the search icon 8018 05:54:10,958 --> 05:54:17,680 here which is in the middle section and 8019 05:54:14,480 --> 05:54:19,200 then the search button here. 8020 05:54:17,680 --> 05:54:21,040 So, to create the tool tips, we're 8021 05:54:19,200 --> 05:54:23,040 actually going to use the position 8022 05:54:21,040 --> 05:54:24,638 property that we learned earlier. So, 8023 05:54:23,040 --> 05:54:26,958 remember that we use position to put 8024 05:54:24,638 --> 05:54:28,718 this number in the top right corner. 8025 05:54:26,958 --> 05:54:33,040 We're going to use position to put a 8026 05:54:28,718 --> 05:54:36,160 tool tip below the element right here. 8027 05:54:33,040 --> 05:54:40,400 So let's first add a tool tip inside the 8028 05:54:36,160 --> 05:54:43,440 button. So we're going to create a div. 8029 05:54:40,400 --> 05:54:45,600 And let's call this search. 8030 05:54:43,440 --> 05:54:47,600 Let's save it. And now that's our tool 8031 05:54:45,600 --> 05:54:50,160 tip. And now we need to position this 8032 05:54:47,600 --> 05:54:51,920 tool tip relative to our button. So 8033 05:54:50,160 --> 05:54:55,200 remember from the previous lesson, we 8034 05:54:51,920 --> 05:54:57,600 need position absolute inside position 8035 05:54:55,200 --> 05:54:59,920 relative. So, let's first add those 8036 05:54:57,600 --> 05:55:02,878 position properties. So, we're going to 8037 05:54:59,920 --> 05:55:04,718 go into the header CSS file because 8038 05:55:02,878 --> 05:55:07,600 we're working with the header. So, let's 8039 05:55:04,718 --> 05:55:09,280 open that up. 8040 05:55:07,600 --> 05:55:11,520 And I'm going to move it to the right 8041 05:55:09,280 --> 05:55:13,120 side here. 8042 05:55:11,520 --> 05:55:15,840 And now, we're going to scroll down 8043 05:55:13,120 --> 05:55:18,240 until we find our search button. So, I'm 8044 05:55:15,840 --> 05:55:20,160 going to scroll, scroll, scroll, and 8045 05:55:18,240 --> 05:55:21,600 it's right here. So, we're going to set 8046 05:55:20,160 --> 05:55:25,680 this search button, which is our 8047 05:55:21,600 --> 05:55:29,638 container, to position 8048 05:55:25,680 --> 05:55:29,638 colon relative. 8049 05:55:29,920 --> 05:55:35,120 Save it. And nothing happens because 8050 05:55:31,920 --> 05:55:37,120 that's how position relative works. And 8051 05:55:35,120 --> 05:55:39,440 now the magic comes when we set this to 8052 05:55:37,120 --> 05:55:42,240 position absolute. So, we're actually 8053 05:55:39,440 --> 05:55:44,480 going to set a class here so that we can 8054 05:55:42,240 --> 05:55:47,040 target it a little easier. We're going 8055 05:55:44,480 --> 05:55:49,040 to call this tool tip. 8056 05:55:47,040 --> 05:55:51,680 And we're going to use that advanced CSS 8057 05:55:49,040 --> 05:55:56,558 selector we learned earlier. So we're 8058 05:55:51,680 --> 05:55:59,200 going to target search-button first and 8059 05:55:56,558 --> 05:56:04,760 then we're going to type a space and 8060 05:55:59,200 --> 05:56:04,760 then we're going to type dottool tip. 8061 05:56:05,440 --> 05:56:10,240 So this means that we're targeting the 8062 05:56:07,360 --> 05:56:13,520 tool tip class not on the entire page 8063 05:56:10,240 --> 05:56:15,040 but only inside the search button. So 8064 05:56:13,520 --> 05:56:18,080 now we don't have to come up with a 8065 05:56:15,040 --> 05:56:20,000 unique name for this specific tool tip. 8066 05:56:18,080 --> 05:56:22,558 So if we save it, we're going to set 8067 05:56:20,000 --> 05:56:25,520 this to position 8068 05:56:22,558 --> 05:56:28,958 absolute. And now we have an absolute 8069 05:56:25,520 --> 05:56:31,120 element inside a relative element. So if 8070 05:56:28,958 --> 05:56:33,520 we save that, now we can start 8071 05:56:31,120 --> 05:56:35,120 positioning this. Let's give a 8072 05:56:33,520 --> 05:56:39,440 background color so that we can see it 8073 05:56:35,120 --> 05:56:42,000 better. So background dash color of 8074 05:56:39,440 --> 05:56:43,840 maybe gray. 8075 05:56:42,000 --> 05:56:48,558 And let's set the text color to white. 8076 05:56:43,840 --> 05:56:50,000 So color colon white. 8077 05:56:48,558 --> 05:56:55,120 Let's give it some padding on the 8078 05:56:50,000 --> 05:56:57,120 inside. So padding top of maybe four 8079 05:56:55,120 --> 05:57:00,958 pixels. 8080 05:56:57,120 --> 05:57:04,878 Padding dash bottom four pixels. 8081 05:57:00,958 --> 05:57:09,280 Padding left four pixels. And padding 8082 05:57:04,878 --> 05:57:10,638 right four pixels. Save it. And let's 8083 05:57:09,280 --> 05:57:14,000 actually increase the padding on the 8084 05:57:10,638 --> 05:57:17,760 left and right to eight. See how that 8085 05:57:14,000 --> 05:57:20,000 looks. Okay, I'm pretty happy with that. 8086 05:57:17,760 --> 05:57:22,480 And now I'm going to set some rounded 8087 05:57:20,000 --> 05:57:24,400 corners. So we don't have to exactly 8088 05:57:22,480 --> 05:57:27,040 match our design. We can make it close 8089 05:57:24,400 --> 05:57:32,400 enough. So we can set some rounded 8090 05:57:27,040 --> 05:57:34,798 corners. Border dash radius of 4 pixels. 8091 05:57:32,400 --> 05:57:36,718 It's a little too much for me. Set to 2 8092 05:57:34,798 --> 05:57:38,320 pixels. 8093 05:57:36,718 --> 05:57:40,160 And I'm also going to make the font a 8094 05:57:38,320 --> 05:57:45,520 little bit smaller. So I'm going to set 8095 05:57:40,160 --> 05:57:47,760 the font dash size to 12 pixels. Save 8096 05:57:45,520 --> 05:57:49,680 it. I think that looks pretty good to 8097 05:57:47,760 --> 05:57:51,280 me. 8098 05:57:49,680 --> 05:57:54,638 Next, we're going to use the properties 8099 05:57:51,280 --> 05:57:57,760 top, bottom, left, and right to position 8100 05:57:54,638 --> 05:58:01,120 this within the relative element. So for 8101 05:57:57,760 --> 05:58:03,360 our cases, let's start with bottom 8102 05:58:01,120 --> 05:58:05,520 zero. So, this means that the bottom of 8103 05:58:03,360 --> 05:58:07,760 our tool tip will be at the bottom of 8104 05:58:05,520 --> 05:58:09,920 the button. If I save this, that's 8105 05:58:07,760 --> 05:58:12,320 exactly what we have. Now, to move it 8106 05:58:09,920 --> 05:58:14,798 even further to the bottom, we're going 8107 05:58:12,320 --> 05:58:16,958 to use negative pixels. So, let's set 8108 05:58:14,798 --> 05:58:19,680 -20. 8109 05:58:16,958 --> 05:58:21,920 Save it. Okay. So, I think that's 8110 05:58:19,680 --> 05:58:23,920 looking pretty good. Let's increase it a 8111 05:58:21,920 --> 05:58:26,798 little bit more. Let's increase it to 30 8112 05:58:23,920 --> 05:58:28,958 pixels. Save it. Okay. So, I'm happy 8113 05:58:26,798 --> 05:58:31,520 with that position. Now, we're going to 8114 05:58:28,958 --> 05:58:35,600 learn how to make this tool tip appear 8115 05:58:31,520 --> 05:58:37,920 when we hover over this button. 8116 05:58:35,600 --> 05:58:41,040 So, the trick here is we're going to set 8117 05:58:37,920 --> 05:58:44,160 the opacity or how see-through the tool 8118 05:58:41,040 --> 05:58:46,638 tip is to zero, which is completely 8119 05:58:44,160 --> 05:58:47,920 invisible. And then when we hover over 8120 05:58:46,638 --> 05:58:51,600 this button, we're going to set the 8121 05:58:47,920 --> 05:58:53,760 opacity to one. So, how do we actually 8122 05:58:51,600 --> 05:58:56,320 change this when we hover over the 8123 05:58:53,760 --> 05:58:58,878 button? So, we're actually going to use 8124 05:58:56,320 --> 05:59:01,840 a combination of this advanced CSS 8125 05:58:58,878 --> 05:59:05,160 selector and pseudo classes which are 8126 05:59:01,840 --> 05:59:05,160 like hover. 8127 05:59:05,360 --> 05:59:10,718 So, first we're going to target the 8128 05:59:07,280 --> 05:59:14,558 search-b class and we're going to add a 8129 05:59:10,718 --> 05:59:16,000 pseudo class colon hover. 8130 05:59:14,558 --> 05:59:19,120 And now we're going to type another 8131 05:59:16,000 --> 05:59:22,120 selector. We're going to type dot tool 8132 05:59:19,120 --> 05:59:22,120 tip. 8133 05:59:22,320 --> 05:59:26,480 And we're going to set some styles here. 8134 05:59:24,320 --> 05:59:29,280 So, what this does is that we're going 8135 05:59:26,480 --> 05:59:32,718 to target the tool tips only when we're 8136 05:59:29,280 --> 05:59:34,558 hovering over this search button. So, up 8137 05:59:32,718 --> 05:59:36,878 here, notice that we're targeting the 8138 05:59:34,558 --> 05:59:38,558 tool tips inside the search button, 8139 05:59:36,878 --> 05:59:40,958 regardless of whether if we're hovering 8140 05:59:38,558 --> 05:59:43,360 over it or not. In this case, we're 8141 05:59:40,958 --> 05:59:45,120 going to target all tool tips inside the 8142 05:59:43,360 --> 05:59:48,080 search button, but only when we hover 8143 05:59:45,120 --> 05:59:52,120 over it. So, when we hover over it, we 8144 05:59:48,080 --> 05:59:52,120 can set the tool tip opacity 8145 05:59:52,480 --> 05:59:57,520 to one. So, this is a neat trick that 8146 05:59:55,280 --> 06:00:01,360 you can do to create tool tips like 8147 05:59:57,520 --> 06:00:03,440 this. So, if we go into our web page, 8148 06:00:01,360 --> 06:00:05,920 when I'm not hovering over the button, 8149 06:00:03,440 --> 06:00:07,920 you'll notice that the opacity is zero. 8150 06:00:05,920 --> 06:00:09,920 But when I'm hovering over the button, 8151 06:00:07,920 --> 06:00:13,520 this tool tip will have an opacity of 8152 06:00:09,920 --> 06:00:15,040 one, which looks like this. 8153 06:00:13,520 --> 06:00:17,920 And now, because we're changing the 8154 06:00:15,040 --> 06:00:20,878 opacity, we can set a transition. So, 8155 06:00:17,920 --> 06:00:22,958 let's set a transition. 8156 06:00:20,878 --> 06:00:25,680 We need to tell it what to transition, 8157 06:00:22,958 --> 06:00:27,840 which is opacity, 8158 06:00:25,680 --> 06:00:32,480 and how long the transition will take. 8159 06:00:27,840 --> 06:00:34,958 Let's say 0.15 seconds. Save it. And 8160 06:00:32,480 --> 06:00:37,200 when we hover over this, now we get our 8161 06:00:34,958 --> 06:00:38,558 tool tips. 8162 06:00:37,200 --> 06:00:41,120 Now, the last thing I want to show you 8163 06:00:38,558 --> 06:00:44,000 is if we hover over the actual tool tip, 8164 06:00:41,120 --> 06:00:46,878 you'll notice that because it's inside 8165 06:00:44,000 --> 06:00:48,958 this button, when we hover over the tool 8166 06:00:46,878 --> 06:00:53,638 tip with our mouse, it also counts as 8167 06:00:48,958 --> 06:00:53,638 hovering over the button. 8168 06:00:53,760 --> 06:00:58,638 We can fix this by disabling hovers on 8169 06:00:56,160 --> 06:01:00,558 the tool tip and only allow hovers on 8170 06:00:58,638 --> 06:01:03,040 the button. 8171 06:01:00,558 --> 06:01:05,520 So to disable the hover on this tool 8172 06:01:03,040 --> 06:01:10,000 tip, we're going to use another CSS 8173 06:01:05,520 --> 06:01:13,440 property called pointer-ashevents 8174 06:01:10,000 --> 06:01:14,878 colon none. 8175 06:01:13,440 --> 06:01:16,558 This means that when our mouse hovers 8176 06:01:14,878 --> 06:01:18,480 over the tool tip, it's not going to do 8177 06:01:16,558 --> 06:01:20,480 anything. 8178 06:01:18,480 --> 06:01:22,798 So that's how we create these tool tips 8179 06:01:20,480 --> 06:01:25,120 on our web page. Let's do the same thing 8180 06:01:22,798 --> 06:01:28,160 with this voice search button. We're 8181 06:01:25,120 --> 06:01:30,878 going to go into our HTML and we're just 8182 06:01:28,160 --> 06:01:33,040 going to copy this tool tip and just 8183 06:01:30,878 --> 06:01:34,558 move it down here into the voice search 8184 06:01:33,040 --> 06:01:36,638 button. 8185 06:01:34,558 --> 06:01:41,440 Just like that. And let's change the 8186 06:01:36,638 --> 06:01:43,360 text to search with your voice. 8187 06:01:41,440 --> 06:01:45,360 Save it. 8188 06:01:43,360 --> 06:01:48,080 And now remember to position this. We're 8189 06:01:45,360 --> 06:01:50,558 going to have position absolute inside 8190 06:01:48,080 --> 06:01:52,558 position relative. 8191 06:01:50,558 --> 06:01:54,320 So let's turn this to position relative 8192 06:01:52,558 --> 06:01:56,718 first. I'm actually going to make it 8193 06:01:54,320 --> 06:02:00,320 easier for us. I'm going to first target 8194 06:01:56,718 --> 06:02:04,558 the search dash button. 8195 06:02:00,320 --> 06:02:06,638 And I'm going to put this inside here. 8196 06:02:04,558 --> 06:02:10,718 And I'm also going to target with a 8197 06:02:06,638 --> 06:02:12,240 comma the voice search button. So this 8198 06:02:10,718 --> 06:02:14,240 one. 8199 06:02:12,240 --> 06:02:16,320 So now this code is going to apply to 8200 06:02:14,240 --> 06:02:19,120 both of these. So it saves us a little 8201 06:02:16,320 --> 06:02:20,798 bit of coding. Same thing down here. 8202 06:02:19,120 --> 06:02:25,280 We're going to apply all of these styles 8203 06:02:20,798 --> 06:02:29,680 to the search button tool tip. and comma 8204 06:02:25,280 --> 06:02:32,080 the voice search button tool tip. 8205 06:02:29,680 --> 06:02:34,400 So using these advanced CSS selectors 8206 06:02:32,080 --> 06:02:37,120 can save us a lot of code. We're going 8207 06:02:34,400 --> 06:02:40,080 to scroll down all the way here too and 8208 06:02:37,120 --> 06:02:42,638 use a comma 8209 06:02:40,080 --> 06:02:46,400 and set this to 8210 06:02:42,638 --> 06:02:47,920 the voice dash search button. So make 8211 06:02:46,400 --> 06:02:51,280 sure you don't have a comma at the end 8212 06:02:47,920 --> 06:02:53,600 there. Let's save it. Now, when I hover 8213 06:02:51,280 --> 06:02:55,680 over this, you'll notice that it doesn't 8214 06:02:53,600 --> 06:02:58,320 really work because the text is sort of 8215 06:02:55,680 --> 06:03:01,520 wrapping around. We're going to fix that 8216 06:02:58,320 --> 06:03:05,280 by setting this property, 8217 06:03:01,520 --> 06:03:07,920 whites space, no wrap. 8218 06:03:05,280 --> 06:03:10,240 Save it. And this will prevent the text 8219 06:03:07,920 --> 06:03:11,840 from wrapping around. 8220 06:03:10,240 --> 06:03:15,520 Now, the last thing I want to do is to 8221 06:03:11,840 --> 06:03:17,760 center this tool tip with the button. 8222 06:03:15,520 --> 06:03:19,520 To do this, we can use a flexbox because 8223 06:03:17,760 --> 06:03:21,840 remember with flexbox, we can center 8224 06:03:19,520 --> 06:03:24,638 horizontally and vertically. In this 8225 06:03:21,840 --> 06:03:26,480 case, we want to center horizontally. 8226 06:03:24,638 --> 06:03:27,760 So, we're going to make we're going to 8227 06:03:26,480 --> 06:03:31,040 scroll up and we're going to make these 8228 06:03:27,760 --> 06:03:32,878 buttons flex boxes. So, let's set 8229 06:03:31,040 --> 06:03:36,400 display 8230 06:03:32,878 --> 06:03:39,200 flex. By default, it's flex direction 8231 06:03:36,400 --> 06:03:42,400 row. So, justify content is going to 8232 06:03:39,200 --> 06:03:44,000 center horizontally. So, justify content 8233 06:03:42,400 --> 06:03:45,600 center 8234 06:03:44,000 --> 06:03:47,840 and save it. 8235 06:03:45,600 --> 06:03:49,600 So now if we hover over our buttons, 8236 06:03:47,840 --> 06:03:51,680 you'll notice that the tool tips are 8237 06:03:49,600 --> 06:03:53,680 aligned horizontally. 8238 06:03:51,680 --> 06:03:56,320 But you also notice that our icons are 8239 06:03:53,680 --> 06:03:58,400 not vertically aligned very well. So 8240 06:03:56,320 --> 06:04:01,040 let's go back into our code and we're 8241 06:03:58,400 --> 06:04:06,638 going to align them in the center with 8242 06:04:01,040 --> 06:04:09,760 align dash items colon center. Save it. 8243 06:04:06,638 --> 06:04:12,878 So that didn't seem to work. But if we 8244 06:04:09,760 --> 06:04:14,958 scroll down into our code, so way 8245 06:04:12,878 --> 06:04:18,798 earlier in the course, we actually added 8246 06:04:14,958 --> 06:04:21,360 margin top to the search icon as well as 8247 06:04:18,798 --> 06:04:23,920 the voice search icon. So we just need 8248 06:04:21,360 --> 06:04:26,160 to get rid of this margin top and let 8249 06:04:23,920 --> 06:04:29,600 the flexbox handle the vertical 8250 06:04:26,160 --> 06:04:32,080 centering. So if we save that, now the 8251 06:04:29,600 --> 06:04:35,840 icons are perfectly centered. And if we 8252 06:04:32,080 --> 06:04:38,000 hover over, we have a centered tool tip. 8253 06:04:35,840 --> 06:04:41,200 The tool tips for these icons are the 8254 06:04:38,000 --> 06:04:43,280 same thing except if we scroll down, we 8255 06:04:41,200 --> 06:04:45,200 currently just have an image. We're 8256 06:04:43,280 --> 06:04:47,040 going to need a container like this 8257 06:04:45,200 --> 06:04:49,760 that's going to act as our position 8258 06:04:47,040 --> 06:04:51,600 relative container. So let's create a 8259 06:04:49,760 --> 06:04:54,480 div 8260 06:04:51,600 --> 06:04:57,040 that's going to contain our upload icon. 8261 06:04:54,480 --> 06:05:01,040 Let's cut this and then paste it in 8262 06:04:57,040 --> 06:05:06,120 here. Let's give a class 8263 06:05:01,040 --> 06:05:06,120 of upload- icon-container. 8264 06:05:07,120 --> 06:05:10,958 And then inside this container, we're 8265 06:05:09,120 --> 06:05:15,760 going to have our tool tip. So let's 8266 06:05:10,958 --> 06:05:18,320 copy this and then paste it in here. 8267 06:05:15,760 --> 06:05:23,080 And let's call this, 8268 06:05:18,320 --> 06:05:23,080 let's look at our design create. 8269 06:05:23,280 --> 06:05:28,920 So, our tool tip is going to have the 8270 06:05:24,718 --> 06:05:28,920 text create. 8271 06:05:29,920 --> 06:05:33,920 Next, we're going to change this to 8272 06:05:31,120 --> 06:05:37,360 position relative and position absolute 8273 06:05:33,920 --> 06:05:39,840 inside. So, let's scroll up and we 8274 06:05:37,360 --> 06:05:41,520 already have this code here that sets to 8275 06:05:39,840 --> 06:05:44,160 position relative and centers 8276 06:05:41,520 --> 06:05:47,280 everything. We're going to add to this 8277 06:05:44,160 --> 06:05:50,280 the upload icon container dot 8278 06:05:47,280 --> 06:05:50,280 upload-icon-container. 8279 06:05:51,200 --> 06:05:56,080 Save it. 8280 06:05:53,680 --> 06:05:58,400 And then we need a position absolute on 8281 06:05:56,080 --> 06:06:00,400 this tool tip. So again, we can just add 8282 06:05:58,400 --> 06:06:04,240 it in here so we don't have to copy all 8283 06:06:00,400 --> 06:06:08,360 this code again with a comma 8284 06:06:04,240 --> 06:06:08,360 upload icon-container 8285 06:06:08,798 --> 06:06:15,040 dot tool tip. 8286 06:06:12,400 --> 06:06:17,760 Save it. And lastly, we're going to 8287 06:06:15,040 --> 06:06:20,958 scroll down and add it to here so that 8288 06:06:17,760 --> 06:06:26,558 appears when we hover. 8289 06:06:20,958 --> 06:06:30,718 So let's set doupload d- icon container 8290 06:06:26,558 --> 06:06:34,320 and dot when we hover over it the tool 8291 06:06:30,718 --> 06:06:37,680 tip is going to have opacity of one. 8292 06:06:34,320 --> 06:06:40,400 Let's save it and hover over. All right. 8293 06:06:37,680 --> 06:06:43,920 So that looks pretty good. But let's 8294 06:06:40,400 --> 06:06:47,360 change the font here. So let's go into 8295 06:06:43,920 --> 06:06:51,520 this code which sets our tool tip styles 8296 06:06:47,360 --> 06:06:53,520 and let's set the font dash family to 8297 06:06:51,520 --> 06:06:57,200 Roboto, 8298 06:06:53,520 --> 06:06:59,440 Ariel like before. If we save it and we 8299 06:06:57,200 --> 06:07:02,240 hover over it, now we have a nice 8300 06:06:59,440 --> 06:07:03,920 looking tool tip on our icons. So that's 8301 06:07:02,240 --> 06:07:05,520 how we create these tool tips. When we 8302 06:07:03,920 --> 06:07:07,520 hover over these icons and these 8303 06:07:05,520 --> 06:07:09,840 buttons, creating tool tips for these 8304 06:07:07,520 --> 06:07:11,520 two other icons are the same thing. and 8305 06:07:09,840 --> 06:07:13,920 I'm going to leave it as an exercise for 8306 06:07:11,520 --> 06:07:15,760 you to do on your own. 8307 06:07:13,920 --> 06:07:18,240 So, in this lesson, we finished up our 8308 06:07:15,760 --> 06:07:20,080 final project. We created the sidebar, 8309 06:07:18,240 --> 06:07:22,080 resized our videos, created the tool 8310 06:07:20,080 --> 06:07:24,638 tips, and now if we compare it to our 8311 06:07:22,080 --> 06:07:28,840 design, our project looks pretty much 8312 06:07:24,638 --> 06:07:28,840 perfect and ready to go. 8313 06:07:29,520 --> 06:07:33,600 So, here's some exercises you can try on 8314 06:07:31,360 --> 06:07:37,240 your own to wrap up everything that we 8315 06:07:33,600 --> 06:07:37,240 learned in this course. 8316 06:07:49,360 --> 06:07:53,760 In the previous lesson, we finished our 8317 06:07:51,200 --> 06:07:55,200 final project, which is this. In this 8318 06:07:53,760 --> 06:07:58,000 lesson, I'm going to show you some more 8319 06:07:55,200 --> 06:08:01,200 useful features of CSS. We're going to 8320 06:07:58,000 --> 06:08:04,160 start off with responsive design. If we 8321 06:08:01,200 --> 06:08:05,600 go to our reference design here, and I'm 8322 06:08:04,160 --> 06:08:09,200 going to zoom out a little bit so you 8323 06:08:05,600 --> 06:08:11,120 can see if I make the page smaller, 8324 06:08:09,200 --> 06:08:13,680 you'll notice that we now have two 8325 06:08:11,120 --> 06:08:17,360 videos in each row. If I make the page 8326 06:08:13,680 --> 06:08:20,080 bigger, we have four videos. So notice 8327 06:08:17,360 --> 06:08:22,480 that at every screen size, the layout 8328 06:08:20,080 --> 06:08:25,040 adjusts so that the website looks good. 8329 06:08:22,480 --> 06:08:26,718 So that's the idea of responsive design, 8330 06:08:25,040 --> 06:08:30,080 making the website look as good as 8331 06:08:26,718 --> 06:08:32,958 possible on every screen size. Now, if 8332 06:08:30,080 --> 06:08:35,280 we make this a little bit more narrow 8333 06:08:32,958 --> 06:08:37,120 and we switch to our current project, 8334 06:08:35,280 --> 06:08:38,878 you'll notice that all of our content is 8335 06:08:37,120 --> 06:08:41,200 sort of squished. So, we're going to 8336 06:08:38,878 --> 06:08:43,920 learn how to implement responsive design 8337 06:08:41,200 --> 06:08:47,040 into our project. 8338 06:08:43,920 --> 06:08:51,040 Let's go into our code and we're going 8339 06:08:47,040 --> 06:08:53,600 to open the file called video.css 8340 06:08:51,040 --> 06:08:56,480 which controls the video grid styles. 8341 06:08:53,600 --> 06:08:59,040 Let's open that. 8342 06:08:56,480 --> 06:09:01,680 And now inside we're going to adjust our 8343 06:08:59,040 --> 06:09:04,160 video grid so that when the screen size 8344 06:09:01,680 --> 06:09:06,878 is small we only have two videos per 8345 06:09:04,160 --> 06:09:10,240 row. And when the screen size is big we 8346 06:09:06,878 --> 06:09:12,558 have more than three videos per row. So 8347 06:09:10,240 --> 06:09:15,360 let's go into our code. We're going to 8348 06:09:12,558 --> 06:09:18,000 scroll down and find the video grid 8349 06:09:15,360 --> 06:09:22,400 styles. So notice that for these styles 8350 06:09:18,000 --> 06:09:24,480 we set three columns of equal size. Now 8351 06:09:22,400 --> 06:09:27,600 to make this responsive, we're going to 8352 06:09:24,480 --> 06:09:29,440 use something called a media query. 8353 06:09:27,600 --> 06:09:33,120 So to create a media query, we're going 8354 06:09:29,440 --> 06:09:35,360 to type at media and then we're going to 8355 06:09:33,120 --> 06:09:41,840 give it a screen size. So we're going to 8356 06:09:35,360 --> 06:09:43,600 say max dash width colon maybe 600 8357 06:09:41,840 --> 06:09:45,440 pixels. 8358 06:09:43,600 --> 06:09:47,280 And then we're going to type open 8359 06:09:45,440 --> 06:09:50,160 squiggly bracket and then close squiggly 8360 06:09:47,280 --> 06:09:51,840 bracket. So, the way this works is that 8361 06:09:50,160 --> 06:09:55,440 we're going to have a bunch of CSS in 8362 06:09:51,840 --> 06:09:59,040 here. And this CSS will only activate if 8363 06:09:55,440 --> 06:10:01,520 the screen size is 600 pixels or less. 8364 06:09:59,040 --> 06:10:04,718 That's what this max width means. So, 8365 06:10:01,520 --> 06:10:08,240 for example, let's target the video grid 8366 06:10:04,718 --> 06:10:12,480 class inside here. 8367 06:10:08,240 --> 06:10:16,958 And let's set the grid-template-c 8368 06:10:12,480 --> 06:10:19,760 columns to one fr. 8369 06:10:16,958 --> 06:10:22,480 That means from a screen size of zero to 8370 06:10:19,760 --> 06:10:26,320 600 pixels, we're only going to have two 8371 06:10:22,480 --> 06:10:29,280 columns. So, we save it and we start to 8372 06:10:26,320 --> 06:10:32,000 resize. Notice that once we get to 600 8373 06:10:29,280 --> 06:10:33,600 pixels, we now have two columns in our 8374 06:10:32,000 --> 06:10:35,200 grid. 8375 06:10:33,600 --> 06:10:40,320 Now, to figure out how big our screen 8376 06:10:35,200 --> 06:10:42,000 size is, we can rightclick and inspect. 8377 06:10:40,320 --> 06:10:44,080 And I'm going to click these three dots 8378 06:10:42,000 --> 06:10:47,040 and move it back down to the bottom like 8379 06:10:44,080 --> 06:10:49,120 this. And now when we resize, you should 8380 06:10:47,040 --> 06:10:52,160 see the screen size at the top right of 8381 06:10:49,120 --> 06:10:54,320 the page. 8382 06:10:52,160 --> 06:10:56,320 So it's really up to us to pick a screen 8383 06:10:54,320 --> 06:11:00,558 size where we're going to go from three 8384 06:10:56,320 --> 06:11:05,520 columns to two. So I think even at this 8385 06:11:00,558 --> 06:11:07,200 screen size, maybe at 750, 8386 06:11:05,520 --> 06:11:12,320 it looks a little bit squished. So I'm 8387 06:11:07,200 --> 06:11:16,400 going to increase this to 750 pixels. 8388 06:11:12,320 --> 06:11:18,718 Save it. And now once we get to 750, 8389 06:11:16,400 --> 06:11:20,958 we're going to have two videos in each 8390 06:11:18,718 --> 06:11:23,760 row and it's not going to be as squished 8391 06:11:20,958 --> 06:11:26,080 anymore. So that's the basics of how to 8392 06:11:23,760 --> 06:11:28,400 create responsive designs using these 8393 06:11:26,080 --> 06:11:30,480 media queries. 8394 06:11:28,400 --> 06:11:32,878 Let's do another example. We're going to 8395 06:11:30,480 --> 06:11:35,440 have four videos per row when our screen 8396 06:11:32,878 --> 06:11:39,440 size gets really big. So let's set 8397 06:11:35,440 --> 06:11:41,120 another at media at media. 8398 06:11:39,440 --> 06:11:43,840 And for this time, we're going to set a 8399 06:11:41,120 --> 06:11:48,400 minimum width 8400 06:11:43,840 --> 06:11:50,558 of maybe 1,000 pixels. 8401 06:11:48,400 --> 06:11:53,440 And then inside here, we're going to 8402 06:11:50,558 --> 06:11:55,840 copy this and then paste it here. We're 8403 06:11:53,440 --> 06:11:59,600 going to change grid template columns to 8404 06:11:55,840 --> 06:12:03,600 four columns. So, one fr 1 FR. Now, if 8405 06:11:59,600 --> 06:12:06,638 we save it and we resize the browser to 8406 06:12:03,600 --> 06:12:09,040 1,000 pixels, it's going to become four 8407 06:12:06,638 --> 06:12:12,000 videos per row. Now you might need to 8408 06:12:09,040 --> 06:12:15,200 press command or control minus to make 8409 06:12:12,000 --> 06:12:17,120 the web page smaller to see this but 8410 06:12:15,200 --> 06:12:19,920 basically the way this works is that 8411 06:12:17,120 --> 06:12:22,160 once the screen size hits 1,000 pixels 8412 06:12:19,920 --> 06:12:26,400 this will activate and we have four 8413 06:12:22,160 --> 06:12:27,920 columns instead of three. 8414 06:12:26,400 --> 06:12:29,920 So the last example is that we can 8415 06:12:27,920 --> 06:12:33,120 actually combine these two. So we can 8416 06:12:29,920 --> 06:12:37,920 set at media 8417 06:12:33,120 --> 06:12:39,440 and we can set the min- width to 751 8418 06:12:37,920 --> 06:12:47,040 pixels 8419 06:12:39,440 --> 06:12:50,080 and the max dash width to 999 pixels. 8420 06:12:47,040 --> 06:12:52,240 So this will cover the space between 8421 06:12:50,080 --> 06:12:56,000 these two measurements here. So let's 8422 06:12:52,240 --> 06:12:58,958 actually put this in the middle. 8423 06:12:56,000 --> 06:13:01,680 Okay. So from zero pixels to a max of 8424 06:12:58,958 --> 06:13:05,200 750, we're going to have these styles. 8425 06:13:01,680 --> 06:13:08,240 And then from 751 to 999, we're going to 8426 06:13:05,200 --> 06:13:10,718 have these styles. We're going to set 8427 06:13:08,240 --> 06:13:13,120 this to three columns. 8428 06:13:10,718 --> 06:13:16,400 And then from 1,000 and up, we're going 8429 06:13:13,120 --> 06:13:18,958 to have four columns. So this is the 8430 06:13:16,400 --> 06:13:21,680 basics of how to create a responsive 8431 06:13:18,958 --> 06:13:25,440 design like this. You just have to write 8432 06:13:21,680 --> 06:13:26,878 a lot of media queries. 8433 06:13:25,440 --> 06:13:28,958 All right. So, that's the basics of 8434 06:13:26,878 --> 06:13:31,840 responsive design. We're going to go 8435 06:13:28,958 --> 06:13:34,320 back to our web pages. I'm just going to 8436 06:13:31,840 --> 06:13:36,320 zoom back in and we'll learn the next 8437 06:13:34,320 --> 06:13:38,480 feature of CSS. 8438 06:13:36,320 --> 06:13:42,400 So, let's go to our project here and 8439 06:13:38,480 --> 06:13:45,600 open our code and let's scroll down to 8440 06:13:42,400 --> 06:13:47,040 this style, the video time. So, the next 8441 06:13:45,600 --> 06:13:49,680 feature we're going to learn is sort of 8442 06:13:47,040 --> 06:13:51,520 like CSS shortcuts. 8443 06:13:49,680 --> 06:13:53,840 So instead of setting padding on the 8444 06:13:51,520 --> 06:13:55,920 left, right, top and bottom separately 8445 06:13:53,840 --> 06:13:59,200 like this, we can actually use a 8446 06:13:55,920 --> 06:14:01,280 property called padding, which is sort 8447 06:13:59,200 --> 06:14:04,000 of like a shortcut for all four of 8448 06:14:01,280 --> 06:14:06,558 these. So if we set the padding to four 8449 06:14:04,000 --> 06:14:08,718 pixels, this is the same as setting 8450 06:14:06,558 --> 06:14:11,280 padding on all four sides. So we don't 8451 06:14:08,718 --> 06:14:13,360 need this code anymore. 8452 06:14:11,280 --> 06:14:16,080 So it makes it a little cleaner for our 8453 06:14:13,360 --> 06:14:18,240 code to use these shorthand properties. 8454 06:14:16,080 --> 06:14:20,638 So another thing we can do with this is 8455 06:14:18,240 --> 06:14:24,638 we can have two values. Let's say 4 8456 06:14:20,638 --> 06:14:26,400 pixels and 10 pixels. Save it. So this 8457 06:14:24,638 --> 06:14:29,520 first value is going to be the vertical 8458 06:14:26,400 --> 06:14:31,520 padding. So padding top, padding bottom. 8459 06:14:29,520 --> 06:14:36,558 And the second value is horizontal 8460 06:14:31,520 --> 06:14:38,480 padding. Padding left and padding right. 8461 06:14:36,558 --> 06:14:42,240 The next thing we can do is have four 8462 06:14:38,480 --> 06:14:45,680 directions. So 20 pixels and 30 pixels. 8463 06:14:42,240 --> 06:14:47,840 Let's see how that looks. 8464 06:14:45,680 --> 06:14:51,040 So this is how we can set padding in all 8465 06:14:47,840 --> 06:14:53,680 four directions using one line of CSS. 8466 06:14:51,040 --> 06:14:56,160 This first value is the padding top. 8467 06:14:53,680 --> 06:14:58,320 Second value is the padding right. Third 8468 06:14:56,160 --> 06:15:01,280 value is padding bottom and fourth is 8469 06:14:58,320 --> 06:15:03,280 padding left. You can think of this as 8470 06:15:01,280 --> 06:15:06,638 first you start from the top and then 8471 06:15:03,280 --> 06:15:09,520 you work your way clockwise around. So 8472 06:15:06,638 --> 06:15:13,120 that's what these four values mean. 8473 06:15:09,520 --> 06:15:16,160 Another shorthand property is margin 8474 06:15:13,120 --> 06:15:20,320 and this is a substitute for margin- 8475 06:15:16,160 --> 06:15:22,958 left margin- right margin top and margin 8476 06:15:20,320 --> 06:15:25,520 bottom. So this margin shorthand 8477 06:15:22,958 --> 06:15:28,160 property works the same way as padding. 8478 06:15:25,520 --> 06:15:30,878 If we have one value, this is all four 8479 06:15:28,160 --> 06:15:33,200 directions. If we have two values, this 8480 06:15:30,878 --> 06:15:36,080 first value is the vertical direction. 8481 06:15:33,200 --> 06:15:38,958 Second is the horizontal direction. 8482 06:15:36,080 --> 06:15:41,600 And if we have four values of margin, 8483 06:15:38,958 --> 06:15:43,680 this is the top, right, bottom, and 8484 06:15:41,600 --> 06:15:45,440 left. 8485 06:15:43,680 --> 06:15:48,080 So these are just examples. We're going 8486 06:15:45,440 --> 06:15:51,600 to move our styles back to four pixels 8487 06:15:48,080 --> 06:15:53,040 of padding on every side. 8488 06:15:51,600 --> 06:15:56,000 And we're going to look at one final 8489 06:15:53,040 --> 06:15:59,360 shorthand property, which is the border. 8490 06:15:56,000 --> 06:16:02,400 So let's go into our header CSS file and 8491 06:15:59,360 --> 06:16:04,878 find the styles for this search bar. So, 8492 06:16:02,400 --> 06:16:06,958 we're going to scroll up until we find 8493 06:16:04,878 --> 06:16:09,040 our search bar, which is here. And 8494 06:16:06,958 --> 06:16:12,080 notice for our borders, we always set a 8495 06:16:09,040 --> 06:16:13,760 width, a border style, and a border 8496 06:16:12,080 --> 06:16:15,120 color. 8497 06:16:13,760 --> 06:16:18,000 So, instead of setting these styles 8498 06:16:15,120 --> 06:16:21,120 separately, we can use a shortand called 8499 06:16:18,000 --> 06:16:23,840 border. So, for border, we can set one 8500 06:16:21,120 --> 06:16:26,400 pixel. This is going to be the width. We 8501 06:16:23,840 --> 06:16:28,798 can set another value of solid. This is 8502 06:16:26,400 --> 06:16:33,718 going to be the border style. And we can 8503 06:16:28,798 --> 06:16:33,718 set the third value of color. 8504 06:16:34,480 --> 06:16:40,240 And so this one line of CSS can replace 8505 06:16:37,040 --> 06:16:42,400 these three. If we delete that, then we 8506 06:16:40,240 --> 06:16:43,920 save, you can see that everything still 8507 06:16:42,400 --> 06:16:46,160 appears normally. And that's because 8508 06:16:43,920 --> 06:16:49,040 this border property is a shorthand for 8509 06:16:46,160 --> 06:16:50,480 the other three. 8510 06:16:49,040 --> 06:16:52,320 The next thing we're going to learn is 8511 06:16:50,480 --> 06:16:56,000 called inheritance. 8512 06:16:52,320 --> 06:16:58,718 Let's go to our YouTube.html HTML file 8513 06:16:56,000 --> 06:17:00,798 and we're going to scroll down to the 8514 06:16:58,718 --> 06:17:03,360 video grid 8515 06:17:00,798 --> 06:17:05,360 which is right here. 8516 06:17:03,360 --> 06:17:08,400 So inheritance means that for certain 8517 06:17:05,360 --> 06:17:10,638 CSS properties if we set the property on 8518 06:17:08,400 --> 06:17:13,840 the outer element it will get passed 8519 06:17:10,638 --> 06:17:15,520 down to the inner elements like these. 8520 06:17:13,840 --> 06:17:18,240 Let's do an example. We're going to set 8521 06:17:15,520 --> 06:17:21,280 a property on the video grid. We're 8522 06:17:18,240 --> 06:17:22,958 going to go to the video.css CSS file 8523 06:17:21,280 --> 06:17:26,718 and we're going to find the video grid 8524 06:17:22,958 --> 06:17:28,798 styles which is all of these. We're 8525 06:17:26,718 --> 06:17:30,080 going to set it on this style here. So, 8526 06:17:28,798 --> 06:17:32,320 we're going to set it for all screen 8527 06:17:30,080 --> 06:17:34,080 sizes. 8528 06:17:32,320 --> 06:17:36,798 Let's add a style. We're going to make 8529 06:17:34,080 --> 06:17:38,160 the text underlined. 8530 06:17:36,798 --> 06:17:42,360 To do that, we're going to use this 8531 06:17:38,160 --> 06:17:42,360 property text-decoration 8532 06:17:42,480 --> 06:17:48,958 colon underline. 8533 06:17:45,920 --> 06:17:51,680 Now if I save this you'll see that even 8534 06:17:48,958 --> 06:17:54,638 though I set text decoration underline 8535 06:17:51,680 --> 06:17:58,000 on the video grid all the paragraphs 8536 06:17:54,638 --> 06:18:01,200 inside have been underlined. So this is 8537 06:17:58,000 --> 06:18:03,600 called inheritance. If we set this style 8538 06:18:01,200 --> 06:18:06,240 on the outer element which is the video 8539 06:18:03,600 --> 06:18:09,680 grid, it gets passed down to all the 8540 06:18:06,240 --> 06:18:11,680 inner elements which are the paragraphs 8541 06:18:09,680 --> 06:18:13,840 here. 8542 06:18:11,680 --> 06:18:16,480 However, not all properties are affected 8543 06:18:13,840 --> 06:18:19,920 by inheritance. For example, if we go 8544 06:18:16,480 --> 06:18:22,400 back to the video.css file, and we're 8545 06:18:19,920 --> 06:18:25,360 going to add a border this time. So, 8546 06:18:22,400 --> 06:18:26,718 let's add a border. 8547 06:18:25,360 --> 06:18:28,320 And we're going to make it 2 pixels 8548 06:18:26,718 --> 06:18:31,040 wide, 8549 06:18:28,320 --> 06:18:33,840 a solid color, 8550 06:18:31,040 --> 06:18:36,638 and let's just make it red. 8551 06:18:33,840 --> 06:18:39,200 And if I save that, you'll see that the 8552 06:18:36,638 --> 06:18:41,600 video grid has a border around it. But 8553 06:18:39,200 --> 06:18:44,240 this border is not passed down to the 8554 06:18:41,600 --> 06:18:46,558 inner elements here. 8555 06:18:44,240 --> 06:18:49,040 So inheritance mostly just works with 8556 06:18:46,558 --> 06:18:52,240 text properties like text decoration, 8557 06:18:49,040 --> 06:18:54,480 underline, color, font weight, and font 8558 06:18:52,240 --> 06:18:58,320 family. It doesn't affect things like 8559 06:18:54,480 --> 06:19:00,160 border, padding or margin. 8560 06:18:58,320 --> 06:19:01,760 So that's what inheritance means. 8561 06:19:00,160 --> 06:19:04,080 Certain properties, mostly text 8562 06:19:01,760 --> 06:19:07,840 properties, will get passed down from 8563 06:19:04,080 --> 06:19:10,160 the outer element to the inner elements. 8564 06:19:07,840 --> 06:19:12,558 Now this can save us some code. For 8565 06:19:10,160 --> 06:19:14,160 example, if we go back to the video.css 8566 06:19:12,558 --> 06:19:16,638 file 8567 06:19:14,160 --> 06:19:19,200 and we scroll down, you can see that the 8568 06:19:16,638 --> 06:19:22,080 video time uses a style called font 8569 06:19:19,200 --> 06:19:24,638 family rooto aerial. So this changes the 8570 06:19:22,080 --> 06:19:26,240 font of our text. 8571 06:19:24,638 --> 06:19:28,160 And instead of putting it on the video 8572 06:19:26,240 --> 06:19:30,160 time, we're just going to put it on the 8573 06:19:28,160 --> 06:19:32,320 entire grid. And then it will get 8574 06:19:30,160 --> 06:19:34,798 inherited by all the elements inside 8575 06:19:32,320 --> 06:19:38,320 which includes the video time. So I can 8576 06:19:34,798 --> 06:19:42,958 scroll up to the video grid and I can 8577 06:19:38,320 --> 06:19:45,280 set the font dash family up here. So I 8578 06:19:42,958 --> 06:19:48,280 can set roboto, 8579 06:19:45,280 --> 06:19:48,280 arerial. 8580 06:19:48,558 --> 06:19:53,840 If I save this, you'll see that nothing 8581 06:19:50,718 --> 06:19:56,400 changed with the video time because this 8582 06:19:53,840 --> 06:19:58,480 style is being inherited from the video 8583 06:19:56,400 --> 06:20:00,000 grid. 8584 06:19:58,480 --> 06:20:02,080 Now we can actually take this even 8585 06:20:00,000 --> 06:20:05,040 further. If we go to the YouTube.html 8586 06:20:02,080 --> 06:20:08,320 HTML file, you'll see that this video 8587 06:20:05,040 --> 06:20:11,360 grid is actually contained within the 8588 06:20:08,320 --> 06:20:13,520 entire body. 8589 06:20:11,360 --> 06:20:15,840 So all of our elements on the page are 8590 06:20:13,520 --> 06:20:18,958 contained within the body. So if we want 8591 06:20:15,840 --> 06:20:21,040 to set a sort of default text style on 8592 06:20:18,958 --> 06:20:23,360 the entire page, we can actually just 8593 06:20:21,040 --> 06:20:26,320 put everything in the body and that'll 8594 06:20:23,360 --> 06:20:29,920 save us a lot of code. So let's actually 8595 06:20:26,320 --> 06:20:33,040 go back to the video.css file. 8596 06:20:29,920 --> 06:20:36,160 We're going to remove this 8597 06:20:33,040 --> 06:20:38,558 and save it. You'll see that the video 8598 06:20:36,160 --> 06:20:41,840 time now goes back to the default font, 8599 06:20:38,558 --> 06:20:44,080 which is Times New Roman. And these 8600 06:20:41,840 --> 06:20:46,798 paragraphs actually use a different set 8601 06:20:44,080 --> 06:20:49,920 of styles. So, if we go to the file 8602 06:20:46,798 --> 06:20:51,760 called general.css, 8603 06:20:49,920 --> 06:20:56,718 we set the font family for these 8604 06:20:51,760 --> 06:20:59,360 paragraphs using just a P selector here. 8605 06:20:56,718 --> 06:21:01,440 If we remove this 8606 06:20:59,360 --> 06:21:03,280 and save it, you'll see that it goes 8607 06:21:01,440 --> 06:21:05,440 back to the default font of Times New 8608 06:21:03,280 --> 06:21:07,600 Roman. Now, we're going to set this 8609 06:21:05,440 --> 06:21:09,440 style on the body so that it gets 8610 06:21:07,600 --> 06:21:12,878 inherited 8611 06:21:09,440 --> 06:21:16,080 to the entire web page inside. 8612 06:21:12,878 --> 06:21:20,798 So, we'll go to general.css CSS 8613 06:21:16,080 --> 06:21:23,520 and we're going to set font-f family 8614 06:21:20,798 --> 06:21:26,638 to Roboto, 8615 06:21:23,520 --> 06:21:29,040 Ariel to take advantage of inheritance. 8616 06:21:26,638 --> 06:21:31,360 If I save this, 8617 06:21:29,040 --> 06:21:33,760 you'll see that all of the fonts went 8618 06:21:31,360 --> 06:21:36,160 back to Roboto. And that's because we 8619 06:21:33,760 --> 06:21:38,558 set it on the body and all of our 8620 06:21:36,160 --> 06:21:40,958 elements are inside the body. So, this 8621 06:21:38,558 --> 06:21:42,878 style gets inherited to the inner 8622 06:21:40,958 --> 06:21:45,520 elements. 8623 06:21:42,878 --> 06:21:48,878 So using this we can save more code. If 8624 06:21:45,520 --> 06:21:51,440 we go to our sidebar and our header, if 8625 06:21:48,878 --> 06:21:54,000 I go to the sidebar first, you'll notice 8626 06:21:51,440 --> 06:21:57,120 that we're also using font family rooto 8627 06:21:54,000 --> 06:21:59,280 aerial. So we can simply get rid of this 8628 06:21:57,120 --> 06:22:02,480 because this style is being inherited 8629 06:21:59,280 --> 06:22:06,638 from the body. 8630 06:22:02,480 --> 06:22:08,718 And if I go to the header.css, 8631 06:22:06,638 --> 06:22:10,878 you'll notice that we're also using font 8632 06:22:08,718 --> 06:22:13,120 family Roboto Ariel in a bunch of 8633 06:22:10,878 --> 06:22:16,080 places. So, we can just get rid of all 8634 06:22:13,120 --> 06:22:21,000 of these and take advantage of 8635 06:22:16,080 --> 06:22:21,000 inheritance to save us some code. 8636 06:22:25,680 --> 06:22:28,638 All right. So, there's one last thing 8637 06:22:27,120 --> 06:22:30,718 about inheritance that I want to show 8638 06:22:28,638 --> 06:22:35,520 you. We're going to go back to our 8639 06:22:30,718 --> 06:22:37,200 video.css file, which is right here. 8640 06:22:35,520 --> 06:22:41,280 And now, let's get rid of these 8641 06:22:37,200 --> 06:22:44,240 properties that we using to test with. 8642 06:22:41,280 --> 06:22:46,320 Save it. This time we're going to go to 8643 06:22:44,240 --> 06:22:48,638 general.css. We're going to set another 8644 06:22:46,320 --> 06:22:53,280 style in the body and we're going to set 8645 06:22:48,638 --> 06:22:56,240 the property color red to change the 8646 06:22:53,280 --> 06:22:59,120 text color of the entire page to red. If 8647 06:22:56,240 --> 06:23:01,520 I save it, you'll see that a lot of the 8648 06:22:59,120 --> 06:23:03,600 text is now red, like the sidebar and 8649 06:23:01,520 --> 06:23:06,240 the video titles, but not all of the 8650 06:23:03,600 --> 06:23:08,080 text has been turned to red. So, why is 8651 06:23:06,240 --> 06:23:09,680 this happening? 8652 06:23:08,080 --> 06:23:12,718 We mentioned this in one of our earlier 8653 06:23:09,680 --> 06:23:15,120 lessons. CSS follows a sort of priority 8654 06:23:12,718 --> 06:23:18,638 when you set the same style on the same 8655 06:23:15,120 --> 06:23:21,200 element. So for these video author and 8656 06:23:18,638 --> 06:23:23,440 video stats paragraphs, 8657 06:23:21,200 --> 06:23:25,840 first we set a color of red from the 8658 06:23:23,440 --> 06:23:28,160 body. So that gets inherited down. But 8659 06:23:25,840 --> 06:23:30,320 then if we look at the CSS for these in 8660 06:23:28,160 --> 06:23:33,360 video.css CSS 8661 06:23:30,320 --> 06:23:36,718 and go into the video author which is 8662 06:23:33,360 --> 06:23:40,558 right here. You can see that we also set 8663 06:23:36,718 --> 06:23:43,280 the color to this gray color. So the 8664 06:23:40,558 --> 06:23:45,360 color is being set both by these styles 8665 06:23:43,280 --> 06:23:48,160 and by the styles that are inherited 8666 06:23:45,360 --> 06:23:50,480 from the body. However, this style is 8667 06:23:48,160 --> 06:23:53,280 more specific because it only targets 8668 06:23:50,480 --> 06:23:55,760 the video author and the video stats. 8669 06:23:53,280 --> 06:23:58,558 While the style in the body targets the 8670 06:23:55,760 --> 06:24:01,600 entire page. So that's why this style 8671 06:23:58,558 --> 06:24:03,200 has higher priority than the inherited 8672 06:24:01,600 --> 06:24:06,320 style. 8673 06:24:03,200 --> 06:24:08,320 This is called CSS specificity. 8674 06:24:06,320 --> 06:24:10,240 Generally, if we set the same style on 8675 06:24:08,320 --> 06:24:12,400 the same elements like we have in this 8676 06:24:10,240 --> 06:24:14,638 situation, the style that is more 8677 06:24:12,400 --> 06:24:16,878 specific, for example, this style 8678 06:24:14,638 --> 06:24:19,200 targets only the video author and video 8679 06:24:16,878 --> 06:24:22,240 stats. The style that is more specific 8680 06:24:19,200 --> 06:24:24,878 has higher priority and it will override 8681 06:24:22,240 --> 06:24:26,558 a more general style, which is what we 8682 06:24:24,878 --> 06:24:29,520 have here. 8683 06:24:26,558 --> 06:24:31,680 So using inheritance and specificity, 8684 06:24:29,520 --> 06:24:34,000 we're able to both set a default style 8685 06:24:31,680 --> 06:24:36,240 on the outer element and then if we need 8686 06:24:34,000 --> 06:24:39,280 to, we can go to the inner element and 8687 06:24:36,240 --> 06:24:40,718 then override that style. Now, in this 8688 06:24:39,280 --> 06:24:43,280 course, we didn't go through a lot of 8689 06:24:40,718 --> 06:24:44,480 detail about specificity and its rules. 8690 06:24:43,280 --> 06:24:46,958 And that's because we were mostly 8691 06:24:44,480 --> 06:24:48,718 focused on building out this project, 8692 06:24:46,958 --> 06:24:51,520 but you can find all the details about 8693 06:24:48,718 --> 06:24:54,240 specificity in the HTML and CSS 8694 06:24:51,520 --> 06:24:57,600 reference below the video. 8695 06:24:54,240 --> 06:25:00,320 For now, let's go back into general.css 8696 06:24:57,600 --> 06:25:02,558 and let's get rid of this practice style 8697 06:25:00,320 --> 06:25:06,080 that we were using. 8698 06:25:02,558 --> 06:25:07,280 And now we're ready to move on. 8699 06:25:06,080 --> 06:25:10,400 Next, we're going to learn about 8700 06:25:07,280 --> 06:25:14,000 semantic elements. If we go back to our 8701 06:25:10,400 --> 06:25:15,600 YouTube.html file. 8702 06:25:14,000 --> 06:25:18,480 So, we learned about a bunch of elements 8703 06:25:15,600 --> 06:25:20,080 like the div, the image, and the button. 8704 06:25:18,480 --> 06:25:22,798 There's also another set of elements 8705 06:25:20,080 --> 06:25:26,480 called semantic elements. So for 8706 06:25:22,798 --> 06:25:30,320 example, header is a semantic element 8707 06:25:26,480 --> 06:25:32,320 and another example is the nav element. 8708 06:25:30,320 --> 06:25:34,718 So these elements actually work the same 8709 06:25:32,320 --> 06:25:36,878 way as a div except they have a special 8710 06:25:34,718 --> 06:25:39,360 meaning to screen readers, search 8711 06:25:36,878 --> 06:25:42,240 engines, and any other kind of device or 8712 06:25:39,360 --> 06:25:44,080 robot that is reading our web page. So 8713 06:25:42,240 --> 06:25:46,718 to have the structure of our web page 8714 06:25:44,080 --> 06:25:48,160 recognized correctly in a screen reader, 8715 06:25:46,718 --> 06:25:51,040 we should actually replace some of our 8716 06:25:48,160 --> 06:25:53,600 divs with semantic elements. 8717 06:25:51,040 --> 06:25:56,558 So, for example, we can remove this div 8718 06:25:53,600 --> 06:25:59,120 and replace it with a header. So, it 8719 06:25:56,558 --> 06:26:02,878 works the same way as a div, except it's 8720 06:25:59,120 --> 06:26:07,000 for the robots. So, let's scroll down. 8721 06:26:02,878 --> 06:26:07,000 We can turn this into a header. 8722 06:26:07,040 --> 06:26:11,200 And then we can also scroll down to our 8723 06:26:08,798 --> 06:26:15,040 sidebar. And we're going to change this 8724 06:26:11,200 --> 06:26:18,080 to a nav element because 8725 06:26:15,040 --> 06:26:20,000 the sidebar on the real YouTube should 8726 06:26:18,080 --> 06:26:22,798 help us navigate through the website. 8727 06:26:20,000 --> 06:26:25,760 Another 8728 06:26:22,798 --> 06:26:28,718 semantic element we can use is called 8729 06:26:25,760 --> 06:26:31,760 main. So this should contain the main 8730 06:26:28,718 --> 06:26:34,160 contents of your website which for us is 8731 06:26:31,760 --> 06:26:36,798 this part. We're going to move 8732 06:26:34,160 --> 06:26:40,718 everything inside here 8733 06:26:36,798 --> 06:26:43,120 to the main element. So I think it's 8734 06:26:40,718 --> 06:26:46,480 this. 8735 06:26:43,120 --> 06:26:48,878 I might be missing. Okay. So move all of 8736 06:26:46,480 --> 06:26:52,638 that into main. 8737 06:26:48,878 --> 06:26:55,360 And let's scroll back up. 8738 06:26:52,638 --> 06:26:58,000 Now, inside main, we're going to have a 8739 06:26:55,360 --> 06:27:00,638 video grid, but we might also have other 8740 06:26:58,000 --> 06:27:03,920 things below the video grid. So, the 8741 06:27:00,638 --> 06:27:05,920 video grid is known as a section of our 8742 06:27:03,920 --> 06:27:08,240 main content. 8743 06:27:05,920 --> 06:27:11,040 Let's save that and scroll all the way 8744 06:27:08,240 --> 06:27:15,000 down to the end of our video grid and 8745 06:27:11,040 --> 06:27:15,000 remove this with section. 8746 06:27:15,440 --> 06:27:19,440 So, that's how semantic elements work. 8747 06:27:17,680 --> 06:27:21,200 They're just the same as divs except 8748 06:27:19,440 --> 06:27:23,520 they give a special meaning and 8749 06:27:21,200 --> 06:27:26,718 structure to our page for search engines 8750 06:27:23,520 --> 06:27:28,000 and screen readers. 8751 06:27:26,718 --> 06:27:31,280 Now, the final thing I want to show you 8752 06:27:28,000 --> 06:27:33,520 in this course is how to write comments. 8753 06:27:31,280 --> 06:27:35,760 So, comments are pieces of code that the 8754 06:27:33,520 --> 06:27:38,478 computer ignores, but you can read 8755 06:27:35,760 --> 06:27:40,240 yourself to remind you of information or 8756 06:27:38,478 --> 06:27:43,440 to tell yourself what's going on in the 8757 06:27:40,240 --> 06:27:46,798 code. So, for example, if we scroll up 8758 06:27:43,440 --> 06:27:48,718 to our header, maybe I forgot how we 8759 06:27:46,798 --> 06:27:51,120 created this tool tip. So, we can 8760 06:27:48,718 --> 06:27:53,600 actually add a comment in the code that 8761 06:27:51,120 --> 06:27:56,160 reminds us. So, let's add a comment 8762 06:27:53,600 --> 06:27:59,120 here. We're going to type less than 8763 06:27:56,160 --> 06:28:01,440 exclamation dash. And we're going to end 8764 06:27:59,120 --> 06:28:06,160 the comment with dash greater than like 8765 06:28:01,440 --> 06:28:08,478 this. So, this is a comment. If I save 8766 06:28:06,160 --> 06:28:10,558 the web page, you'll see that this text 8767 06:28:08,478 --> 06:28:12,240 appears nowhere on the web page. And 8768 06:28:10,558 --> 06:28:15,600 that's because the computer basically 8769 06:28:12,240 --> 06:28:19,520 ignores comments. 8770 06:28:15,600 --> 06:28:24,080 So we can add comments like put position 8771 06:28:19,520 --> 06:28:26,000 absolute inside position relative to 8772 06:28:24,080 --> 06:28:28,958 remind us that we need to put a position 8773 06:28:26,000 --> 06:28:32,798 absolute inside a position relative to 8774 06:28:28,958 --> 06:28:35,680 create this tool tip. In CSS we also 8775 06:28:32,798 --> 06:28:38,478 have comments. So for example if we go 8776 06:28:35,680 --> 06:28:42,000 here we can write a comment by writing 8777 06:28:38,478 --> 06:28:44,638 slash star and ending it with star 8778 06:28:42,000 --> 06:28:48,478 slash. Now everything in between here is 8779 06:28:44,638 --> 06:28:53,120 a comment. So we can say this style 8780 06:28:48,478 --> 06:28:55,680 below will be inherited. 8781 06:28:53,120 --> 06:28:57,920 So as you can see comments add extra 8782 06:28:55,680 --> 06:29:00,240 information into our code without 8783 06:28:57,920 --> 06:29:01,440 affecting our web page. So, it's a 8784 06:29:00,240 --> 06:29:03,840 really useful tool when you're working 8785 06:29:01,440 --> 06:29:05,680 on a team to document how your code 8786 06:29:03,840 --> 06:29:07,360 works. 8787 06:29:05,680 --> 06:29:09,440 And now for everything in this course, 8788 06:29:07,360 --> 06:29:11,840 if you ever forget, remember that you 8789 06:29:09,440 --> 06:29:14,240 can always Google it. For example, if I 8790 06:29:11,840 --> 06:29:17,520 go to Google, I can search things like 8791 06:29:14,240 --> 06:29:20,958 CSS rounded corners 8792 06:29:17,520 --> 06:29:23,360 and it will give us the border radius 8793 06:29:20,958 --> 06:29:26,400 property. 8794 06:29:23,360 --> 06:29:29,520 I can also search for something like CSS 8795 06:29:26,400 --> 06:29:31,600 text don't wrap 8796 06:29:29,520 --> 06:29:33,360 and it will give us the whites space 8797 06:29:31,600 --> 06:29:37,440 property 8798 06:29:33,360 --> 06:29:39,680 and the valley whites space no wrap. 8799 06:29:37,440 --> 06:29:41,280 So this is how you learn from here. You 8800 06:29:39,680 --> 06:29:43,440 take the techniques that we learned in 8801 06:29:41,280 --> 06:29:46,478 this course such as the nested layout 8802 06:29:43,440 --> 06:29:48,798 technique using grid flexbox and 8803 06:29:46,478 --> 06:29:50,798 position and then you try to recreate 8804 06:29:48,798 --> 06:29:53,040 things that you see on the internet. And 8805 06:29:50,798 --> 06:29:57,400 if you ever forget, you can Google and 8806 06:29:53,040 --> 06:29:57,400 get the exact code that you need. 8807 06:29:57,520 --> 06:30:00,958 So now that we learned all the major 8808 06:29:59,120 --> 06:30:03,200 skills that we need to build complex 8809 06:30:00,958 --> 06:30:05,200 websites like YouTube, here are some 8810 06:30:03,200 --> 06:30:07,040 challenge exercises that you can do to 8811 06:30:05,200 --> 06:30:10,040 create other popular websites on your 8812 06:30:07,040 --> 06:30:10,040 own. 8813 06:30:13,440 --> 06:30:16,958 Thanks so much for taking this course 8814 06:30:14,958 --> 06:30:19,120 with me. I hope you now realize that 8815 06:30:16,958 --> 06:30:21,520 creating websites is not as intimidating 8816 06:30:19,120 --> 06:30:24,240 as it seems. We just need to create each 8817 06:30:21,520 --> 06:30:26,958 part of the website step by step using 8818 06:30:24,240 --> 06:30:29,120 the major features of HTML and CSS that 8819 06:30:26,958 --> 06:30:31,600 we learned in this course. Now, where do 8820 06:30:29,120 --> 06:30:33,280 we go from here? As the next step, I 8821 06:30:31,600 --> 06:30:36,080 recommend learning the JavaScript 8822 06:30:33,280 --> 06:30:38,240 programming language. JavaScript is what 8823 06:30:36,080 --> 06:30:40,320 makes our web page interactive. For 8824 06:30:38,240 --> 06:30:42,478 example, if we click something, type 8825 06:30:40,320 --> 06:30:44,958 some text, or drag something onto the 8826 06:30:42,478 --> 06:30:47,360 page, JavaScript is what updates our 8827 06:30:44,958 --> 06:30:50,400 page. So, it's a natural progression 8828 06:30:47,360 --> 06:30:52,240 from HTML and CSS. Now, if you want to 8829 06:30:50,400 --> 06:30:54,320 learn JavaScript, I have a full 8830 06:30:52,240 --> 06:30:57,040 JavaScript course for absolute beginners 8831 06:30:54,320 --> 06:30:58,638 that you can find by clicking this link. 8832 06:30:57,040 --> 06:31:01,120 Again, thanks so much for watching. My 8833 06:30:58,638 --> 06:31:02,718 name is Simon from supersimple.dev. I 8834 06:31:01,120 --> 06:31:04,638 want to make a tech career possible for 8835 06:31:02,718 --> 06:31:06,400 anyone. If you have any comments, 8836 06:31:04,638 --> 06:31:08,638 questions, or feedback, please leave 8837 06:31:06,400 --> 06:31:10,080 them down in the comment section below. 8838 06:31:08,638 --> 06:31:12,320 If you want to support this channel and 8839 06:31:10,080 --> 06:31:14,080 you want more courses like this, please 8840 06:31:12,320 --> 06:31:17,440 click the subscribe button. Thanks so 8841 06:31:14,080 --> 06:31:17,440 much and I'll see you in the next 623999

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