[ { "text": "[MUSIC]", "start": 0.0, "duration": 17.0 }, { "text": "BRIAN YU: All right, welcome,\neveryone, to Web Programming", "start": 17.31, "duration": 2.42 }, { "text": "with Python and JavaScript.", "start": 19.73, "duration": 1.38 }, { "text": "My name is Brian Yu.", "start": 21.11, "duration": 1.17 }, { "text": "And in this course, we'll dive\ninto the design and implementation", "start": 22.28, "duration": 2.75 }, { "text": "of web applications.", "start": 25.03, "duration": 1.48 }, { "text": "In lectures, we'll have an\nopportunity to discuss and explore", "start": 26.51, "duration": 2.94 }, { "text": "many of the ideas and\ntools and languages", "start": 29.45, "duration": 2.25 }, { "text": "that are central to\nmodern web programming.", "start": 31.7, "duration": 2.16 }, { "text": "And through hands-on projects, you'll\nhave an opportunity to take those ideas", "start": 33.86, "duration": 3.84 }, { "text": "and put them into practice, designing\nmultiple web applications of your own,", "start": 37.7, "duration": 3.57 }, { "text": "culminating in a final\nproject of your own choosing.", "start": 41.27, "duration": 3.03 }, { "text": "Throughout the term, we'll\ncover a number of topics", "start": 44.3, "duration": 2.13 }, { "text": "in this world of web\nprogramming, beginning", "start": 46.43, "duration": 2.31 }, { "text": "with HTML5 and CSS3,\ntwo of the languages", "start": 48.74, "duration": 3.54 }, { "text": "that are central to the\nunderstanding of web pages.", "start": 52.28, "duration": 2.79 }, { "text": "HTML is a language we'll use to\ndescribe the structure of a web page.", "start": 55.07, "duration": 3.78 }, { "text": "And CSS is the language\nwe'll use to describe", "start": 58.85, "duration": 2.31 }, { "text": "the style of a web page,\nthe colors and the fonts", "start": 61.16, "duration": 2.61 }, { "text": "and the layouts and the spacing\nthat make the web page look", "start": 63.77, "duration": 2.7 }, { "text": "exactly the way we want it to look.", "start": 66.47, "duration": 2.4 }, { "text": "After that, we'll turn\nour attention to Git,", "start": 68.87, "duration": 2.34 }, { "text": "a tool not specific to\nweb programming per se,", "start": 71.21, "duration": 2.64 }, { "text": "but that we can use in order to\nversion control our programs,", "start": 73.85, "duration": 3.27 }, { "text": "to keep track of the different\nchanges we make to our web programs,", "start": 77.12, "duration": 2.91 }, { "text": "and to allow us to be able to work\non various different parts of the web", "start": 80.03, "duration": 3.0 }, { "text": "application at the same time before\nmerging those pieces back together.", "start": 83.03, "duration": 4.05 }, { "text": "After that, we'll take a look at\nPython, one of the first main languages", "start": 87.08, "duration": 3.0 }, { "text": "that we're going to be\nexploring in the course, which", "start": 90.08, "duration": 2.2 }, { "text": "is the language that we are going to use\nin order to build our web applications.", "start": 92.28, "duration": 3.5 }, { "text": "Specifically, we'll use Python\nusing a framework called Django.", "start": 95.78, "duration": 3.66 }, { "text": "Django is a web programming framework\nwritten in the Python programming", "start": 99.44, "duration": 3.15 }, { "text": "language that we're going to use to make\nit easy to design and develop our web", "start": 102.59, "duration": 4.2 }, { "text": "applications Django in particular makes\nit easy to design web applications", "start": 106.79, "duration": 4.23 }, { "text": "that interact with data.", "start": 111.02, "duration": 1.54 }, { "text": "So after that, we'll turn our\nattention to SQL, a language", "start": 112.56, "duration": 2.84 }, { "text": "that we can use to interact with\ndatabases, in particular looking", "start": 115.4, "duration": 3.39 }, { "text": "at how Django allows us to use models\nand migrations to interact with data", "start": 118.79, "duration": 4.11 }, { "text": "and allow users to interact\nwith data all the more easily.", "start": 122.9, "duration": 3.94 }, { "text": "Next, we'll turn our attention to\nthe second of the main programming", "start": 126.84, "duration": 2.84 }, { "text": "languages that we'll be exploring\nin this class, JavaScript,", "start": 129.68, "duration": 3.15 }, { "text": "and looking at how we can use\nJavaScript to run in users' web browsers", "start": 132.83, "duration": 3.48 }, { "text": "to make web pages just a\nlittle bit more interactive.", "start": 136.31, "duration": 2.94 }, { "text": "In particular, we'll use JavaScript\nin the context of user interfaces,", "start": 139.25, "duration": 3.66 }, { "text": "looking at modern user\ninterfaces and exploring", "start": 142.91, "duration": 2.31 }, { "text": "how it is that those\ninterfaces work and how", "start": 145.22, "duration": 2.46 }, { "text": "we can develop those user interfaces\nwith a combination of Python", "start": 147.68, "duration": 3.6 }, { "text": "and JavaScript.", "start": 151.28, "duration": 1.65 }, { "text": "Next, we'll turn our\nattention to testing", "start": 152.93, "duration": 2.1 }, { "text": "and CI/CD, or Continuous\nIntegration and Continuous Delivery,", "start": 155.03, "duration": 4.65 }, { "text": "which are tools that we can use and\nsoftware best practices to make sure", "start": 159.68, "duration": 3.39 }, { "text": "that we're able to design and\ndevelop code more efficiently.", "start": 163.07, "duration": 3.12 }, { "text": "And testing in particular makes sure\nthat as we make changes to our code,", "start": 166.19, "duration": 3.76 }, { "text": "we're not breaking existing\nparts of our web application", "start": 169.95, "duration": 2.64 }, { "text": "by making sure that we\nhave a whole suite of tests", "start": 172.59, "duration": 2.09 }, { "text": "that we can use to ensure that\nour web application is always", "start": 174.68, "duration": 3.0 }, { "text": "behaving as it should.", "start": 177.68, "duration": 1.95 }, { "text": "And finally, we'll turn our\nattention to scalability and security", "start": 179.63, "duration": 3.47 }, { "text": "on the internet, thinking\nabout what happens", "start": 183.1, "duration": 1.84 }, { "text": "as our web application grows larger.", "start": 184.94, "duration": 1.8 }, { "text": "As more and more different users\nstart to use our web application,", "start": 186.74, "duration": 3.49 }, { "text": "how do we load balance\nbetween those people?", "start": 190.23, "duration": 1.85 }, { "text": "And what do we need to change about\nour database to make sure lots of users", "start": 192.08, "duration": 3.42 }, { "text": "are able to connect to our web\napplication at the same time?", "start": 195.5, "duration": 3.02 }, { "text": "Moreover, we'll look at\nthe security implications", "start": 198.52, "duration": 2.05 }, { "text": "behind designing our web applications.", "start": 200.57, "duration": 1.89 }, { "text": "What might an adversary\ndo if we're not careful?", "start": 202.46, "duration": 2.68 }, { "text": "And how should we proactively\nbe designing our web application", "start": 205.14, "duration": 3.02 }, { "text": "to make sure that it's secure?", "start": 208.16, "duration": 2.4 }, { "text": "But today, we begin our\nconversation with HTML and CSS,", "start": 210.56, "duration": 3.69 }, { "text": "two of the languages that are\nfoundational to understanding web pages", "start": 214.25, "duration": 3.33 }, { "text": "and how web browsers are able\nto display those web pages.", "start": 217.58, "duration": 3.42 }, { "text": "And we'll start with each HTML,\nor HyperText Markup Language,", "start": 221.0, "duration": 3.84 }, { "text": "which is a language that we can use to\ndescribe the structure of the web page,", "start": 224.84, "duration": 3.48 }, { "text": "all of the buttons and the text and the\nforms and other parts of the web page", "start": 228.32, "duration": 3.9 }, { "text": "that the user ultimately\nsees and interacts with.", "start": 232.22, "duration": 3.51 }, { "text": "Our very first HTML page is going to\nlook a little something like this.", "start": 235.73, "duration": 3.51 }, { "text": "It's going to be text-based code that\nwe write that a web browser, like Safari", "start": 239.24, "duration": 3.87 }, { "text": "or Chrome or Firefox, is then able\nto look at, parse, understand,", "start": 243.11, "duration": 4.11 }, { "text": "and display to the user.", "start": 247.22, "duration": 2.11 }, { "text": "So let's take a look at\nthis page one line at a time", "start": 249.33, "duration": 2.24 }, { "text": "and get an understanding\nfor how it works.", "start": 251.57, "duration": 2.1 }, { "text": "Even if you don't quite understand\nall the nuances of the syntax,", "start": 253.67, "duration": 2.94 }, { "text": "there are probably a couple of\nthings that stand out to you.", "start": 256.61, "duration": 2.58 }, { "text": "You might notice the word\ntitle, which probably", "start": 259.19, "duration": 2.16 }, { "text": "reflects the title of the web page,\nfor example, which in this case", "start": 261.35, "duration": 3.3 }, { "text": "appears to be the word hello.", "start": 264.65, "duration": 1.89 }, { "text": "And then down further below, we see\nthat we have the body of the web page", "start": 266.54, "duration": 3.57 }, { "text": "that seems to contain\nthe words hello world.", "start": 270.11, "duration": 2.95 }, { "text": "So what is this web page\nactually going to look like?", "start": 273.06, "duration": 2.39 }, { "text": "Well, let's take a look at it.", "start": 275.45, "duration": 2.11 }, { "text": "We'll go ahead and\nopen up a text editor.", "start": 277.56, "duration": 1.85 }, { "text": "You can use any text editor you want.", "start": 279.41, "duration": 1.73 }, { "text": "But for this course, I'm going to\nuse Microsoft's Visual Studio Code.", "start": 281.14, "duration": 3.46 }, { "text": "And I'm going to open up a new file\nthat I'm just going to call hello.html.", "start": 284.6, "duration": 6.09 }, { "text": "Inside of hello.html I'm going to\nwrite the same HTML that we just", "start": 290.69, "duration": 4.02 }, { "text": "saw a moment ago.", "start": 294.71, "duration": 0.9 }, { "text": "And we'll explain each of\nthese lines in due time.", "start": 295.61, "duration": 2.73 }, { "text": "But recall that we had a title of the\npage that said something like hello", "start": 298.34, "duration": 5.7 }, { "text": "and then a body of the page where\nwe said something like hello world,", "start": 304.04, "duration": 4.02 }, { "text": "for example.", "start": 308.06, "duration": 1.51 }, { "text": "So this is our very first HTML page.", "start": 309.57, "duration": 2.59 }, { "text": "And if I go ahead and open that HTML\npage as my opening hello.html HTML,", "start": 312.16, "duration": 4.21 }, { "text": "for example, inside of a web browser,\nwhat I'll see is something like this.", "start": 316.37, "duration": 4.62 }, { "text": "In the body of the page, I\nsee the words hello world.", "start": 320.99, "duration": 3.34 }, { "text": "And if you notice up here at\nthe top of my web browser,", "start": 324.33, "duration": 2.69 }, { "text": "I see the title bar, where I have the\ntitle for this page, which in this case", "start": 327.02, "duration": 4.17 }, { "text": "is just the word hello.", "start": 331.19, "duration": 1.92 }, { "text": "So this is our very first\nweb program that we've", "start": 333.11, "duration": 2.91 }, { "text": "been able to develop just using HTML.", "start": 336.02, "duration": 2.25 }, { "text": "And now let's explore in more detail\nhow exactly this program works.", "start": 338.27, "duration": 4.59 }, { "text": "So here again was the web page\nthat we were just looking at.", "start": 342.86, "duration": 3.15 }, { "text": "And this very first\nline here, DOCTYPE html", "start": 346.01, "duration": 3.42 }, { "text": "is what we might call\na DOCTYPE declaration.", "start": 349.43, "duration": 2.91 }, { "text": "It's a way of telling the web\nbrowser what version of HTML", "start": 352.34, "duration": 3.57 }, { "text": "we're using in this particular\nweb page, because depending", "start": 355.91, "duration": 3.09 }, { "text": "on the version of HTML,\nthe web browser might", "start": 359.0, "duration": 2.2 }, { "text": "want to display different\ninformation or it might need to parse", "start": 361.2, "duration": 2.63 }, { "text": "the page a little bit differently.", "start": 363.83, "duration": 1.83 }, { "text": "Each version of HTML has\nhad a slightly different way", "start": 365.66, "duration": 2.76 }, { "text": "of indicating that version.", "start": 368.42, "duration": 1.47 }, { "text": "But this line here,\nDOCTYPE html is our way", "start": 369.89, "duration": 3.15 }, { "text": "of saying that this HTML\npage is written using", "start": 373.04, "duration": 2.85 }, { "text": "HTML5, the latest version of HTML.", "start": 375.89, "duration": 3.87 }, { "text": "After that our HTML page is structured\nas a series of nested HTML elements,", "start": 379.76, "duration": 6.15 }, { "text": "where an HTML element describes\nsomething on the page.", "start": 385.91, "duration": 3.46 }, { "text": "And we might have elements that\nare inside of other elements.", "start": 389.37, "duration": 3.71 }, { "text": "Each of those elements\nis indicated by what", "start": 393.08, "duration": 2.22 }, { "text": "we're going to call an HTML tag,\nenclosed using those angled brackets.", "start": 395.3, "duration": 4.23 }, { "text": "And right here, we'll see the\nbeginning of the HTML tag, which", "start": 399.53, "duration": 3.81 }, { "text": "means that this is the beginning\nof the HTML content of our page.", "start": 403.34, "duration": 4.32 }, { "text": "Down below this slash\nHTML means that this", "start": 407.66, "duration": 3.51 }, { "text": "is the end of the HTML\ncontent of the page.", "start": 411.17, "duration": 2.88 }, { "text": "And in between is the actual\nHTML content of the page,", "start": 414.05, "duration": 3.52 }, { "text": "which might include other HTML elements.", "start": 417.57, "duration": 3.36 }, { "text": "You might also notice\nthat in this HTML tag", "start": 420.93, "duration": 2.67 }, { "text": "we've specified what we're\ngoing to call an HTML attribute,", "start": 423.6, "duration": 3.39 }, { "text": "some additional information that\nwe're giving about this tag.", "start": 426.99, "duration": 3.45 }, { "text": "In particular, we're giving it\na lang, or language, attribute,", "start": 430.44, "duration": 3.81 }, { "text": "which is equal to en, or English.", "start": 434.25, "duration": 3.3 }, { "text": "This just tells the web browser or\nanyone looking at the HTML of this page", "start": 437.55, "duration": 3.87 }, { "text": "that this page is written in a language,\nand the language it's written in", "start": 441.42, "duration": 3.1 }, { "text": "is English.", "start": 444.52, "duration": 1.07 }, { "text": "And this is helpful for\nsearch engines, for example.", "start": 445.59, "duration": 2.22 }, { "text": "When they're looking through\nmany different web pages trying", "start": 447.81, "duration": 2.19 }, { "text": "to figure out what language\neach web page is in we", "start": 450.0, "duration": 2.22 }, { "text": "can just tell the search engine or\nanyone else who's looking at the page", "start": 452.22, "duration": 3.15 }, { "text": "that this page is written in English.", "start": 455.37, "duration": 3.19 }, { "text": "Now, inside of the\nHTML body of the page,", "start": 458.56, "duration": 2.56 }, { "text": "we have a number of\ndifferent elements that", "start": 461.12, "duration": 1.91 }, { "text": "are going to describe\nwhat we want on this page,", "start": 463.03, "duration": 2.82 }, { "text": "starting with the head section of\nthe web page, which describes stuff", "start": 465.85, "duration": 3.99 }, { "text": "not in the main body of the web\npage, the part of the web page", "start": 469.84, "duration": 2.61 }, { "text": "the user sees, but other\ninformation about the web", "start": 472.45, "duration": 2.88 }, { "text": "page that's going to be helpful or\nuseful for web browsers to know about.", "start": 475.33, "duration": 3.79 }, { "text": "For example, one important thing\nthat a web browser needs to know", "start": 479.12, "duration": 2.9 }, { "text": "is, what is the title of the web page?", "start": 482.02, "duration": 3.03 }, { "text": "And here, we see a title tag,\nagain, indicated by the word title", "start": 485.05, "duration": 3.81 }, { "text": "in those angled brackets, followed\nby the end of the title tag,", "start": 488.86, "duration": 3.6 }, { "text": "indicated by a slash before the title.", "start": 492.46, "duration": 2.67 }, { "text": "And in between the two title\ntags is the word hello,", "start": 495.13, "duration": 3.15 }, { "text": "which means the title of this\npage should be the word hello.", "start": 498.28, "duration": 3.74 }, { "text": "And that's all the information\nwe'll have in the head of the page.", "start": 502.02, "duration": 2.91 }, { "text": "We'll add more information\nthere later, but for now", "start": 504.93, "duration": 2.12 }, { "text": "all the web page needs to\nknow is that it has a title", "start": 507.05, "duration": 2.86 }, { "text": "and the title is the word hello.", "start": 509.91, "duration": 2.53 }, { "text": "Next up comes the body of the page,\nagain, indicated by a body tag", "start": 512.44, "duration": 3.99 }, { "text": "and that ends with a\ntag with slash body,", "start": 516.43, "duration": 2.61 }, { "text": "meaning this is the end\nof the body of the page.", "start": 519.04, "duration": 2.43 }, { "text": "And the body of the page, again, is\njust the visible part of the page", "start": 521.47, "duration": 2.91 }, { "text": "that the user can see.", "start": 524.38, "duration": 1.56 }, { "text": "And what do we want inside\nthe body of the page?", "start": 525.94, "duration": 2.43 }, { "text": "For now, we just want\nthe text, hello world.", "start": 528.37, "duration": 2.47 }, { "text": "And that's the information\nthat's going to be displayed", "start": 530.84, "duration": 2.3 }, { "text": "when someone visits this web page.", "start": 533.14, "duration": 2.38 }, { "text": "And so that's all there\nreally is to this HTML page.", "start": 535.52, "duration": 2.65 }, { "text": "We specified in the header that there's\na title of the page called hello.", "start": 538.17, "duration": 3.61 }, { "text": "And inside the body, we're saying the\npage should say the words hello world.", "start": 541.78, "duration": 4.54 }, { "text": "And if you want to visually\nthink about the way", "start": 546.32, "duration": 2.3 }, { "text": "that all these HTML\nelements are structured,", "start": 548.62, "duration": 2.46 }, { "text": "it can sometimes be helpful\nto think about an HTML page", "start": 551.08, "duration": 2.88 }, { "text": "in terms of a tree-like\nstructure that we", "start": 553.96, "duration": 2.28 }, { "text": "call the document object model, or DOM.", "start": 556.24, "duration": 3.12 }, { "text": "And so, here, for example, is\nwhat the DOM for this web page", "start": 559.36, "duration": 3.69 }, { "text": "might actually look like.", "start": 563.05, "duration": 1.29 }, { "text": "Here on the left is the HTML content\nthat we just saw a moment ago.", "start": 564.34, "duration": 3.39 }, { "text": "And over here on the right is the\nDOM, the document object model,", "start": 567.73, "duration": 3.84 }, { "text": "the tree-like structure that describes\nhow all of these HTML elements", "start": 571.57, "duration": 4.32 }, { "text": "are related to each other.", "start": 575.89, "duration": 1.6 }, { "text": "So we start up here\nwith the HTML element.", "start": 577.49, "duration": 2.48 }, { "text": "And this parent element, so to\nspeak, has two child elements", "start": 579.97, "duration": 4.05 }, { "text": "within it, a head element\nand a body element.", "start": 584.02, "duration": 3.06 }, { "text": "As we can see here,\nwe're inside of HTML.", "start": 587.08, "duration": 2.64 }, { "text": "We have a head section\nand a body section.", "start": 589.72, "duration": 2.43 }, { "text": "And the indentation here that\nwe're including in the HTML text,", "start": 592.15, "duration": 3.54 }, { "text": "it's not strictly necessary.", "start": 595.69, "duration": 1.53 }, { "text": "The web browser doesn't care\nwhat the indentation is.", "start": 597.22, "duration": 2.64 }, { "text": "But it can be helpful for someone\nwho's reading the page just", "start": 599.86, "duration": 2.82 }, { "text": "to see the indentation to understand\nvisually that the head is inside", "start": 602.68, "duration": 3.9 }, { "text": "of the HTML element and the body\nis inside of the HTML element too.", "start": 606.58, "duration": 4.86 }, { "text": "So inside of the head element,\nwe have a title element.", "start": 611.44, "duration": 2.58 }, { "text": "And inside of the title element\nis just the text, the word hello.", "start": 614.02, "duration": 3.78 }, { "text": "And likewise, inside\nof the body element,", "start": 617.8, "duration": 2.14 }, { "text": "we also have some text,\nthe text hello world.", "start": 619.94, "duration": 3.11 }, { "text": "So thinking about HTML and HTML\ndocuments in terms of this structure", "start": 623.05, "duration": 4.26 }, { "text": "can be helpful for understanding which\nHTML elements are inside of which", "start": 627.31, "duration": 4.05 }, { "text": "other HTML elements.", "start": 631.36, "duration": 1.53 }, { "text": "And that's going to make it easier\nfor us to reason about these pages", "start": 632.89, "duration": 3.0 }, { "text": "later on.", "start": 635.89, "duration": 0.81 }, { "text": "And especially as we later transition\ninto the world of JavaScript,", "start": 636.7, "duration": 3.27 }, { "text": "JavaScript is going to make\nit all the more powerful", "start": 639.97, "duration": 2.37 }, { "text": "and give us the ability to actually\nmodify parts of this DOM as well.", "start": 642.34, "duration": 3.78 }, { "text": "But we'll certainly get\nto that in due time.", "start": 646.12, "duration": 2.92 }, { "text": "So now, let's take a look at some of\nthe other common HTML tags and HTML", "start": 649.04, "duration": 4.28 }, { "text": "elements that we might be\ninteracting with in our web page.", "start": 653.32, "duration": 3.33 }, { "text": "And we'll start by thinking about\nHTML headings, so big banners", "start": 656.65, "duration": 3.81 }, { "text": "at the top of the page, for\nexample, some headline that", "start": 660.46, "duration": 2.34 }, { "text": "describes what a page is about.", "start": 662.8, "duration": 2.5 }, { "text": "So I'll go ahead into my text\neditor and create a new file", "start": 665.3, "duration": 3.05 }, { "text": "that I'll call headings.html.", "start": 668.35, "duration": 3.19 }, { "text": "And the structure of this page is\ngoing to be pretty similar to the pages", "start": 671.54, "duration": 3.05 }, { "text": "that we've seen before already.", "start": 674.59, "duration": 1.63 }, { "text": "So I'm going to start by just using the\nhello.html text and paste it in here.", "start": 676.22, "duration": 5.17 }, { "text": "I'll change the title of the page.", "start": 681.39, "duration": 1.42 }, { "text": "Instead of hello, we'll go\nahead and call it headings.", "start": 682.81, "duration": 3.79 }, { "text": "But inside the body of this page now, I\nwant something a little bit different.", "start": 686.6, "duration": 4.55 }, { "text": "I'm going to, inside the body\nthe page, use an h1 element", "start": 691.15, "duration": 3.8 }, { "text": "and say this is a heading, for example.", "start": 694.95, "duration": 5.2 }, { "text": "So h1 is a tag that I can use to create\na large heading at the top of my page,", "start": 700.15, "duration": 4.55 }, { "text": "like for the title of\nthe page, for example.", "start": 704.7, "duration": 2.89 }, { "text": "So if I open up headings.html.", "start": 707.59, "duration": 3.62 }, { "text": "I might see something\nthat looks like this,", "start": 711.21, "duration": 2.51 }, { "text": "a big heading at the top of my\npage that says, this is a heading.", "start": 713.72, "duration": 3.61 }, { "text": "h1, where the h stands for heading\nand the 1 stands for the largest", "start": 717.33, "duration": 4.23 }, { "text": "possible heading.", "start": 721.56, "duration": 0.96 }, { "text": "And in fact, HTML gives us\na number of different tags", "start": 722.52, "duration": 2.67 }, { "text": "that we can use in order to\ncreate headings of various sizes.", "start": 725.19, "duration": 3.78 }, { "text": "So, for example, I could also\nsay h2 inside of which I say,", "start": 728.97, "duration": 4.92 }, { "text": "this is a smaller heading.", "start": 733.89, "duration": 2.74 }, { "text": "If h1 is the largest heading, h2\nis the second largest heading.", "start": 736.63, "duration": 4.31 }, { "text": "So if I load this page, for example,\nI now see the h1 at the very top.", "start": 740.94, "duration": 3.78 }, { "text": "This is the big heading.", "start": 744.72, "duration": 1.47 }, { "text": "And then beneath that, I see this\nis a smaller heading, the h2.", "start": 746.19, "duration": 3.96 }, { "text": "And it turns out there's\nalso h3, h4, h5, all the way", "start": 750.15, "duration": 3.33 }, { "text": "down to h6, which is\nthe smallest heading,", "start": 753.48, "duration": 4.54 }, { "text": "such that if I load this page now,\nI have a big heading, a smaller one,", "start": 758.02, "duration": 3.74 }, { "text": "and then here's the smallest.", "start": 761.76, "duration": 1.5 }, { "text": "So we can often use\nthese h1, h2, h3 tags", "start": 763.26, "duration": 3.36 }, { "text": "just for visually organizing\ntext inside of a page.", "start": 766.62, "duration": 2.61 }, { "text": "If I want the title of\nthe page, but also I", "start": 769.23, "duration": 3.12 }, { "text": "want titles for each of the various\ndifferent sections and subsections", "start": 772.35, "duration": 3.78 }, { "text": "that might be contained\nwithin that page as well.", "start": 776.13, "duration": 4.21 }, { "text": "So those are headings.", "start": 780.34, "duration": 1.04 }, { "text": "And now, let's also take a\nlook at some other elements", "start": 781.38, "duration": 1.98 }, { "text": "that we might want to add.", "start": 783.36, "duration": 1.08 }, { "text": "On web pages, we see not just\ntitles and not just text,", "start": 784.44, "duration": 2.79 }, { "text": "but we might also see\nlists, for example.", "start": 787.23, "duration": 2.31 }, { "text": "Like if you've ever used a to\ndo list program on a web page,", "start": 789.54, "duration": 2.8 }, { "text": "for example, you might see a list\nof things that you need to do", "start": 792.34, "duration": 2.63 }, { "text": "or other web pages might\ndisplay lists of information.", "start": 794.97, "duration": 3.3 }, { "text": "And it turns out that HTML\nhas two basic types of lists.", "start": 798.27, "duration": 3.72 }, { "text": "We have ordered lists for things\nthat are in a particular order,", "start": 801.99, "duration": 3.03 }, { "text": "like item number 1, item\nnumber 2, item number 3.", "start": 805.02, "duration": 3.19 }, { "text": "And we have unordered lists for lists\nthat don't have any particular order.", "start": 808.21, "duration": 3.39 }, { "text": "So just bullet point, bullet\npoint, bullet point, for example.", "start": 811.6, "duration": 2.93 }, { "text": "And both are quite easy to use.", "start": 814.53, "duration": 2.37 }, { "text": "I'll go ahead and create a new file.", "start": 816.9, "duration": 2.43 }, { "text": "And we'll call this lists.html.", "start": 819.33, "duration": 2.94 }, { "text": "And again, in list.html, I'll copy\nthe same structure from hello.html.", "start": 822.27, "duration": 4.51 }, { "text": "We're again going to have DOCTYPE html\njust to indicate the version of HTML.", "start": 826.78, "duration": 4.46 }, { "text": "Most of the heading is the same.", "start": 831.24, "duration": 1.35 }, { "text": "I'm just going to change the\ntitle from Hello to Lists.", "start": 832.59, "duration": 3.3 }, { "text": "And then we're going to\nreplace the body of this page", "start": 835.89, "duration": 2.28 }, { "text": "to show some different information here.", "start": 838.17, "duration": 3.03 }, { "text": "So let me first show what an\nordered list might look like,", "start": 841.2, "duration": 3.81 }, { "text": "something that has numbers, 1, 2, 3.", "start": 845.01, "duration": 2.4 }, { "text": "An ordered as an HTML tag is\njust ol, ol for ordered list.", "start": 847.41, "duration": 5.79 }, { "text": "So I can add a tag that says ol.", "start": 853.2, "duration": 3.06 }, { "text": "And now inside of my ol element,\nmy ordered list element,", "start": 856.26, "duration": 3.72 }, { "text": "I need a new element\nfor every list item.", "start": 859.98, "duration": 3.27 }, { "text": "List item we're going to\nabbreviate to just li.", "start": 863.25, "duration": 2.91 }, { "text": "So the li tag in HTML\nis what we're going", "start": 866.16, "duration": 2.49 }, { "text": "to use to designate an item\ninside of an HTML list.", "start": 868.65, "duration": 3.9 }, { "text": "So here, for example, I could\nsay li and then first item.", "start": 872.55, "duration": 4.53 }, { "text": "Then I could do the same\nthing, li second item", "start": 877.08, "duration": 3.55 }, { "text": "and then again li third item.", "start": 880.63, "duration": 3.32 }, { "text": "So what I have here are some\nelements and then elements", "start": 883.95, "duration": 2.36 }, { "text": "nested within other elements.", "start": 886.31, "duration": 2.04 }, { "text": "I have an ordered list\nelement inside of which", "start": 888.35, "duration": 2.37 }, { "text": "are three other HTML elements,\nthree list items that", "start": 890.72, "duration": 3.45 }, { "text": "are each indicating each of the\nindividual items that are inside", "start": 894.17, "duration": 4.08 }, { "text": "of my HTML list.", "start": 898.25, "duration": 2.45 }, { "text": "I can now open this up\nby opening lists.html.", "start": 900.7, "duration": 4.65 }, { "text": "And this is what I see.", "start": 905.35, "duration": 1.44 }, { "text": "I see an ordered list,\nwhere I have item number 1,", "start": 906.79, "duration": 2.49 }, { "text": "first item, second item, third item.", "start": 909.28, "duration": 2.7 }, { "text": "Note that I didn't actually\nneed to in the HTML anywhere", "start": 911.98, "duration": 3.06 }, { "text": "specify the number 1, the\nnumber 2, and the number 3.", "start": 915.04, "duration": 2.97 }, { "text": "When my web browser reads\nthis should be an order list,", "start": 918.01, "duration": 2.7 }, { "text": "my web browser, Chrome in this case,\njust adds those numbers in for me", "start": 920.71, "duration": 3.51 }, { "text": "because it knows what\nan ordered list means", "start": 924.22, "duration": 2.16 }, { "text": "and it knows how to take the HTML that\nI've written and display it in the way", "start": 926.38, "duration": 3.96 }, { "text": "that I intend to the user.", "start": 930.34, "duration": 3.24 }, { "text": "Now, in addition to ordered list\nthat all have numbers, 1, 2, 3,", "start": 933.58, "duration": 3.81 }, { "text": "we also have unordered\nlists that are just bullet", "start": 937.39, "duration": 2.28 }, { "text": "points, bullet points of information.", "start": 939.67, "duration": 2.01 }, { "text": "So I could, up above, add some\nmore content to this HTML page.", "start": 941.68, "duration": 4.32 }, { "text": "I can say here is an unordered list.", "start": 946.0, "duration": 3.82 }, { "text": "And just as an ordered\nlist we represented", "start": 949.82, "duration": 2.36 }, { "text": "using the ol tag in HTML, ol\nstanding for ordered list,", "start": 952.18, "duration": 4.8 }, { "text": "likewise we can use the\nul tag in HTML to create", "start": 956.98, "duration": 4.11 }, { "text": "an unordered list, u for unordered.", "start": 961.09, "duration": 3.24 }, { "text": "So here, we're going to add a ul tag.", "start": 964.33, "duration": 1.79 }, { "text": "And again, my text editor\nhere is automatically", "start": 966.12, "duration": 1.96 }, { "text": "adding the closing tag\nhere, this slash ul,", "start": 968.08, "duration": 2.52 }, { "text": "meaning the end of the unordered list.", "start": 970.6, "duration": 1.89 }, { "text": "And many text editors will do this\nnow just so you, the programmer,", "start": 972.49, "duration": 2.97 }, { "text": "don't forget to add that.", "start": 975.46, "duration": 2.28 }, { "text": "And now inside of this\nunordered list, we're", "start": 977.74, "duration": 1.98 }, { "text": "again going to have some list items.", "start": 979.72, "duration": 1.98 }, { "text": "Also, using the li\ntag, here is one item.", "start": 981.7, "duration": 3.55 }, { "text": "And here is another item.", "start": 985.25, "duration": 2.34 }, { "text": "And here is yet another item.", "start": 987.59, "duration": 4.16 }, { "text": "If I go ahead and refresh the\npage now, I'm still on list.html,", "start": 991.75, "duration": 3.39 }, { "text": "I now see that on top\nof my ordered list,", "start": 995.14, "duration": 2.25 }, { "text": "I have an unordered list, where\neach item instead of being numbered", "start": 997.39, "duration": 3.06 }, { "text": "1, 2, 3, is instead labeled with just\nbullet point, bullet point, bullet", "start": 1000.45, "duration": 3.99 }, { "text": "point, where each of these bullet\npoints and each of these numbered items", "start": 1004.44, "duration": 3.36 }, { "text": "is a list item element, or an li.", "start": 1007.8, "duration": 3.65 }, { "text": "So hopefully now we can\nsee that as we start", "start": 1011.45, "duration": 1.84 }, { "text": "to explore these various different\nHTML tags and nesting HTML tags inside", "start": 1013.29, "duration": 4.86 }, { "text": "of one another, we're able to\ncreate more and more interesting", "start": 1018.15, "duration": 3.42 }, { "text": "web pages as a result.", "start": 1021.57, "duration": 2.38 }, { "text": "So let's explore now what\nother types of web pages", "start": 1023.95, "duration": 2.64 }, { "text": "we can create using other\ntypes of HTML elements.", "start": 1026.59, "duration": 3.47 }, { "text": "In addition to lists, one\nthing you might imagine", "start": 1030.06, "duration": 2.37 }, { "text": "is that one of the\nimportant things on the web", "start": 1032.43, "duration": 1.92 }, { "text": "is not just displaying text, but\nalso displaying other types of media,", "start": 1034.35, "duration": 3.43 }, { "text": "like images, for example.", "start": 1037.78, "duration": 1.47 }, { "text": "So how might we go about doing that?", "start": 1039.25, "duration": 2.53 }, { "text": "Well, I can, for example--", "start": 1041.78, "duration": 1.52 }, { "text": "let's go back into my text editor.", "start": 1043.3, "duration": 2.94 }, { "text": "Let me create a new file\nthat I'm going to call", "start": 1046.24, "duration": 2.12 }, { "text": "image.html, which is going to contain\nsome code for displaying some images.", "start": 1048.36, "duration": 5.35 }, { "text": "I'll go ahead and go into hello.html\nand copy this text into the page,", "start": 1053.71, "duration": 4.24 }, { "text": "again, change the title to Image.", "start": 1057.95, "duration": 2.1 }, { "text": "And now, inside of the body, I'm\ngoing to add a new tag called image.", "start": 1060.05, "duration": 5.29 }, { "text": "And the image tag has a\ncouple of required attributes.", "start": 1065.34, "duration": 2.97 }, { "text": "Remember that attributes are what\nwe saw before things, like adding", "start": 1068.31, "duration": 2.8 }, { "text": "a lang equals en to the top of my\npage to indicate that this web page is", "start": 1071.11, "duration": 4.89 }, { "text": "written in English, for example.", "start": 1076.0, "duration": 2.34 }, { "text": "And the image tag has a couple of\nrequired attributes that I need to add.", "start": 1078.34, "duration": 4.59 }, { "text": "In particular, when I\ndisplay an image on the page,", "start": 1082.93, "duration": 2.79 }, { "text": "I need to specify what image I\nactually want displayed, for example.", "start": 1085.72, "duration": 4.19 }, { "text": "So I might specify image\nsrc, short for source,", "start": 1089.91, "duration": 4.8 }, { "text": "is going to be equal to what image do I\nactually want to display on this page.", "start": 1094.71, "duration": 5.2 }, { "text": "And it just so happens that inside\nof my folder where I have image.html,", "start": 1099.91, "duration": 3.87 }, { "text": "I have an image called cat.jpeg.", "start": 1103.78, "duration": 2.96 }, { "text": "So I'm just going to specify cat.jpeg\nas the file name of the image", "start": 1106.74, "duration": 4.24 }, { "text": "that I want to display.", "start": 1110.98, "duration": 2.06 }, { "text": "And it turns out that images also\nhave a second required attribute.", "start": 1113.04, "duration": 3.94 }, { "text": "In addition to the file name or the link\nto whatever image I want to display,", "start": 1116.98, "duration": 4.41 }, { "text": "I also need to provide some alternative\ntext, a text-based representation", "start": 1121.39, "duration": 4.9 }, { "text": "of what you're going to see on\nthe image because in some cases,", "start": 1126.29, "duration": 2.63 }, { "text": "some web browser might not be able\nto render the image correctly.", "start": 1128.92, "duration": 3.21 }, { "text": "You might imagine if there's\nsome error rendering the image,", "start": 1132.13, "duration": 2.55 }, { "text": "or if someone's on a\nslow internet connection,", "start": 1134.68, "duration": 1.91 }, { "text": "or if someone's using a screen\nreader and therefore can't actually", "start": 1136.59, "duration": 2.75 }, { "text": "see the image.", "start": 1139.34, "duration": 0.71 }, { "text": "We want some text-based\nrepresentation of that image as well.", "start": 1140.05, "duration": 3.94 }, { "text": "And so I'll provide some Alt\ntext, some alternative text, that", "start": 1143.99, "duration": 3.23 }, { "text": "can be used to substitute the\nimage in case for some reason", "start": 1147.22, "duration": 2.79 }, { "text": "we can't display the image.", "start": 1150.01, "duration": 1.56 }, { "text": "And the Alt text that\nI'll use in this case", "start": 1151.57, "duration": 2.4 }, { "text": "is just going to be the\nword cat, for example.", "start": 1153.97, "duration": 3.45 }, { "text": "And that's all I need.", "start": 1157.42, "duration": 1.05 }, { "text": "Now, notice in particular\nthere's something a little bit", "start": 1158.47, "duration": 2.34 }, { "text": "different about this image\ntag compared to other tags", "start": 1160.81, "duration": 2.94 }, { "text": "that we've seen before in the sense\nthat it doesn't have a closing", "start": 1163.75, "duration": 3.36 }, { "text": "tag in the sense that the body had\na beginning of the body and an end", "start": 1167.11, "duration": 3.58 }, { "text": "to the body, our ordered list had\na beginning of the ordered list", "start": 1170.69, "duration": 2.9 }, { "text": "and the end of the unordered\nlist with list items in between.", "start": 1173.59, "duration": 2.82 }, { "text": "It doesn't really make\nsense for an image,", "start": 1176.41, "duration": 2.97 }, { "text": "for example, to have the\nbeginning of the image", "start": 1179.38, "duration": 2.07 }, { "text": "and the end of the\nimage and some content", "start": 1181.45, "duration": 1.8 }, { "text": "in between, because the image is just\na single HTML element that can't really", "start": 1183.25, "duration": 4.68 }, { "text": "have anything inside of it.", "start": 1187.93, "duration": 1.86 }, { "text": "So in that sense, we don't\nactually need a closing image tag.", "start": 1189.79, "duration": 3.21 }, { "text": "The image tag is self-closing.", "start": 1193.0, "duration": 1.93 }, { "text": "It is its own beginning and end.", "start": 1194.93, "duration": 1.88 }, { "text": "So we can just say we\nwant an image to be here", "start": 1196.81, "duration": 2.79 }, { "text": "that is cat.jpeg with an alternative\ntext of just the word cat, for example.", "start": 1199.6, "duration": 6.1 }, { "text": "So now, if I open up\nimage.html, we'll see", "start": 1205.7, "duration": 3.41 }, { "text": "that what gets loaded is quite\nlarge, a picture of a cat.", "start": 1209.11, "duration": 3.69 }, { "text": "And I can scroll around\nand see this entire image.", "start": 1212.8, "duration": 2.97 }, { "text": "Of course, this picture of a cat is\nprobably larger than I wanted it to be.", "start": 1215.77, "duration": 3.19 }, { "text": "I probably, when I my\nuser visits this web page,", "start": 1218.96, "duration": 2.05 }, { "text": "I don't want them to have to\nscroll all the way to the right", "start": 1221.01, "duration": 2.5 }, { "text": "in order to see the entire cat.", "start": 1223.51, "duration": 1.77 }, { "text": "So I can actually add\nadditional HTML attributes", "start": 1225.28, "duration": 3.15 }, { "text": "in order to modify the size of\nthe image that I'm displaying.", "start": 1228.43, "duration": 3.03 }, { "text": "And later we'll see we can use\nCSS to do a similar thing as well.", "start": 1231.46, "duration": 3.52 }, { "text": "But for now, what I can add\nis an additional attribute", "start": 1234.98, "duration": 3.23 }, { "text": "and say that let me give\ncat.jpeg, this image tag,", "start": 1238.21, "duration": 3.3 }, { "text": "another attribute that, in this\ncase, I'll just call width.", "start": 1241.51, "duration": 3.21 }, { "text": "And I'll say that width is\ngoing to be equal to 300,", "start": 1244.72, "duration": 3.15 }, { "text": "because I would like for this image\nto be 300 pixels wide, for example.", "start": 1247.87, "duration": 4.96 }, { "text": "So now, if I refresh\nthis page, I now see", "start": 1252.83, "duration": 2.3 }, { "text": "that the same cat image\nappears, except now it", "start": 1255.13, "duration": 2.4 }, { "text": "appears at 300 pixels wide exactly.", "start": 1257.53, "duration": 2.73 }, { "text": "So I'm able to add additional\nattributes, additional information", "start": 1260.26, "duration": 3.69 }, { "text": "to control how an HTML\nelement is going to appear.", "start": 1263.95, "duration": 3.17 }, { "text": "In this case, I want\nto control its width,", "start": 1267.12, "duration": 1.75 }, { "text": "and it automatically\nscales down the height", "start": 1268.87, "duration": 1.92 }, { "text": "to make sure that the image\nis proportional as well.", "start": 1270.79, "duration": 3.68 }, { "text": "Now, on the internet, in addition\nto just displaying information", "start": 1274.47, "duration": 2.88 }, { "text": "on a single page, it's also common\nfor a page to link to other pages.", "start": 1277.35, "duration": 4.21 }, { "text": "In fact, that's one of\nthe main important values", "start": 1281.56, "duration": 2.0 }, { "text": "of the internet is the\nability to go from one page", "start": 1283.56, "duration": 2.34 }, { "text": "to another via these links.", "start": 1285.9, "duration": 2.19 }, { "text": "And so one thing we might\nreasonably want to do", "start": 1288.09, "duration": 2.28 }, { "text": "is add some links to our page,\nwhere if you click on something,", "start": 1290.37, "duration": 2.82 }, { "text": "you're taken to another page altogether.", "start": 1293.19, "duration": 2.73 }, { "text": "So let's take a look\nat an example of that.", "start": 1295.92, "duration": 2.71 }, { "text": "I'll create a new file\nbased on hello.html.", "start": 1298.63, "duration": 2.96 }, { "text": "And I'll add lang equals\nEnglish for good measure.", "start": 1301.59, "duration": 2.42 }, { "text": "And I'll call this new file\nlink.html, where here, we're", "start": 1304.01, "duration": 4.24 }, { "text": "going to practice with building\nsome links into our HTML page.", "start": 1308.25, "duration": 4.1 }, { "text": "I'll copy the content of\nhello.html again, call this link.", "start": 1312.35, "duration": 5.58 }, { "text": "In order to create a link,\nI'm going to use a tag", "start": 1317.93, "duration": 2.48 }, { "text": "called the a tag, short\nfor the anchor tag.", "start": 1320.41, "duration": 3.57 }, { "text": "And the a tag takes one\nimportant attribute,", "start": 1323.98, "duration": 2.79 }, { "text": "which is called href, for\nhyperlink reference, which", "start": 1326.77, "duration": 3.69 }, { "text": "is going to specify what\npage I would like to link to.", "start": 1330.46, "duration": 3.82 }, { "text": "So if, for example, I wanted\nwhen a user clicks on this link", "start": 1334.28, "duration": 2.81 }, { "text": "to go to google.com, then\nI'd set the href attribute", "start": 1337.09, "duration": 3.69 }, { "text": "of this tag equal to\nHTTPS://google.com, for example.", "start": 1340.78, "duration": 7.04 }, { "text": "Then inside of the a tag, I would\nspecify what text I want to display.", "start": 1347.82, "duration": 4.83 }, { "text": "What text should the user see such\nthat when the user clicks on that text", "start": 1352.65, "duration": 3.81 }, { "text": "they're taken to the web page?", "start": 1356.46, "duration": 1.6 }, { "text": "In this case, I'm just going to\nsay something like, Click here,", "start": 1358.06, "duration": 3.62 }, { "text": "for instance.", "start": 1361.68, "duration": 2.03 }, { "text": "Now, if I open up a link.html,\nthis is what the user sees.", "start": 1363.71, "duration": 5.46 }, { "text": "They see a blue link\nthat says Click here.", "start": 1369.17, "duration": 2.28 }, { "text": "And when the user does\nclick on that link,", "start": 1371.45, "duration": 2.55 }, { "text": "they're taken to HTTPS://google.com.", "start": 1374.0, "duration": 4.75 }, { "text": "And it turns out that we can\nuse this href attribute not only", "start": 1378.75, "duration": 3.09 }, { "text": "to link to different\nwebsites altogether,", "start": 1381.84, "duration": 2.31 }, { "text": "but we can link to different\npages on the same website.", "start": 1384.15, "duration": 3.54 }, { "text": "So, for example, if I wanted\nto link to that cat page", "start": 1387.69, "duration": 2.73 }, { "text": "that I designed a moment ago,\ninstead of linking to google.com,", "start": 1390.42, "duration": 3.9 }, { "text": "I could instead just link to image.html.", "start": 1394.32, "duration": 4.53 }, { "text": "And now, if I save that and refresh,\nor if I open up link.html again,", "start": 1398.85, "duration": 5.94 }, { "text": "now I see a click here link,\nwhere when I click on Click here,", "start": 1404.79, "duration": 3.21 }, { "text": "now I'm taken to that\npage, image.html, that", "start": 1408.0, "duration": 3.63 }, { "text": "happened to have that\npicture of a cat from before.", "start": 1411.63, "duration": 3.0 }, { "text": "So using these anchor\ntags and href attributes,", "start": 1414.63, "duration": 3.03 }, { "text": "we're able to link\ntogether multiple pages.", "start": 1417.66, "duration": 1.83 }, { "text": "So that if we have a website that\nhas many different web pages,", "start": 1419.49, "duration": 2.79 }, { "text": "we can connect them all\ntogether by using a combination", "start": 1422.28, "duration": 3.03 }, { "text": "of these various different links.", "start": 1425.31, "duration": 2.58 }, { "text": "So now that we've seen images and links\nand lists, what other HTML elements", "start": 1427.89, "duration": 4.44 }, { "text": "might we add to our web page?", "start": 1432.33, "duration": 1.65 }, { "text": "Well, one thing we might\nwant to add are things", "start": 1433.98, "duration": 1.95 }, { "text": "like tables, just other ways\nof displaying information.", "start": 1435.93, "duration": 2.65 }, { "text": "So let's go ahead and create a\ntable and look at what HTML elements", "start": 1438.58, "duration": 3.47 }, { "text": "we can use in order to do so.", "start": 1442.05, "duration": 2.71 }, { "text": "So I'll go back here to my text editor,\ncreate a new file called table.html.", "start": 1444.76, "duration": 4.46 }, { "text": "Using the same starting HTML,\nwe'll call this page Table.", "start": 1449.22, "duration": 4.96 }, { "text": "And inside the body of\nthis page now, there", "start": 1454.18, "duration": 2.33 }, { "text": "are a number of different\nHTML elements that we'll", "start": 1456.51, "duration": 2.49 }, { "text": "need in order to create a table,\nbecause as you might imagine,", "start": 1459.0, "duration": 3.07 }, { "text": "a table is really composed\nof multiple parts.", "start": 1462.07, "duration": 2.42 }, { "text": "We have our big table.", "start": 1464.49, "duration": 1.23 }, { "text": "But each table is really just a\nsequence of individual table rows.", "start": 1465.72, "duration": 4.32 }, { "text": "And each of those rows\nis really just a sequence", "start": 1470.04, "duration": 2.34 }, { "text": "of individual cells of\ndata within that table.", "start": 1472.38, "duration": 3.33 }, { "text": "And so that structure that we're\nimagining, a table that consists", "start": 1475.71, "duration": 3.0 }, { "text": "of individual rows, where each\nrow consists of individual cells,", "start": 1478.71, "duration": 3.81 }, { "text": "is exactly how we're going to\nrepresent this table in HTML.", "start": 1482.52, "duration": 3.96 }, { "text": "We're going to start\nwith just a table tag.", "start": 1486.48, "duration": 3.24 }, { "text": "That's going to represent\nthe entirety of this table.", "start": 1489.72, "duration": 3.33 }, { "text": "But inside of the table, we\nmight have different parts.", "start": 1493.05, "duration": 2.82 }, { "text": "We might have the heading of the table.", "start": 1495.87, "duration": 2.22 }, { "text": "We might have the body of the table.", "start": 1498.09, "duration": 1.69 }, { "text": "So in order to represent\nthat, I'll add thead.", "start": 1499.78, "duration": 3.14 }, { "text": "That's going to stand for\nthe heading of the table,", "start": 1502.92, "duration": 2.13 }, { "text": "the stuff at the top\nof the table that might", "start": 1505.05, "duration": 1.83 }, { "text": "indicate what each column of\nthe table means, for example.", "start": 1506.88, "duration": 3.21 }, { "text": "And let's see, what columns do I want?", "start": 1510.09, "duration": 2.18 }, { "text": "Well, let's go ahead and\nadd some table headings,", "start": 1512.27, "duration": 2.05 }, { "text": "which I can represent using\nthe th tag, h for heading.", "start": 1514.32, "duration": 4.47 }, { "text": "And maybe I want in this web\npage to display information", "start": 1518.79, "duration": 2.91 }, { "text": "about various different\noceans, for example.", "start": 1521.7, "duration": 2.28 }, { "text": "So maybe I have one column for\nthe ocean and another column,", "start": 1523.98, "duration": 3.87 }, { "text": "another table heading, for the\naverage depth of that ocean,", "start": 1527.85, "duration": 4.35 }, { "text": "and another table heading for\nthe maximum depth of that ocean.", "start": 1532.2, "duration": 5.67 }, { "text": "And that'll be the very first row of\nthat table, the heading of the table.", "start": 1537.87, "duration": 3.24 }, { "text": "But in addition to the\nheading of the table,", "start": 1541.11, "duration": 1.84 }, { "text": "we also have the body of the table.", "start": 1542.95, "duration": 1.94 }, { "text": "So underneath the thead,\nI'll go ahead and include", "start": 1544.89, "duration": 2.81 }, { "text": "tbody, body for the main part of the\ntable where all my data is going to be.", "start": 1547.7, "duration": 4.75 }, { "text": "And that body is going to consist\nof individual rows of a table.", "start": 1552.45, "duration": 3.91 }, { "text": "So I might have a tr, which\nhere stands for table row.", "start": 1556.36, "duration": 5.81 }, { "text": "And inside of this table row, we'll\ngo ahead and add some individual data", "start": 1562.17, "duration": 4.08 }, { "text": "points inside of the table.", "start": 1566.25, "duration": 1.89 }, { "text": "So inside of my table row, I'm going\nto have one table data point, or td,", "start": 1568.14, "duration": 4.23 }, { "text": "for table data, that says Pacific\nOcean, for example, then another table", "start": 1572.37, "duration": 5.01 }, { "text": "data that says 4,280\nmeters, and then another one", "start": 1577.38, "duration": 4.23 }, { "text": "for the maximum depth of the Pacific\nOcean, which is 10,911 meters.", "start": 1581.61, "duration": 4.71 }, { "text": "And, in fact, these\nthree table heads as well", "start": 1586.32, "duration": 3.39 }, { "text": "at the top of the page, the ocean, the\naverage depth, and the maximum depth,", "start": 1589.71, "duration": 3.22 }, { "text": "those should actually probably\nbe in a row of their own", "start": 1592.93, "duration": 2.3 }, { "text": "as well, because the very first part\nof the table, that is also a row.", "start": 1595.23, "duration": 4.21 }, { "text": "So I'll go ahead and add a tr, short\nfor table row and inside of that tr", "start": 1599.44, "duration": 5.27 }, { "text": "put these headings.", "start": 1604.71, "duration": 1.41 }, { "text": "I'll go ahead and add one more row just\nso we can see what this looks like.", "start": 1606.12, "duration": 3.13 }, { "text": "And then, we'll take a look at the\npage and then go back to this code.", "start": 1609.25, "duration": 2.91 }, { "text": "I'll add the Atlantic Ocean, too, which\nhas an average depth of 3,646 meters,", "start": 1612.16, "duration": 6.17 }, { "text": "as well as a maximum depth\nof 8,486 meters as well.", "start": 1618.33, "duration": 6.34 }, { "text": "So when I open up table.html now,\nhere's what I'm going to see.", "start": 1624.67, "duration": 4.16 }, { "text": "I'm going to see a table-like\nrepresentation of the data.", "start": 1628.83, "duration": 3.46 }, { "text": "It's not just one thing after\nanother after another anymore.", "start": 1632.29, "duration": 2.69 }, { "text": "It's structured in a table.", "start": 1634.98, "duration": 1.12 }, { "text": "Now, granted, there aren't any borders.", "start": 1636.1, "duration": 1.63 }, { "text": "And I could probably add\nsome colors and spacing", "start": 1637.73, "duration": 2.17 }, { "text": "to make this look a little bit nicer.", "start": 1639.9, "duration": 1.75 }, { "text": "But I see three columns--", "start": 1641.65, "duration": 1.34 }, { "text": "ocean, average depth, and maximum\ndepth, where this very first row", "start": 1642.99, "duration": 4.65 }, { "text": "is what we might call the\ntable header, the very top", "start": 1647.64, "duration": 2.31 }, { "text": "of the table that's defining\nwhat all of the columns mean.", "start": 1649.95, "duration": 3.12 }, { "text": "Inside of that table header\nis a single table row", "start": 1653.07, "duration": 3.27 }, { "text": "that has three table data cells--", "start": 1656.34, "duration": 2.34 }, { "text": "ocean, average depth, and maximum depth.", "start": 1658.68, "duration": 2.97 }, { "text": "Then beneath this table\nheader, represented in bold,", "start": 1661.65, "duration": 3.06 }, { "text": "is the table's body, or\nthe tbody element, inside", "start": 1664.71, "duration": 3.24 }, { "text": "of which we had two rows, one for\nrepresenting the Pacific Ocean,", "start": 1667.95, "duration": 3.33 }, { "text": "one for representing the Atlantic Ocean.", "start": 1671.28, "duration": 2.25 }, { "text": "And then we had data cells\nin each one of those rows", "start": 1673.53, "duration": 2.73 }, { "text": "for representing each of the individual\ncells that's located within this table.", "start": 1676.26, "duration": 5.3 }, { "text": "So this is what that page\nultimately looks like.", "start": 1681.56, "duration": 2.53 }, { "text": "And let's take one more\nlook at the HTML just", "start": 1684.09, "duration": 1.92 }, { "text": "to get an understanding for how all of\nthese tags interact with one another.", "start": 1686.01, "duration": 4.82 }, { "text": "And no need to memorize all\nthese tags right now, slowly", "start": 1690.83, "duration": 2.84 }, { "text": "as you begin to design\nHTML pages, you'll", "start": 1693.67, "duration": 2.1 }, { "text": "start to get more familiar with\nwhat HTML tags are available to you.", "start": 1695.77, "duration": 3.6 }, { "text": "And certainly, all of\nthese HTML tags are", "start": 1699.37, "duration": 2.0 }, { "text": "things that are easy to reference\nif you need to look them up.", "start": 1701.37, "duration": 2.59 }, { "text": "It's very helpful to be\nable to look up something", "start": 1703.96, "duration": 2.04 }, { "text": "like, how do I create a table in HTML?", "start": 1706.0, "duration": 2.13 }, { "text": "And then you'll be able to see what\nthe various different tags you'll", "start": 1708.13, "duration": 2.88 }, { "text": "need to add are in order to generate\nthe table that you're looking for.", "start": 1711.01, "duration": 3.99 }, { "text": "But, again, just to recap, here, we\nhave a table element, inside of which", "start": 1715.0, "duration": 3.84 }, { "text": "are two child elements, thead and tbody.", "start": 1718.84, "duration": 3.36 }, { "text": "Inside of each of those are one or\nmore table rows, representing using tr.", "start": 1722.2, "duration": 4.95 }, { "text": "Inside of each of those are three table\ndata cells, representing using td.", "start": 1727.15, "duration": 6.12 }, { "text": "And so using these nested\ntags, elements inside", "start": 1733.27, "duration": 2.31 }, { "text": "of elements inside of\nother elements, we've", "start": 1735.58, "duration": 2.04 }, { "text": "been able to build something far more\ncomplex than just a bulleted list.", "start": 1737.62, "duration": 3.51 }, { "text": "We've been able to build an entire\ntable that has information as well.", "start": 1741.13, "duration": 5.24 }, { "text": "But ultimately, our web pages\nshould be web pages that don't just", "start": 1746.37, "duration": 2.87 }, { "text": "display information,\nbut that also let users", "start": 1749.24, "duration": 2.85 }, { "text": "interact with that\ninformation in some way.", "start": 1752.09, "duration": 2.68 }, { "text": "For example, you might imagine that\non Google's home page, for example,", "start": 1754.77, "duration": 3.11 }, { "text": "it's not just unchanging.", "start": 1757.88, "duration": 1.45 }, { "text": "There's a field where I\ncan type something in.", "start": 1759.33, "duration": 2.39 }, { "text": "And anytime users can\nprovide input to a web page,", "start": 1761.72, "duration": 3.48 }, { "text": "we generally call that\na form, or some place", "start": 1765.2, "duration": 2.55 }, { "text": "where a user can fill\nout a form in order", "start": 1767.75, "duration": 2.01 }, { "text": "to provide information to the web page.", "start": 1769.76, "duration": 2.91 }, { "text": "And so now, let's take a\nlook at how we can use HTML", "start": 1772.67, "duration": 3.03 }, { "text": "in order to create a form that's\ngoing to display some information.", "start": 1775.7, "duration": 4.42 }, { "text": "So I'll go ahead and create\na new page called form.html,", "start": 1780.12, "duration": 4.19 }, { "text": "again using that same HTML as before.", "start": 1784.31, "duration": 2.29 }, { "text": "We'll call the page Form.", "start": 1786.6, "duration": 2.65 }, { "text": "And inside of the body of\nthis page now, let's say", "start": 1789.25, "duration": 2.73 }, { "text": "that I want to create a form that gives\nthe user an opportunity to provide", "start": 1791.98, "duration": 3.81 }, { "text": "their full name, for example.", "start": 1795.79, "duration": 2.1 }, { "text": "How do I do that?", "start": 1797.89, "duration": 1.12 }, { "text": "Well, the first thing, I need is a\nform element, some way of saying,", "start": 1799.01, "duration": 3.03 }, { "text": "here is going to be a form.", "start": 1802.04, "duration": 2.39 }, { "text": "And now, inside of that form, what\nare the various different parts", "start": 1804.43, "duration": 3.15 }, { "text": "of the form?", "start": 1807.58, "duration": 1.02 }, { "text": "Well, there's really two parts that\nyou might imagine to this form.", "start": 1808.6, "duration": 3.18 }, { "text": "One is a place for the user to\nactually type in their name.", "start": 1811.78, "duration": 3.18 }, { "text": "And they probably also need some way\nto submit the form, some button that", "start": 1814.96, "duration": 3.27 }, { "text": "just says submit, such that\nthey can click on that button", "start": 1818.23, "duration": 2.76 }, { "text": "in order to submit the form.", "start": 1820.99, "duration": 1.86 }, { "text": "So how would we do that?", "start": 1822.85, "duration": 1.48 }, { "text": "Well, in order to create\nan input field, we're", "start": 1824.33, "duration": 2.24 }, { "text": "going to use an input tag, who's type\nin this case is going to be text.", "start": 1826.57, "duration": 6.86 }, { "text": "There are a number of\ndifferent ways that users", "start": 1833.43, "duration": 1.96 }, { "text": "might provide input to a form.", "start": 1835.39, "duration": 1.44 }, { "text": "They might type in text.", "start": 1836.83, "duration": 1.17 }, { "text": "They might choose from a dropdown menu.", "start": 1838.0, "duration": 2.04 }, { "text": "They might choose from\na radio button option.", "start": 1840.04, "duration": 2.64 }, { "text": "Or they might provide input as by\nclicking on a button, for example.", "start": 1842.68, "duration": 3.06 }, { "text": "In this case, we're specifically\nusing the type attribute", "start": 1845.74, "duration": 2.88 }, { "text": "to say that when the user is\nproviding input in this way,", "start": 1848.62, "duration": 2.7 }, { "text": "the type of input that they're providing\nis going to be some kind of text.", "start": 1851.32, "duration": 4.53 }, { "text": "Then, we might provide a\nplaceholder, some default text that's", "start": 1855.85, "duration": 4.23 }, { "text": "going to be inside of that\ninput field the first time", "start": 1860.08, "duration": 2.55 }, { "text": "the user looks at the page.", "start": 1862.63, "duration": 1.57 }, { "text": "So, for example, the\nplaceholder might be Full Name.", "start": 1864.2, "duration": 2.75 }, { "text": "That way the user knows that what\nthey should type into this placeholder", "start": 1866.95, "duration": 4.77 }, { "text": "is their own full name.", "start": 1871.72, "duration": 2.19 }, { "text": "And then finally, we're going to go\nahead and give a name to this input", "start": 1873.91, "duration": 3.69 }, { "text": "field.", "start": 1877.6, "duration": 0.5 }, { "text": "Now, this isn't going to be\nsomething that the user sees", "start": 1878.1, "duration": 2.33 }, { "text": "when they visit the page.", "start": 1880.43, "duration": 1.07 }, { "text": "But anytime you submit a form, when\nwe receive that forum in our web", "start": 1881.5, "duration": 3.99 }, { "text": "application-- something\nwe'll explore later on--", "start": 1885.49, "duration": 2.31 }, { "text": "we need some way of knowing which input\nfield corresponded to which value.", "start": 1887.8, "duration": 4.92 }, { "text": "And so we're going to name\neach of the input fields", "start": 1892.72, "duration": 2.46 }, { "text": "just so that later on we'll\nbe able to reference them.", "start": 1895.18, "duration": 2.99 }, { "text": "And, for now, since the user\nis typing their full name here,", "start": 1898.17, "duration": 2.95 }, { "text": "we could just name this full name.", "start": 1901.12, "duration": 1.74 }, { "text": "Or we could more succinctly just say\nname as the Name of this input field.", "start": 1902.86, "duration": 5.39 }, { "text": "After that, we have an input field\nwhere the user can type in their name.", "start": 1908.25, "duration": 3.45 }, { "text": "And now, we need some way for the\nuser to be able to submit this form.", "start": 1911.7, "duration": 3.6 }, { "text": "So we might say something\nlike input type equals", "start": 1915.3, "duration": 3.66 }, { "text": "submit to say, here's a way for\nthe user to submit the form,", "start": 1918.96, "duration": 4.47 }, { "text": "type equals submit means.", "start": 1923.43, "duration": 1.38 }, { "text": "This is how they're going to submit the\nform when they're done completing it.", "start": 1924.81, "duration": 4.51 }, { "text": "Now, if I open up\nform.html, this is the page", "start": 1929.32, "duration": 3.78 }, { "text": "that we're ultimately going\nto see when we load this HTML.", "start": 1933.1, "duration": 3.06 }, { "text": "This entire page just\ncontains a single HTML form.", "start": 1936.16, "duration": 3.17 }, { "text": "But that HTML form contains two parts.", "start": 1939.33, "duration": 3.05 }, { "text": "The first part was\nthis input element here", "start": 1942.38, "duration": 2.45 }, { "text": "that allowed an opportunity for the\nuser to type in their full name.", "start": 1944.83, "duration": 3.06 }, { "text": "They type in their full\nname into this input field.", "start": 1947.89, "duration": 2.26 }, { "text": "And when they're done, they\ncan click this Submit button", "start": 1950.15, "duration": 2.48 }, { "text": "to indicate that they would\nlike to now submit this form.", "start": 1952.63, "duration": 3.69 }, { "text": "Of course, right now, this form isn't\ngoing to do anything when we type", "start": 1956.32, "duration": 3.0 }, { "text": "in our name and click Submit, because\nwe have an added and a logic in order", "start": 1959.32, "duration": 3.15 }, { "text": "to handle this form.", "start": 1962.47, "duration": 1.53 }, { "text": "But later on, as we transition into\nthe world of building web applications", "start": 1964.0, "duration": 3.12 }, { "text": "using Python, we'll see\nhow we can design a form,", "start": 1967.12, "duration": 3.16 }, { "text": "such that after the user submits it,\nwe save information to a database", "start": 1970.28, "duration": 3.53 }, { "text": "or display some sort of\nresults back to the user,", "start": 1973.81, "duration": 2.67 }, { "text": "all by using the power of\nbuilding these web applications", "start": 1976.48, "duration": 2.88 }, { "text": "and connecting them to\nthese sorts of HTML forms.", "start": 1979.36, "duration": 3.42 }, { "text": "And HTML forms can actually\nget quite a bit more complex.", "start": 1982.78, "duration": 3.13 }, { "text": "We'll take a look at another example.", "start": 1985.91, "duration": 1.55 }, { "text": "For instance, let me\nopen up form1.html, which", "start": 1987.46, "duration": 4.83 }, { "text": "is a form that I built in advance,\nwhich shows a number of other ways", "start": 1992.29, "duration": 3.9 }, { "text": "that users can provide information\nas input to an HTML form.", "start": 1996.19, "duration": 4.02 }, { "text": "Here, we see an input\nwhose type is text,", "start": 2000.21, "duration": 3.0 }, { "text": "meaning we want the user to\ntype in their name as text.", "start": 2003.21, "duration": 3.08 }, { "text": "But you might also imagine that if\na user is logging into a website,", "start": 2006.29, "duration": 3.13 }, { "text": "for example, they might in addition to\ntyping in a text-based name or username", "start": 2009.42, "duration": 3.84 }, { "text": "or email, also provide a password.", "start": 2013.26, "duration": 2.34 }, { "text": "And generally, if you've been on a\nwebsite and you've typed in a password,", "start": 2015.6, "duration": 3.09 }, { "text": "the password characters don't all\nshow up as the actual characters.", "start": 2018.69, "duration": 3.72 }, { "text": "For security reasons, they generally\nshow up as just little dots", "start": 2022.41, "duration": 3.12 }, { "text": "on the screen hiding the actual\ncharacters that they're representing.", "start": 2025.53, "duration": 3.61 }, { "text": "And in HTML, we can do\nthat very easily by just", "start": 2029.14, "duration": 2.96 }, { "text": "saying that the type of\nthis input is password.", "start": 2032.1, "duration": 3.42 }, { "text": "If they're typing in a\npassword, our web browser", "start": 2035.52, "duration": 2.01 }, { "text": "will know not to actually display\nthose individual characters.", "start": 2037.53, "duration": 4.63 }, { "text": "In addition to just text-based input,\nwe also have radio button input,", "start": 2042.16, "duration": 3.48 }, { "text": "as I alluded to a moment ago.", "start": 2045.64, "duration": 1.84 }, { "text": "So here, we have a number\nof different radio inputs,", "start": 2047.48, "duration": 3.17 }, { "text": "where the user might be able to\nselect from a number of options,", "start": 2050.65, "duration": 2.74 }, { "text": "choosing their favorite\ncolor, for example,", "start": 2053.39, "duration": 2.19 }, { "text": "from a number of these options.", "start": 2055.58, "duration": 1.67 }, { "text": "And finally, just to take a look at\none other additional feature of HTML5,", "start": 2057.25, "duration": 4.47 }, { "text": "in fact, a new feature\nof HTML5, is something", "start": 2061.72, "duration": 2.67 }, { "text": "we might call a data\nlist, where we might", "start": 2064.39, "duration": 2.43 }, { "text": "have the user choose in a dropdown\nfrom a number of different options.", "start": 2066.82, "duration": 3.75 }, { "text": "But we want to very quickly filter down\nor autocomplete based on those options.", "start": 2070.57, "duration": 4.3 }, { "text": "So if the user needs to select what\ncountry they're from, for example,", "start": 2074.87, "duration": 3.3 }, { "text": "we might have an input\nfield and specify that it's", "start": 2078.17, "duration": 3.38 }, { "text": "going to be associated with\na list called countries.", "start": 2081.55, "duration": 4.32 }, { "text": "Then immediately below that I\nhave a data list element whose", "start": 2085.87, "duration": 3.53 }, { "text": "ID is countries, where here,\nI'm going to specify these", "start": 2089.4, "duration": 3.25 }, { "text": "are all of the options for\nwhat country we could have.", "start": 2092.65, "duration": 3.15 }, { "text": "Each one is inside of an\noption element whose value", "start": 2095.8, "duration": 2.87 }, { "text": "is whatever country they could select.", "start": 2098.67, "duration": 2.35 }, { "text": "And we have all of the countries of the\nworld listed in these option elements.", "start": 2101.02, "duration": 5.11 }, { "text": "So this input here is going to allow me\nto select one option from a list of all", "start": 2106.13, "duration": 4.79 }, { "text": "of these possible options.", "start": 2110.92, "duration": 1.96 }, { "text": "So now, if I open up form1.html.", "start": 2112.88, "duration": 4.21 }, { "text": "Here's what that form\nultimately looks like.", "start": 2117.09, "duration": 2.69 }, { "text": "I can, here, inside of the name field--", "start": 2119.78, "duration": 1.95 }, { "text": "again, that word name shows up,\nbecause it's the placeholder--", "start": 2121.73, "duration": 3.03 }, { "text": "I can type in my name here.", "start": 2124.76, "duration": 1.83 }, { "text": "And inside of the password\nfield anything I type", "start": 2126.59, "duration": 2.67 }, { "text": "is going to show up as\njust little dots instead", "start": 2129.26, "duration": 2.4 }, { "text": "of the actual characters, because the\ntype of that input field was password,", "start": 2131.66, "duration": 4.23 }, { "text": "instead of the type being text.", "start": 2135.89, "duration": 2.55 }, { "text": "In favorite color, I\nnow have the ability", "start": 2138.44, "duration": 1.98 }, { "text": "to choose between various\ndifferent favorite color options.", "start": 2140.42, "duration": 2.97 }, { "text": "In a radio button format, I choose\nfrom one of a number of options.", "start": 2143.39, "duration": 3.33 }, { "text": "And finally, inside\nthis country dropdown,", "start": 2146.72, "duration": 2.82 }, { "text": "I have the ability now when I click\non it to see all of the countries,", "start": 2149.54, "duration": 3.61 }, { "text": "but as I start to type\nletters, like u-n-i-t,", "start": 2153.15, "duration": 3.32 }, { "text": "it filters down to only the\noptions that I actually care about.", "start": 2156.47, "duration": 3.76 }, { "text": "So here if I type in enough letters,\neventually I see United States.", "start": 2160.23, "duration": 3.86 }, { "text": "And I can click on that option as well.", "start": 2164.09, "duration": 2.65 }, { "text": "So HTML5 builds in these\nadditional features", "start": 2166.74, "duration": 3.14 }, { "text": "to make it easy to implement something\nlike a text field, where it will auto", "start": 2169.88, "duration": 3.42 }, { "text": "complete based on the\ntext that you provide.", "start": 2173.3, "duration": 2.22 }, { "text": "You can just specify that it\nis inside of this data list", "start": 2175.52, "duration": 4.2 }, { "text": "and then provide a list of\nall the possible values.", "start": 2179.72, "duration": 2.43 }, { "text": "And then HTML and your\nweb browser in turn", "start": 2182.15, "duration": 2.58 }, { "text": "will take care of the process of\nrendering that information in the way", "start": 2184.73, "duration": 3.15 }, { "text": "that you expect it to be displayed.", "start": 2187.88, "duration": 3.78 }, { "text": "So those are just some of\nthe possible HTML elements", "start": 2191.66, "duration": 2.6 }, { "text": "that we can ultimately create by\nusing these various different elements", "start": 2194.26, "duration": 3.69 }, { "text": "that we nest within each other.", "start": 2197.95, "duration": 1.52 }, { "text": "And there are definitely\nother HTML elements", "start": 2199.47, "duration": 2.02 }, { "text": "that exist as well that\nyou can begin to explore.", "start": 2201.49, "duration": 2.61 }, { "text": "But all of them follow\na very similar pattern", "start": 2204.1, "duration": 2.17 }, { "text": "that we're going to have\nsome tag, that might require", "start": 2206.27, "duration": 2.21 }, { "text": "some attributes, additional\ninformation about the HTML,", "start": 2208.48, "duration": 3.3 }, { "text": "to give context to the web browser for\nhow that element should be displayed.", "start": 2211.78, "duration": 3.93 }, { "text": "Maybe that element needs to have\na particular source for an image.", "start": 2215.71, "duration": 3.12 }, { "text": "Maybe it needs a link in order to link\nto somewhere, or other information", "start": 2218.83, "duration": 3.15 }, { "text": "as well.", "start": 2221.98, "duration": 0.78 }, { "text": "And then inside of that element,\nyou might nest other elements.", "start": 2222.76, "duration": 2.7 }, { "text": "So that your table has rows.", "start": 2225.46, "duration": 1.86 }, { "text": "And inside of those rows,\nwe have other cells.", "start": 2227.32, "duration": 2.16 }, { "text": "And you might imagine\nnesting elements inside", "start": 2229.48, "duration": 2.55 }, { "text": "of other elements inside\nof other elements.", "start": 2232.03, "duration": 2.83 }, { "text": "But right now so far, all of our\nweb pages have been rather simple.", "start": 2234.86, "duration": 3.7 }, { "text": "They've just been-- we've described\nthe structure of the page,", "start": 2238.56, "duration": 2.59 }, { "text": "and we've described we want a\nlist here, we want to form there.", "start": 2241.15, "duration": 3.02 }, { "text": "What we might really like is\nsome way of specifying that we", "start": 2244.17, "duration": 2.89 }, { "text": "want to style our web page in some way.", "start": 2247.06, "duration": 2.28 }, { "text": "We want to add color.", "start": 2249.34, "duration": 0.93 }, { "text": "We want add spacing.", "start": 2250.27, "duration": 1.26 }, { "text": "We want to add some sort of\nother layout to our page as well.", "start": 2251.53, "duration": 3.48 }, { "text": "And in order to do that, we're\ngoing to use a second language", "start": 2255.01, "duration": 2.97 }, { "text": "that we're going to call CSS,\nshort for Cascading Style Sheets.", "start": 2257.98, "duration": 3.48 }, { "text": "In particular, we'll\nuse the latest version", "start": 2261.46, "duration": 1.8 }, { "text": "of CSS, CSS3, which gives us\nthe ability to take an HTML page", "start": 2263.26, "duration": 5.1 }, { "text": "and tell the web browser how\nwe would like it to be styled.", "start": 2268.36, "duration": 3.06 }, { "text": "Instead of just black text in the\nsame font on a white background,", "start": 2271.42, "duration": 3.48 }, { "text": "we can begin to specify\nparticular CSS properties of how", "start": 2274.9, "duration": 4.2 }, { "text": "we would like this page to look\nto make sure that the page looks", "start": 2279.1, "duration": 3.15 }, { "text": "the way we want it to.", "start": 2282.25, "duration": 1.71 }, { "text": "So let's take a look at a\nsimple example now of CSS", "start": 2283.96, "duration": 3.57 }, { "text": "to take a look at how we can\nadd some CSS code to our page.", "start": 2287.53, "duration": 5.27 }, { "text": "So I'll go ahead and create a new\nfile that I'll call style.html,", "start": 2292.8, "duration": 5.58 }, { "text": "just to demonstrate some basic ideas\nof adding some style to our page.", "start": 2298.38, "duration": 3.99 }, { "text": "And we'll go ahead and copy the\nsame hello.html from before.", "start": 2302.37, "duration": 3.96 }, { "text": "And maybe in addition to hello world,\nI display in h1 some big heading", "start": 2306.33, "duration": 4.02 }, { "text": "at the top that says like, Welcome\nto my web page, for example.", "start": 2310.35, "duration": 5.44 }, { "text": "So now, if I open up,\nstyle.html, this is what I see.", "start": 2315.79, "duration": 4.38 }, { "text": "I see a big heading at the top\nthat says welcome to my web page,", "start": 2320.17, "duration": 2.85 }, { "text": "beneath which is just\nthe text, hello world.", "start": 2323.02, "duration": 3.32 }, { "text": "And now imagine that I\nwant to add some style", "start": 2326.34, "duration": 2.37 }, { "text": "to this heading at the top of the page.", "start": 2328.71, "duration": 2.16 }, { "text": "Maybe instead of being left\naligned, I want it to be centered.", "start": 2330.87, "duration": 2.64 }, { "text": "Maybe instead of just being black\ntext, I'd like to change the color.", "start": 2333.51, "duration": 3.27 }, { "text": "In order to do that, just\nas we've used attributes", "start": 2336.78, "duration": 3.24 }, { "text": "in the past to add additional\ninformation to this particular HTML", "start": 2340.02, "duration": 4.26 }, { "text": "page, we can do a very\nsimilar thing with CSS.", "start": 2344.28, "duration": 3.42 }, { "text": "We can specify that we're going to\ngive this h1 element a style attribute.", "start": 2347.7, "duration": 5.24 }, { "text": "And that is going to be equal to.", "start": 2352.94, "duration": 1.54 }, { "text": "And then in quotation marks, we're going\nto provide all of the CSS properties", "start": 2354.48, "duration": 4.59 }, { "text": "that we would like to add\nto this particular element.", "start": 2359.07, "duration": 2.97 }, { "text": "So the way that CSS styling works\nis that we can give elements", "start": 2362.04, "duration": 3.78 }, { "text": "individual CSS properties,\nwhere a property is", "start": 2365.82, "duration": 2.97 }, { "text": "something like the color of the element\nor the alignment of the element.", "start": 2368.79, "duration": 3.8 }, { "text": "And each of those properties\nhas a default value.", "start": 2372.59, "duration": 2.53 }, { "text": "But we can change its\nvalue to something else.", "start": 2375.12, "duration": 2.73 }, { "text": "So if, for example, I wanted to\nchange the color of this heading,", "start": 2377.85, "duration": 3.78 }, { "text": "so that instead of a black heading,\nit displayed as the blue heading,", "start": 2381.63, "duration": 3.42 }, { "text": "I could say for this h1, I would\nlike to give it a color property.", "start": 2385.05, "duration": 4.59 }, { "text": "And then to give the\ncolor property of value,", "start": 2389.64, "duration": 2.25 }, { "text": "I say color colon and then the value\nthat I would like to give to it.", "start": 2391.89, "duration": 3.78 }, { "text": "So color colon blue, for\nexample, followed by a semicolon", "start": 2395.67, "duration": 4.42 }, { "text": "will change the color of\nthis h1 element to blue.", "start": 2400.09, "duration": 3.11 }, { "text": "And my text editor is\nautomatically showing me", "start": 2403.2, "duration": 1.92 }, { "text": "a little square that shows me\nwhat this color blue is actually", "start": 2405.12, "duration": 3.03 }, { "text": "going to look like.", "start": 2408.15, "duration": 0.87 }, { "text": "This isn't part of the text.", "start": 2409.02, "duration": 1.17 }, { "text": "It's just my text\neditor being helpful so", "start": 2410.19, "duration": 2.07 }, { "text": "that I can see in advance as I'm writing\nthis code what the color is actually", "start": 2412.26, "duration": 3.75 }, { "text": "going to look like.", "start": 2416.01, "duration": 2.02 }, { "text": "So now if I open up\nstyle.html, here's what I see.", "start": 2418.03, "duration": 4.64 }, { "text": "Instead of a black heading at the\ntop, we've changed the color to blue.", "start": 2422.67, "duration": 3.84 }, { "text": "And there are many other\nbuilt-in colors that", "start": 2426.51, "duration": 2.16 }, { "text": "exist within HTML that we\ncan use in order to change", "start": 2428.67, "duration": 2.79 }, { "text": "the color to whatever we want.", "start": 2431.46, "duration": 1.46 }, { "text": "If instead of blue, I said\nI want the color to be red,", "start": 2432.92, "duration": 2.42 }, { "text": "for instance, I can refresh the page.", "start": 2435.34, "duration": 2.34 }, { "text": "And now, the heading is red.", "start": 2437.68, "duration": 1.19 }, { "text": "And there are many other colors.", "start": 2438.87, "duration": 1.33 }, { "text": "I can change the color to like\nspring green, for instance.", "start": 2440.2, "duration": 2.69 }, { "text": "And that's going to\nbe a particular shade", "start": 2442.89, "duration": 1.71 }, { "text": "of green that displays just like this.", "start": 2444.6, "duration": 3.03 }, { "text": "And so now, we have the ability\nto add various different style", "start": 2447.63, "duration": 3.27 }, { "text": "properties to individual elements.", "start": 2450.9, "duration": 2.16 }, { "text": "I can say take this heading\nand change its style", "start": 2453.06, "duration": 2.73 }, { "text": "so that the color instead of being black\nis going to show up as blue instead.", "start": 2455.79, "duration": 4.93 }, { "text": "And if I want to add multiple CSS\nproperties to the same HTML element,", "start": 2460.72, "duration": 4.01 }, { "text": "I can do that as well.", "start": 2464.73, "duration": 1.53 }, { "text": "Here in the style attribute,\nI can say that in addition", "start": 2466.26, "duration": 2.52 }, { "text": "to saying that the color is blue,\nI'd like to give a second CSS", "start": 2468.78, "duration": 3.66 }, { "text": "property to this element.", "start": 2472.44, "duration": 1.53 }, { "text": "I'd like to say that the text align\nproperty should be center, for example.", "start": 2473.97, "duration": 7.29 }, { "text": "The text align property\ncontrols, as you might imagine,", "start": 2481.26, "duration": 3.3 }, { "text": "how a particular HTML\nelement has its text aligned.", "start": 2484.56, "duration": 2.82 }, { "text": "Is it all the way on the left, all\nthe way on the right, or centered?", "start": 2487.38, "duration": 3.02 }, { "text": "And if I change the text align\nproperty to have a value of center,", "start": 2490.4, "duration": 4.39 }, { "text": "well, then now, when I refresh this\npage, I see that Welcome to my web page", "start": 2494.79, "duration": 4.7 }, { "text": "is now both blue, and it's centered.", "start": 2499.49, "duration": 2.38 }, { "text": "I've changed the color, and\nI've changed the alignment", "start": 2501.87, "duration": 3.12 }, { "text": "of this particular element.", "start": 2504.99, "duration": 2.37 }, { "text": "And HTML elements don't need\nto just be styled directly.", "start": 2507.36, "duration": 3.48 }, { "text": "They can also get their style\ninformation from parent elements.", "start": 2510.84, "duration": 4.66 }, { "text": "So if you recall again\nthat DOM structure, where", "start": 2515.5, "duration": 2.75 }, { "text": "we have an HTML element inside\nof which is this body element", "start": 2518.25, "duration": 4.02 }, { "text": "and inside of the body element\nis this h1 element and this text,", "start": 2522.27, "duration": 4.38 }, { "text": "you can imagine if we\nwanted this styling", "start": 2526.65, "duration": 2.22 }, { "text": "to apply not just to this heading,\nbut also to the Hello World text,", "start": 2528.87, "duration": 4.47 }, { "text": "I could move the styling information,\nmove this style attribute,", "start": 2533.34, "duration": 3.66 }, { "text": "change it from the h1 and\nescalating it to this body.", "start": 2537.0, "duration": 4.11 }, { "text": "And if I move the style to the body,\nthen everything inside of the body", "start": 2541.11, "duration": 4.05 }, { "text": "is going to be styled in that way.", "start": 2545.16, "duration": 2.38 }, { "text": "So let's now take a look at an\nexample of that to see how that works.", "start": 2547.54, "duration": 3.48 }, { "text": "If I take this style\ninformation, and I move", "start": 2551.02, "duration": 2.57 }, { "text": "it so that instead of\nassociating it with the h1,", "start": 2553.59, "duration": 3.36 }, { "text": "I instead associate it with the body,\nthen now, when I refresh the page,", "start": 2556.95, "duration": 5.27 }, { "text": "I see that both parts of the\nbody, both the big heading", "start": 2562.22, "duration": 2.63 }, { "text": "at the top that says,\nWelcome to my web page,", "start": 2564.85, "duration": 2.16 }, { "text": "as well as the text, Hello World, both\nhave those CSS properties applied.", "start": 2567.01, "duration": 4.17 }, { "text": "I've changed their color to blue.", "start": 2571.18, "duration": 1.95 }, { "text": "And I've also changed\ntheir text alignment", "start": 2573.13, "duration": 2.13 }, { "text": "to be centered instead\nof just left aligned.", "start": 2575.26, "duration": 3.6 }, { "text": "But if I do want it to\njust be that heading,", "start": 2578.86, "duration": 2.19 }, { "text": "then I can move it out\nand say that I just", "start": 2581.05, "duration": 2.94 }, { "text": "want to apply the style to\nthat one individual heading.", "start": 2583.99, "duration": 4.65 }, { "text": "Now, one thing that we might imagine\nmight become a problem over time", "start": 2588.64, "duration": 3.53 }, { "text": "is that imagine if I had\nmultiple headings that I wanted", "start": 2592.17, "duration": 3.15 }, { "text": "to style in the same way, for example.", "start": 2595.32, "duration": 2.28 }, { "text": "Let's say I have a second heading that--", "start": 2597.6, "duration": 2.49 }, { "text": "this is a second heading--", "start": 2600.09, "duration": 1.51 }, { "text": "that I also want to be styled\nas blue and centered as well,", "start": 2601.6, "duration": 4.28 }, { "text": "I can refresh this page and see\nthat right now that is not the case.", "start": 2605.88, "duration": 3.01 }, { "text": "And I don't want to make the\nentire page blue and centered.", "start": 2608.89, "duration": 2.64 }, { "text": "I only want these two headings\nto be blue and centered.", "start": 2611.53, "duration": 3.59 }, { "text": "So what I could do is I could just\ntake this style code from the h1", "start": 2615.12, "duration": 4.41 }, { "text": "and apply it to this h1 as well,\nso that both of my h1 elements", "start": 2619.53, "duration": 4.14 }, { "text": "now have the exact same style code.", "start": 2623.67, "duration": 2.47 }, { "text": "And I'll go ahead and refresh this.", "start": 2626.14, "duration": 1.46 }, { "text": "And now, we see this is\nthe intended behavior.", "start": 2627.6, "duration": 2.55 }, { "text": "I have two headings, both of which are\ncentered and both of which are blue.", "start": 2630.15, "duration": 4.23 }, { "text": "But what we want to start to think about\nas we start to build web applications,", "start": 2634.38, "duration": 3.51 }, { "text": "and especially as our web applications\nstart to get a little bit more", "start": 2637.89, "duration": 3.0 }, { "text": "sophisticated, is to\nthink about the design", "start": 2640.89, "duration": 2.7 }, { "text": "of how we're building\nour web pages and how", "start": 2643.59, "duration": 2.04 }, { "text": "we're building our web applications.", "start": 2645.63, "duration": 1.72 }, { "text": "And in particular,\nanytime we find ourselves", "start": 2647.35, "duration": 2.24 }, { "text": "copying a lot of the same\ninformation from one place", "start": 2649.59, "duration": 3.0 }, { "text": "to another, that's probably\nnot the best design.", "start": 2652.59, "duration": 2.57 }, { "text": "And you should start to\nthink about how might you", "start": 2655.16, "duration": 2.05 }, { "text": "design this a little bit better.", "start": 2657.21, "duration": 1.9 }, { "text": "It's not great design,\none, just because there's", "start": 2659.11, "duration": 2.0 }, { "text": "some redundancy that probably\ndoesn't need to be there,", "start": 2661.11, "duration": 2.67 }, { "text": "but also because it makes\nthe page a little bit more", "start": 2663.78, "duration": 2.43 }, { "text": "difficult to change and add a\nlittle more difficult to update.", "start": 2666.21, "duration": 2.73 }, { "text": "If I instead want to change\nboth of these headings", "start": 2668.94, "duration": 2.31 }, { "text": "to be red instead of blue,\nthen all of a sudden,", "start": 2671.25, "duration": 2.73 }, { "text": "I need to change my code in two places.", "start": 2673.98, "duration": 2.89 }, { "text": "I need to change the style attribute\non this first heading up here.", "start": 2676.87, "duration": 3.83 }, { "text": "And I also need to change\nthe style attribute", "start": 2680.7, "duration": 2.4 }, { "text": "on the second heading down there.", "start": 2683.1, "duration": 2.67 }, { "text": "What I'd like to do\nis to somehow just be", "start": 2685.77, "duration": 2.04 }, { "text": "able to write the style\ncode once and then have", "start": 2687.81, "duration": 2.82 }, { "text": "it apply to both of these headings.", "start": 2690.63, "duration": 2.44 }, { "text": "And, in fact, there is a way to do that.", "start": 2693.07, "duration": 1.67 }, { "text": "What we can do is instead of doing\nwhat we might call inline styling,", "start": 2694.74, "duration": 4.2 }, { "text": "where we take the CSS\ncode and place it directly", "start": 2698.94, "duration": 3.63 }, { "text": "as an attribute of an HTML\nelement, we can move our style code", "start": 2702.57, "duration": 4.59 }, { "text": "to an entirely different\npart of the web page.", "start": 2707.16, "duration": 3.56 }, { "text": "Recall again that at the\ntop of our HTML page,", "start": 2710.72, "duration": 2.67 }, { "text": "we have this head section\nthat just includes", "start": 2713.39, "duration": 2.67 }, { "text": "information that's useful\nto know about the web page,", "start": 2716.06, "duration": 2.82 }, { "text": "but isn't actually part of the\nbody of the web page, the content", "start": 2718.88, "duration": 3.18 }, { "text": "that the user sees.", "start": 2722.06, "duration": 1.11 }, { "text": "This head section is\na great place where we", "start": 2723.17, "duration": 1.8 }, { "text": "can begin to put some style information,\ninformation about how we would", "start": 2724.97, "duration": 3.96 }, { "text": "like for this web page to be styled.", "start": 2728.93, "duration": 2.97 }, { "text": "So what I can do here is\ninstead of putting these style", "start": 2731.9, "duration": 3.54 }, { "text": "attributes inside inline\nwith these HTML elements,", "start": 2735.44, "duration": 4.71 }, { "text": "I can inside of the head\nsection of my web page", "start": 2740.15, "duration": 3.04 }, { "text": "add a style element, where in between\nthe opening style tag and the closing", "start": 2743.19, "duration": 6.17 }, { "text": "style tag, I can add any of the\nstyle information that I want.", "start": 2749.36, "duration": 5.04 }, { "text": "And here's the way that\nsyntax is going to look.", "start": 2754.4, "duration": 2.22 }, { "text": "I first need to specify, what types\nof elements am I going to style?", "start": 2756.62, "duration": 4.44 }, { "text": "And in this case, I want\nto style all of the h1s.", "start": 2761.06, "duration": 3.03 }, { "text": "So I can just say h1.", "start": 2764.09, "duration": 3.06 }, { "text": "And then all of the style\ncode is going to go inside", "start": 2767.15, "duration": 3.96 }, { "text": "of a pair of curly braces, where I can\nsay I would like the color to be blue", "start": 2771.11, "duration": 4.56 }, { "text": "and I would like the text\nalign property to be centered.", "start": 2775.67, "duration": 4.37 }, { "text": "So now, here's what I've done.", "start": 2780.04, "duration": 1.86 }, { "text": "I've taken the CSS code that used to be\ndown here inside the body of the page", "start": 2781.9, "duration": 4.7 }, { "text": "actually as an attribute\nof these h1 elements.", "start": 2786.6, "duration": 2.91 }, { "text": "And I've moved the style-related code to\na different part of my page altogether.", "start": 2789.51, "duration": 5.16 }, { "text": "Now, the style information is\ninside the header of my page,", "start": 2794.67, "duration": 3.06 }, { "text": "inside of the style element, where\nI've said for every h1 element,", "start": 2797.73, "duration": 4.51 }, { "text": "here's how you should style it.", "start": 2802.24, "duration": 1.4 }, { "text": "The styling is in between the opening\nand curly closing braces here.", "start": 2803.64, "duration": 3.45 }, { "text": "And I've said that every h1\nshould have a color of blue.", "start": 2807.09, "duration": 3.74 }, { "text": "And every h1 should have a\ntext a line property of center.", "start": 2810.83, "duration": 4.45 }, { "text": "And that is then going to\napply to all of the h1 elements", "start": 2815.28, "duration": 3.33 }, { "text": "that my web page happens to find\ninside the body of my web page.", "start": 2818.61, "duration": 4.08 }, { "text": "So there's a couple of advantages here.", "start": 2822.69, "duration": 1.63 }, { "text": "Advantage number one is what\nwe talked about a moment ago.", "start": 2824.32, "duration": 2.45 }, { "text": "I don't need to duplicate the same\ncode in both of these h1 elements.", "start": 2826.77, "duration": 4.17 }, { "text": "I can write at once and\nsay, apply this styling", "start": 2830.94, "duration": 2.55 }, { "text": "to all of the h1s that\nshow up in the page.", "start": 2833.49, "duration": 2.81 }, { "text": "An advantage number two is we've\nbeen able to factor out the style", "start": 2836.3, "duration": 4.0 }, { "text": "code to somewhere else, just to\nmake it a little bit cleaner.", "start": 2840.3, "duration": 3.01 }, { "text": "So that instead of having a really\nlong line, you might imagine,", "start": 2843.31, "duration": 2.78 }, { "text": "if we had not just two, but maybe\nfive or six or seven different CSS", "start": 2846.09, "duration": 3.28 }, { "text": "properties, that would have taken\nup a lot of space on one line.", "start": 2849.37, "duration": 3.45 }, { "text": "I can instead in a more\nreadable, more organized way,", "start": 2852.82, "duration": 3.26 }, { "text": "move that style-related\ncode to the style element", "start": 2856.08, "duration": 2.91 }, { "text": "at the beginning of the page\njust to make it easier to read,", "start": 2858.99, "duration": 3.1 }, { "text": "easier to visually understand, and just\nto clean up the body of the web page", "start": 2862.09, "duration": 3.77 }, { "text": "as well.", "start": 2865.86, "duration": 0.9 }, { "text": "And that's going to be another\nof the key themes that's", "start": 2866.76, "duration": 1.71 }, { "text": "going to come up again and again in this\nclass, this idea of separating things", "start": 2868.47, "duration": 3.3 }, { "text": "out so that every piece can sort\nof be independent of one another.", "start": 2871.77, "duration": 3.5 }, { "text": "Our structure of the web page inside\nthe body is separate from the style.", "start": 2875.27, "duration": 3.91 }, { "text": "And we'll see the same sort of idea\nappear again and again, as we begin", "start": 2879.18, "duration": 3.33 }, { "text": "to try to design web applications well.", "start": 2882.51, "duration": 3.78 }, { "text": "So now if I take this exact same page\nand go ahead and refresh style.html,", "start": 2886.29, "duration": 6.36 }, { "text": "we'll see that we see\nthe exact same thing.", "start": 2892.65, "duration": 3.09 }, { "text": "Both of the headings\nstill show up as centered.", "start": 2895.74, "duration": 2.13 }, { "text": "Both of them still show up as blue.", "start": 2897.87, "duration": 1.95 }, { "text": "But now we have the\nadvantage of having only", "start": 2899.82, "duration": 1.86 }, { "text": "written the style code once instead of\nneeding to write the exact same style", "start": 2901.68, "duration": 4.17 }, { "text": "code multiple times in the same way.", "start": 2905.85, "duration": 3.61 }, { "text": "But it turns out that we can\neven do a little bit better", "start": 2909.46, "duration": 2.64 }, { "text": "than this, because one\nthing you might imagine", "start": 2912.1, "duration": 2.7 }, { "text": "is that if I have a web application or a\nwebsite that has multiple different web", "start": 2914.8, "duration": 3.9 }, { "text": "pages, it's probably going to be\nlikely that each of those web pages", "start": 2918.7, "duration": 4.2 }, { "text": "might need to be styled in similar ways.", "start": 2922.9, "duration": 2.43 }, { "text": "If I have a big banner at\nthe top of one web page,", "start": 2925.33, "duration": 2.55 }, { "text": "then in other pages\nrelated to that page,", "start": 2927.88, "duration": 2.52 }, { "text": "I might want the same banner,\nstyled in the same way,", "start": 2930.4, "duration": 2.79 }, { "text": "using similar style information.", "start": 2933.19, "duration": 2.28 }, { "text": "And right now, our CSS code is\nspecific to one particular page.", "start": 2935.47, "duration": 5.43 }, { "text": "And it's not going to be easy\nto then take that same styling", "start": 2940.9, "duration": 2.94 }, { "text": "and apply it to another page.", "start": 2943.84, "duration": 1.53 }, { "text": "If I wanted to, I'd need to\ncopy the exact same CSS code,", "start": 2945.37, "duration": 3.51 }, { "text": "put it inside of another page.", "start": 2948.88, "duration": 1.54 }, { "text": "But then we run into the\nsame problem of duplication,", "start": 2950.42, "duration": 2.57 }, { "text": "where I've now had to repeat myself\nacross multiple different pages,", "start": 2952.99, "duration": 3.0 }, { "text": "putting the exact same CSS code\nacross all those different pages.", "start": 2955.99, "duration": 4.15 }, { "text": "So there is an improvement we can make.", "start": 2960.14, "duration": 1.91 }, { "text": "And the improvement we can\nmake is to take that CSS code", "start": 2962.05, "duration": 3.93 }, { "text": "and just move it to an\nentirely different file.", "start": 2965.98, "duration": 3.25 }, { "text": "So instead of putting this style\ncode inside of a style element", "start": 2969.23, "duration": 3.65 }, { "text": "inside of this HTML page,\nI'll just create a new file", "start": 2972.88, "duration": 3.87 }, { "text": "that I'll call styles.css, inside of\nwhich is going to be all of the CSS", "start": 2976.75, "duration": 5.52 }, { "text": "that I care about.", "start": 2982.27, "duration": 1.08 }, { "text": "I want to take every h1, I want\nto change its color to blue.", "start": 2983.35, "duration": 3.49 }, { "text": "And now, I want to change its\ntext align property to center.", "start": 2986.84, "duration": 4.51 }, { "text": "And now, inside of my HTML page, I no\nlonger need to include any CSS at all.", "start": 2991.35, "duration": 5.91 }, { "text": "Instead of this style\nelement altogether,", "start": 2997.26, "duration": 2.27 }, { "text": "I can just link my CSS code in\nthat CSS file, called styles.css,", "start": 2999.53, "duration": 5.55 }, { "text": "to this particular HTML page.", "start": 3005.08, "duration": 3.06 }, { "text": "And how do I link the styles.css file?", "start": 3008.14, "duration": 2.37 }, { "text": "Well, I can do so again in the\nhead section of my web page", "start": 3010.51, "duration": 3.18 }, { "text": "using a link tag, where I\ncan say I'd like this link", "start": 3013.69, "duration": 4.2 }, { "text": "to be the relationship is it's\ngoing to be a style sheet,", "start": 3017.89, "duration": 3.85 }, { "text": "meaning what I'm about to link is going\nto be a style sheet for this page.", "start": 3021.74, "duration": 3.54 }, { "text": "It's going to describe how I want for\nthe elements on this page to be styled.", "start": 3025.28, "duration": 4.4 }, { "text": "And then, just as in the case\nof a link to another page,", "start": 3029.68, "duration": 2.85 }, { "text": "I use href to specify a hyperlink\nreference, what I want to link to,", "start": 3032.53, "duration": 5.01 }, { "text": "I'm now going to specify\nusing an href attribute what", "start": 3037.54, "duration": 3.39 }, { "text": "CSS file I would like to know link.", "start": 3040.93, "duration": 2.19 }, { "text": "And in this case the CSS file that\nI'm going to link is styles.css.", "start": 3043.12, "duration": 5.04 }, { "text": "That is the file that just so\nhappens to contain all of the CSS", "start": 3048.16, "duration": 3.63 }, { "text": "that I would like to apply\nto this particular file.", "start": 3051.79, "duration": 3.6 }, { "text": "Now, if I refresh the page, I\nsee again nothing has changed.", "start": 3055.39, "duration": 3.99 }, { "text": "In the last two revisions, the\npage has stayed exactly the same", "start": 3059.38, "duration": 2.82 }, { "text": "as far as the user is concerned.", "start": 3062.2, "duration": 1.47 }, { "text": "They still see two headings.", "start": 3063.67, "duration": 1.2 }, { "text": "Both of them are centered.", "start": 3064.87, "duration": 1.09 }, { "text": "Both of them are blue.", "start": 3065.96, "duration": 1.22 }, { "text": "But now, the advantage\nis that here is my HTML.", "start": 3067.18, "duration": 3.3 }, { "text": "It's shorter than it was before.", "start": 3070.48, "duration": 1.87 }, { "text": "And in particular, there's no CSS that's\nbaked in to this HTML file at all.", "start": 3072.35, "duration": 4.76 }, { "text": "I factored it all out into\nthe separate styles.css file.", "start": 3077.11, "duration": 4.38 }, { "text": "And now if I have multiple HTML files\nthat are all using the same styling,", "start": 3081.49, "duration": 4.68 }, { "text": "I can just link them all\nto the same styles.css", "start": 3086.17, "duration": 3.36 }, { "text": "file, such that they're all\nusing the same style information.", "start": 3089.53, "duration": 3.72 }, { "text": "I don't need to repeat myself.", "start": 3093.25, "duration": 1.56 }, { "text": "And if ever I need to make a\nchange across all of those pages,", "start": 3094.81, "duration": 3.42 }, { "text": "I just change the styling once.", "start": 3098.23, "duration": 1.95 }, { "text": "I change the styles.css file.", "start": 3100.18, "duration": 2.37 }, { "text": "And then all of the web pages that\nare linked to that style sheet", "start": 3102.55, "duration": 3.66 }, { "text": "will update as well in order\nto reflect those changes.", "start": 3106.21, "duration": 3.2 }, { "text": "So again, we've been able to factor\nout some of this style information", "start": 3109.41, "duration": 3.67 }, { "text": "to a separate file just to make\nour lives a little bit easier.", "start": 3113.08, "duration": 4.25 }, { "text": "All right, so so far\nwe've now seen how we", "start": 3117.33, "duration": 1.75 }, { "text": "can CSS in a number of different ways\nto add some basic styles to our page.", "start": 3119.08, "duration": 4.29 }, { "text": "We've seen that we can take an\nelement and change its color.", "start": 3123.37, "duration": 2.86 }, { "text": "We've seen how we can take an\nelement and change its alignment,", "start": 3126.23, "duration": 2.63 }, { "text": "move it from left aligned to right\naligned to centered, for example.", "start": 3128.86, "duration": 3.12 }, { "text": "As it turns out, there are a\nlot of different CSS properties", "start": 3131.98, "duration": 2.88 }, { "text": "that we can add to our\nHTML elements in order", "start": 3134.86, "duration": 2.94 }, { "text": "to style them in various different\nways, more than we'll have time", "start": 3137.8, "duration": 3.54 }, { "text": "to talk about in this lecture.", "start": 3141.34, "duration": 1.6 }, { "text": "But now, let's just\ntake a look at a couple", "start": 3142.94, "duration": 1.82 }, { "text": "of the most popular, most\ncommon CSS properties", "start": 3144.76, "duration": 2.81 }, { "text": "that we can add in order to make our\nweb pages look the way we wanted to.", "start": 3147.57, "duration": 4.84 }, { "text": "And one of the most\npowerful tools for CSS", "start": 3152.41, "duration": 2.31 }, { "text": "is controlling the size of\nvarious different elements.", "start": 3154.72, "duration": 2.85 }, { "text": "By default, HTML just used a default\nsize for everything on the page.", "start": 3157.57, "duration": 4.14 }, { "text": "But if I want to more precisely control\nhow big any particular element is I", "start": 3161.71, "duration": 4.62 }, { "text": "can use CSS in order to do so.", "start": 3166.33, "duration": 3.1 }, { "text": "So let me now create a new file\nthat I will call a size.html.", "start": 3169.43, "duration": 4.31 }, { "text": "We'll start with the same HTML\ncode and call the page Size.", "start": 3173.74, "duration": 5.48 }, { "text": "And now, inside the body\nof my page, let me just", "start": 3179.22, "duration": 2.94 }, { "text": "have a vertical section of my\npage, just some section of my page", "start": 3182.16, "duration": 3.24 }, { "text": "that's going to have some content.", "start": 3185.4, "duration": 1.72 }, { "text": "And I'm going to put\nthis inside of a div tag.", "start": 3187.12, "duration": 3.38 }, { "text": "Now, this is the first time\nthat we've seen a div in HTML.", "start": 3190.5, "duration": 2.7 }, { "text": "You can think of a\ndiv as just a division", "start": 3193.2, "duration": 2.52 }, { "text": "of the page, some section\nof the page that's going", "start": 3195.72, "duration": 2.55 }, { "text": "to have some content inside of it.", "start": 3198.27, "duration": 1.74 }, { "text": "And we use divs because it makes it easy\nto reference a particular div or nest", "start": 3200.01, "duration": 4.74 }, { "text": "information inside of other pieces\nof information, or just to divide", "start": 3204.75, "duration": 3.54 }, { "text": "and break up our page into\nmultiple different sections.", "start": 3208.29, "duration": 2.82 }, { "text": "Here, inside of the body,\nI'm just going to have", "start": 3211.11, "duration": 2.0 }, { "text": "a single div that is going to\nsay something like hello world.", "start": 3213.11, "duration": 3.97 }, { "text": "And now, I'm going to add\nsome style to this page", "start": 3217.08, "duration": 2.94 }, { "text": "in order to control\nthe size of this div,", "start": 3220.02, "duration": 2.22 }, { "text": "to control the size of this\nsection of my web page.", "start": 3222.24, "duration": 3.24 }, { "text": "I could use inline styling.", "start": 3225.48, "duration": 1.35 }, { "text": "I could factor things\nout into another file.", "start": 3226.83, "duration": 1.95 }, { "text": "But since I'm only dealing\nwith one file for now,", "start": 3228.78, "duration": 2.49 }, { "text": "I'm just going to add a style\nsection to the top of my web page", "start": 3231.27, "duration": 2.88 }, { "text": "just so you can more clearly\nsee how the style of this page", "start": 3234.15, "duration": 2.88 }, { "text": "is going to map on to the way that\nwe're modifying these HTML elements.", "start": 3237.03, "duration": 5.25 }, { "text": "And I would like to style\nthis div in a couple of ways.", "start": 3242.28, "duration": 3.7 }, { "text": "One thing I can do is give\nthe div a background color.", "start": 3245.98, "duration": 2.25 }, { "text": "Let me change its background\ncolor to blue, for example.", "start": 3248.23, "duration": 3.77 }, { "text": "And then I can say, all right,\nI'd like to give this div a width", "start": 3252.0, "duration": 2.94 }, { "text": "and a height, some size information.", "start": 3254.94, "duration": 2.37 }, { "text": "I can say, go ahead and give\nthis div a width of 100 pixels", "start": 3257.31, "duration": 3.78 }, { "text": "and maybe a height of 400 pixels.", "start": 3261.09, "duration": 4.5 }, { "text": "So now, when I go ahead and open\nup size.html, this is what I see.", "start": 3265.59, "duration": 5.99 }, { "text": "I see in a 100 by 400 pixel\nwide vertical, or rectangular,", "start": 3271.58, "duration": 4.53 }, { "text": "section of my page, I see\nthe words Hello World.", "start": 3276.11, "duration": 3.45 }, { "text": "And so you might imagine if you\nhave multiple different elements", "start": 3279.56, "duration": 2.67 }, { "text": "on your page, as your web pages start\nto get a little bit more complex,", "start": 3282.23, "duration": 3.06 }, { "text": "you probably want to have some\nmore precise control over how wide", "start": 3285.29, "duration": 3.3 }, { "text": "or how tall any particular element is.", "start": 3288.59, "duration": 2.4 }, { "text": "And these width and height\nattributes can be very helpful", "start": 3290.99, "duration": 2.61 }, { "text": "because I can very easily change\nthe width to say like 500 pixels,", "start": 3293.6, "duration": 3.21 }, { "text": "for example.", "start": 3296.81, "duration": 1.02 }, { "text": "And now when I refresh the page, now\nI see that the width of this page,", "start": 3297.83, "duration": 3.29 }, { "text": "or this div, the section of the page,\nhas actually now gotten a lot wider.", "start": 3301.12, "duration": 4.95 }, { "text": "And so we have the ability\nto control size using CSS.", "start": 3306.07, "duration": 4.45 }, { "text": "Go ahead and can close some of\nthese pages that I no longer need.", "start": 3310.52, "duration": 3.04 }, { "text": "And now take a look at some\nother things that we can do.", "start": 3313.56, "duration": 2.54 }, { "text": "In addition to controlling\nthe size-- and let", "start": 3316.1, "duration": 1.59 }, { "text": "me change this color to\nsomething a little bit lighter,", "start": 3317.69, "duration": 2.29 }, { "text": "something like orange, such that now\nif I open up size, it looks like this.", "start": 3319.98, "duration": 5.16 }, { "text": "I'll make this a little bit smaller.", "start": 3325.14, "duration": 1.62 }, { "text": "Let's try 200 by 200 pixels.", "start": 3326.76, "duration": 2.95 }, { "text": "It looks now like this.", "start": 3329.71, "duration": 1.41 }, { "text": "You might imagine there are some other\nchanges that I might like to make.", "start": 3331.12, "duration": 3.09 }, { "text": "Like this Hello World, for\nexample, is very close to the edge", "start": 3334.21, "duration": 4.29 }, { "text": "of this particular div.", "start": 3338.5, "duration": 1.23 }, { "text": "It's right up against the\nupper left corner of that div.", "start": 3339.73, "duration": 2.78 }, { "text": "I might want to change\nthat by adding what", "start": 3342.51, "duration": 1.75 }, { "text": "we might call some padding to this\nparticular HTML element, some space,", "start": 3344.26, "duration": 4.17 }, { "text": "just so that the content\nof the element isn't", "start": 3348.43, "duration": 2.28 }, { "text": "so close to the border\nof the element itself.", "start": 3350.71, "duration": 3.7 }, { "text": "So, for example, one thing I can do\nis inside this div add some padding.", "start": 3354.41, "duration": 4.19 }, { "text": "Say maybe I want 20 pixels worth of\npadding on the inside of the element,", "start": 3358.6, "duration": 4.9 }, { "text": "such that now when I\nrefresh the page, we", "start": 3363.5, "duration": 2.72 }, { "text": "see that we have some padding\nalong the outside of the element.", "start": 3366.22, "duration": 3.22 }, { "text": "So that Hello World now\nshows up not right up", "start": 3369.44, "duration": 2.33 }, { "text": "against the edge of the element,\nbut inside a little bit as well.", "start": 3371.77, "duration": 4.42 }, { "text": "And if we have a particular\nHTML element that", "start": 3376.19, "duration": 1.94 }, { "text": "maybe is too close to\nthe edge of the screen,", "start": 3378.13, "duration": 2.13 }, { "text": "maybe it's too close to\nthe top of the screen,", "start": 3380.26, "duration": 2.23 }, { "text": "we can also add space around\noutside of the element", "start": 3382.49, "duration": 3.17 }, { "text": "by adding what we call margin\nto the element as well.", "start": 3385.66, "duration": 2.92 }, { "text": "So I can say let's give it 20\npixels of margin inside of this div.", "start": 3388.58, "duration": 4.31 }, { "text": "And then refresh.", "start": 3392.89, "duration": 1.11 }, { "text": "And now we see that whereas\nbefore this div was very close", "start": 3394.0, "duration": 3.84 }, { "text": "to the upper left edge\nof the screen, now", "start": 3397.84, "duration": 2.1 }, { "text": "we've moved it 20 pixels\naway from everything.", "start": 3399.94, "duration": 2.44 }, { "text": "So it's got some space\non all four sides of it.", "start": 3402.38, "duration": 3.71 }, { "text": "So that's how we can now\nuse margin and padding just", "start": 3406.09, "duration": 2.95 }, { "text": "to make the page look a\nlittle bit nicer to the user.", "start": 3409.04, "duration": 2.21 }, { "text": "So objects are not too close\ntogether or too far apart.", "start": 3411.25, "duration": 3.24 }, { "text": "Padding, again, is on the inside\nof the border of the element.", "start": 3414.49, "duration": 3.57 }, { "text": "I can add 20 pixels of\npadding, for example,", "start": 3418.06, "duration": 2.65 }, { "text": "to make sure that the content\ninside of the element,", "start": 3420.71, "duration": 2.4 }, { "text": "in this case, the words Hello World,\njust have a little bit of space", "start": 3423.11, "duration": 3.35 }, { "text": "from the border.", "start": 3426.46, "duration": 0.93 }, { "text": "And that's padding on the\ninside of the element.", "start": 3427.39, "duration": 2.22 }, { "text": "Margin, meanwhile, is on\nthe outside of the element.", "start": 3429.61, "duration": 2.76 }, { "text": "We add some margin along the\noutside of the border to space", "start": 3432.37, "duration": 3.06 }, { "text": "the element out from\nother elements that might", "start": 3435.43, "duration": 2.19 }, { "text": "be nearby it to make sure that there's\nenough space between the border", "start": 3437.62, "duration": 3.06 }, { "text": "of the element from the top of\nthe screen and also from the left", "start": 3440.68, "duration": 2.74 }, { "text": "and also the bottom and the right,\nthough there's no objects there", "start": 3443.42, "duration": 2.75 }, { "text": "that we're currently\ncreating space from.", "start": 3446.17, "duration": 2.67 }, { "text": "So by combining width and\nheight and margin and padding,", "start": 3448.84, "duration": 3.66 }, { "text": "we now have the ability,\nusing CSS, to make sure", "start": 3452.5, "duration": 3.06 }, { "text": "that we're able to layout our page\nthe way we want to lay out the page,", "start": 3455.56, "duration": 3.05 }, { "text": "so that elements have the right\namount of spacing from each other", "start": 3458.61, "duration": 2.71 }, { "text": "and are the correct size.", "start": 3461.32, "duration": 2.16 }, { "text": "So now, let's take a look at some other\nfeatures that CSS is going to give us.", "start": 3463.48, "duration": 3.93 }, { "text": "In addition to just changing\nwhere particular elements are,", "start": 3467.41, "duration": 2.94 }, { "text": "like centering text or adding\nsize and margin and padding,", "start": 3470.35, "duration": 3.24 }, { "text": "we can also use CSS to change\nhow elements actually look.", "start": 3473.59, "duration": 3.66 }, { "text": "We've seen it to change the color\nof text, changing it from one color,", "start": 3477.25, "duration": 3.0 }, { "text": "like black, to another color, like blue.", "start": 3480.25, "duration": 2.49 }, { "text": "But we can also use CSS to be able\nto change something like the font", "start": 3482.74, "duration": 4.29 }, { "text": "that we use in order to display text.", "start": 3487.03, "duration": 2.19 }, { "text": "Modern web pages don't show\neverything in the exact same font.", "start": 3489.22, "duration": 2.97 }, { "text": "Usually, some designer\nis choosing what font", "start": 3492.19, "duration": 2.4 }, { "text": "they want for any particular web page.", "start": 3494.59, "duration": 3.18 }, { "text": "So let's experiment with\nthose possibilities.", "start": 3497.77, "duration": 2.05 }, { "text": "I'll now create a new file\nthat I'll call font.html,", "start": 3499.82, "duration": 4.4 }, { "text": "inside of which will be\nan HTML page called font.", "start": 3504.22, "duration": 5.23 }, { "text": "And inside the body, I'll\nagain just have a div", "start": 3509.45, "duration": 2.02 }, { "text": "that says Hello World, same as before.", "start": 3511.47, "duration": 3.27 }, { "text": "But now, inside of the style tag here,\nup in the head section of my web page,", "start": 3514.74, "duration": 4.98 }, { "text": "I would like to add some\nfont information to this div.", "start": 3519.72, "duration": 4.02 }, { "text": "And in particular, there are a number\nof different font-related CSS properties", "start": 3523.74, "duration": 3.66 }, { "text": "that I can add to control the font\nof any particular HTML element.", "start": 3527.4, "duration": 4.53 }, { "text": "One thing I can specify\nis the font family,", "start": 3531.93, "duration": 3.18 }, { "text": "specifying what font would I like to\nuse in order to display this text.", "start": 3535.11, "duration": 4.89 }, { "text": "And maybe I want to display\nit in Arial, for example,", "start": 3540.0, "duration": 2.63 }, { "text": "which is a common font\nused on the internet, such", "start": 3542.63, "duration": 2.92 }, { "text": "that now if I open up font.html, I now\nsee in Arial the words Hello World,", "start": 3545.55, "duration": 6.84 }, { "text": "different from the text\nthat I was using before.", "start": 3552.39, "duration": 3.09 }, { "text": "You can also specify\nmultiple different fonts.", "start": 3555.48, "duration": 2.76 }, { "text": "Not all computers support all fonts.", "start": 3558.24, "duration": 1.92 }, { "text": "So I could specify that just\nin case Arial isn't supported,", "start": 3560.16, "duration": 3.63 }, { "text": "fall back to any sans serif\nfont, any of the fonts that", "start": 3563.79, "duration": 3.57 }, { "text": "don't have the little glyphs at\nthe edge of each of the characters.", "start": 3567.36, "duration": 3.34 }, { "text": "So now, if I refresh the page,\nbecause my web browser supports Arial,", "start": 3570.7, "duration": 3.2 }, { "text": "I don't notice anything different.", "start": 3573.9, "duration": 1.44 }, { "text": "But you might imagine if you're using\nmore complex fonts that not all web", "start": 3575.34, "duration": 3.04 }, { "text": "browsers have or support, you\nmight add some backups just", "start": 3578.38, "duration": 2.78 }, { "text": "in case the font you want\nisn't actually available.", "start": 3581.16, "duration": 3.81 }, { "text": "In addition to a font\nfamily, I might also", "start": 3584.97, "duration": 2.01 }, { "text": "specify a font size, how big I want\nthe font to be inside of this div.", "start": 3586.98, "duration": 4.33 }, { "text": "So I can specify that I'd like the\nfont size of this give to be, you know,", "start": 3591.31, "duration": 3.6 }, { "text": "28 pixels, for example,\nsuch that now I refresh it.", "start": 3594.91, "duration": 3.23 }, { "text": "And now, this div appears\nusing larger text.", "start": 3598.14, "duration": 3.48 }, { "text": "And I can also, just\nas like text editors", "start": 3601.62, "duration": 2.22 }, { "text": "let you specify whether you want it\nto be normal text or bolded text,", "start": 3603.84, "duration": 3.81 }, { "text": "I can specify a font\nweight for this div and say", "start": 3607.65, "duration": 3.51 }, { "text": "that in addition to being\nin font Arial in size 28,", "start": 3611.16, "duration": 2.97 }, { "text": "I would also like for the font to\nbe bold, such that now I refresh it,", "start": 3614.13, "duration": 3.96 }, { "text": "and now, the font shows up as bold.", "start": 3618.09, "duration": 2.73 }, { "text": "And using these CSS style sheets,\nwe're able to selectively apply", "start": 3620.82, "duration": 3.57 }, { "text": "the styling to only particular\nparts of the web page.", "start": 3624.39, "duration": 3.48 }, { "text": "If I have another underneath this div\nsome more text down here, for example,", "start": 3627.87, "duration": 5.16 }, { "text": "that additional text\nthat's outside of the div", "start": 3633.03, "duration": 2.73 }, { "text": "isn't going to be affected\nby the CSS styling, such", "start": 3635.76, "duration": 3.12 }, { "text": "that now if I refresh this\npage or some more text", "start": 3638.88, "duration": 2.64 }, { "text": "shows up in that same standard default\nfont provided by my web browser and not", "start": 3641.52, "duration": 4.92 }, { "text": "the custom font that I have\nspecified to apply to only", "start": 3646.44, "duration": 3.06 }, { "text": "this particular part of the HTML page.", "start": 3649.5, "duration": 3.72 }, { "text": "So that now is the ability\nto add fonts to our page too.", "start": 3653.22, "duration": 4.77 }, { "text": "Another thing that we\nmight want to do is", "start": 3657.99, "duration": 1.8 }, { "text": "to be able to add some sort of\nborder around our HTML elements.", "start": 3659.79, "duration": 3.87 }, { "text": "So maybe I want a line to be able to\nseparate this entire part of the page", "start": 3663.66, "duration": 4.11 }, { "text": "from another part of the page.", "start": 3667.77, "duration": 1.53 }, { "text": "So I could add a border by\ngoing to this div and saying,", "start": 3669.3, "duration": 2.95 }, { "text": "let me give this div a border.", "start": 3672.25, "duration": 1.49 }, { "text": "And maybe I want the border to be\nlike a 3 pixel solid black border,", "start": 3673.74, "duration": 5.94 }, { "text": "for instance.", "start": 3679.68, "duration": 0.93 }, { "text": "I can specify how big I\nwant the border to be.", "start": 3680.61, "duration": 2.76 }, { "text": "I can specify whether I want\nthe border to be a solid line", "start": 3683.37, "duration": 2.58 }, { "text": "or a dashed or dotted line.", "start": 3685.95, "duration": 1.68 }, { "text": "And I can specify what color I would\nlike that border to be as well.", "start": 3687.63, "duration": 4.48 }, { "text": "So now, when I refresh\nthis, I now see I have", "start": 3692.11, "duration": 2.18 }, { "text": "a border around this\nentire section, around", "start": 3694.29, "duration": 2.16 }, { "text": "this entire div, inside of my web page.", "start": 3696.45, "duration": 3.72 }, { "text": "And you can imagine these\nborders being helpful for styling", "start": 3700.17, "duration": 2.97 }, { "text": "various different parts of my page.", "start": 3703.14, "duration": 2.05 }, { "text": "So, for example, if we\ngo back to that table", "start": 3705.19, "duration": 2.04 }, { "text": "that we were looking at a moment ago\nwhen we were dealing with oceans, where", "start": 3707.23, "duration": 3.17 }, { "text": "I had Ocean and Pacific\nOcean and Atlantic Ocean,", "start": 3710.4, "duration": 3.0 }, { "text": "this is structured in\nthe format of a table.", "start": 3713.4, "duration": 2.22 }, { "text": "We have rows and columns.", "start": 3715.62, "duration": 1.71 }, { "text": "But it doesn't look great right now.", "start": 3717.33, "duration": 1.89 }, { "text": "I might like to add\nsome styling in order", "start": 3719.22, "duration": 2.4 }, { "text": "to improve the way that this\ntable looks, for example.", "start": 3721.62, "duration": 3.55 }, { "text": "So let's give that a try.", "start": 3725.17, "duration": 1.85 }, { "text": "I'll go ahead and go\nback into table.html,", "start": 3727.02, "duration": 2.73 }, { "text": "that HTML file I was using\nbefore where I had this table.", "start": 3729.75, "duration": 3.21 }, { "text": "And let me now add some style\ninformation to this table.", "start": 3732.96, "duration": 4.17 }, { "text": "I might say that for\nthis table I would like", "start": 3737.13, "duration": 2.1 }, { "text": "to give it a border that is maybe\na 1 pixel solid black border,", "start": 3739.23, "duration": 6.11 }, { "text": "such that now when I refresh the page,\nI have a 1 pixel solid black border", "start": 3745.34, "duration": 4.38 }, { "text": "around the entirety of the table.", "start": 3749.72, "duration": 2.21 }, { "text": "All right, that's great.", "start": 3751.93, "duration": 1.0 }, { "text": "But I also really wanted a border\nin between the rows and the columns", "start": 3752.93, "duration": 3.48 }, { "text": "as well.", "start": 3756.41, "duration": 0.69 }, { "text": "In particular, every\ntable data item, I might", "start": 3757.1, "duration": 2.76 }, { "text": "like to have some additional\nCSS supplied to those too.", "start": 3759.86, "duration": 4.56 }, { "text": "So I might say for\nevery table data cell--", "start": 3764.42, "duration": 2.46 }, { "text": "again td stood for table\ndata, and those were", "start": 3766.88, "duration": 2.7 }, { "text": "the individual cells within my table--", "start": 3769.58, "duration": 2.55 }, { "text": "I might specify that I\nwould like those to also", "start": 3772.13, "duration": 2.16 }, { "text": "have a border that is 1 pixel\nsolid black, such that now I", "start": 3774.29, "duration": 5.68 }, { "text": "refresh the page.", "start": 3779.97, "duration": 1.27 }, { "text": "And now, each of my table data\ncells also has a border around it.", "start": 3781.24, "duration": 4.04 }, { "text": "Now, this applied to the table\ndata cells in the body of my page,", "start": 3785.28, "duration": 3.42 }, { "text": "but it didn't yet apply to\nthese cells up in the heading.", "start": 3788.7, "duration": 3.09 }, { "text": "And that's because those were\nth elements, table headers.", "start": 3791.79, "duration": 5.58 }, { "text": "And so here, we have\na couple of options.", "start": 3797.37, "duration": 2.17 }, { "text": "I could specify, once\nmore, table headers", "start": 3799.54, "duration": 2.78 }, { "text": "I would like to give a border\nof 1 pixel solid black.", "start": 3802.32, "duration": 4.44 }, { "text": "But when I do so, you'll see that it\ndoes create a border around those table", "start": 3806.76, "duration": 3.51 }, { "text": "headers.", "start": 3810.27, "duration": 0.93 }, { "text": "But again, one thing that\nshould be crossing your mind now", "start": 3811.2, "duration": 2.43 }, { "text": "is that there's a fair amount of\nredundancy here, some repeated style", "start": 3813.63, "duration": 3.15 }, { "text": "code that shows up in\nmultiple different places.", "start": 3816.78, "duration": 2.28 }, { "text": "Table data cells in the\nbody of my page, I really", "start": 3819.06, "duration": 3.45 }, { "text": "want to be styled in a very\nsimilar way to table header cells.", "start": 3822.51, "duration": 3.59 }, { "text": "And so it'd be nice if I could somehow\nconsolidate these two different CSS", "start": 3826.1, "duration": 5.05 }, { "text": "selectors, these ways of me saying,\nstyle table data, style table headers.", "start": 3831.15, "duration": 4.47 }, { "text": "I'd like to combine them into one.", "start": 3835.62, "duration": 2.58 }, { "text": "And you can, in fact, do this in CSS.", "start": 3838.2, "duration": 1.89 }, { "text": "There are a number of different CSS\nselectors, ways of choosing elements.", "start": 3840.09, "duration": 4.47 }, { "text": "And one of them is just called\nthe multiple element selector,", "start": 3844.56, "duration": 3.66 }, { "text": "that if I want to select both\ntable data cells and table headers,", "start": 3848.22, "duration": 4.23 }, { "text": "then I can do so by saying td comma\nth and delete these three lines", "start": 3852.45, "duration": 6.78 }, { "text": "down there.", "start": 3859.23, "duration": 1.47 }, { "text": "What these three lines\nare now saying are", "start": 3860.7, "duration": 2.07 }, { "text": "that I would like to style\nall table data cells and table", "start": 3862.77, "duration": 3.6 }, { "text": "headers in the same way.", "start": 3866.37, "duration": 1.45 }, { "text": "And I could even combine table\nif I wanted to for good measure.", "start": 3867.82, "duration": 2.64 }, { "text": "But I'd like to give all of them a\nborder of 1 pixel solid black, such", "start": 3870.46, "duration": 4.56 }, { "text": "that now I refresh it and now I see that\nthey all have this border around them.", "start": 3875.02, "duration": 4.44 }, { "text": "Now, most tables you see on the internet\ndon't have both a table or a border", "start": 3879.46, "duration": 3.62 }, { "text": "around everything on the\ntable and also a border", "start": 3883.08, "duration": 2.7 }, { "text": "around each of the individual cells.", "start": 3885.78, "duration": 2.04 }, { "text": "Usually, those are collapsed\njust into a single line.", "start": 3887.82, "duration": 2.92 }, { "text": "And it turns out that CSS has an\neasy way for you to do this as well.", "start": 3890.74, "duration": 3.54 }, { "text": "I can add a CSS property to the table\ncalled border collapse and just say,", "start": 3894.28, "duration": 5.45 }, { "text": "I would like to collapse all\nof the borders in the table.", "start": 3899.73, "duration": 3.45 }, { "text": "Just going to show you there are many,\nmany different CSS properties, far more", "start": 3903.18, "duration": 3.3 }, { "text": "than we'll be looking at today.", "start": 3906.48, "duration": 1.44 }, { "text": "But they're easy things to\nreference, that you can easily", "start": 3907.92, "duration": 2.37 }, { "text": "look up how to collapse\nborders in a table", "start": 3910.29, "duration": 2.29 }, { "text": "and then find a CSS property like\nthis that you can then use and apply", "start": 3912.58, "duration": 3.62 }, { "text": "to your web page.", "start": 3916.2, "duration": 1.78 }, { "text": "So now I refresh that.", "start": 3917.98, "duration": 1.35 }, { "text": "And now I see that I have a border,\njust a single border, around all", "start": 3919.33, "duration": 3.71 }, { "text": "of the cells in this particular page.", "start": 3923.04, "duration": 3.84 }, { "text": "Next, what I might like to do, though,\nis like add some space around here.", "start": 3926.88, "duration": 3.16 }, { "text": "Like it seems like this text is very\ntight against the border of this table.", "start": 3930.04, "duration": 4.74 }, { "text": "So in order to do so, I\nwant to add some spacing.", "start": 3934.78, "duration": 2.78 }, { "text": "And recall again, do I\nwant margin or padding?", "start": 3937.56, "duration": 2.52 }, { "text": "Margin is spacing around side of the\nborder of a particular HTML element,", "start": 3940.08, "duration": 5.28 }, { "text": "whereas padding is inside of the border.", "start": 3945.36, "duration": 2.56 }, { "text": "So if I want some space\ninside of the border,", "start": 3947.92, "duration": 2.3 }, { "text": "just to space out the text from\nthe border itself, then what I want", "start": 3950.22, "duration": 3.15 }, { "text": "is padding inside of\nall of my table cells.", "start": 3953.37, "duration": 3.36 }, { "text": "So I can say let me add\n5 pixels worth of padding", "start": 3956.73, "duration": 3.48 }, { "text": "inside of all of my table data\ncells and table header cells.", "start": 3960.21, "duration": 4.05 }, { "text": "Refresh the page.", "start": 3964.26, "duration": 1.27 }, { "text": "And now, here's what the\nresulting table looks like.", "start": 3965.53, "duration": 3.11 }, { "text": "Just by adding a little\nbit of CSS specifying what", "start": 3968.64, "duration": 2.79 }, { "text": "border I want around\nthe edge of the page,", "start": 3971.43, "duration": 2.22 }, { "text": "specifying a little bit of padding\ninside of each of the cells,", "start": 3973.65, "duration": 3.3 }, { "text": "my table now looks a whole lot nicer\nthan it did just a few lines of code", "start": 3976.95, "duration": 3.64 }, { "text": "ago when I just had the HTML\nstructure of the page and not the CSS", "start": 3980.59, "duration": 4.34 }, { "text": "to describe how I actually\nwanted that page to be styled.", "start": 3984.93, "duration": 4.98 }, { "text": "And notice again that\nin doing so, we were", "start": 3989.91, "duration": 2.07 }, { "text": "able to use one of these CSS selectors.", "start": 3991.98, "duration": 3.21 }, { "text": "I was able to say that I wanted to use\nthe multiple element selector, which", "start": 3995.19, "duration": 4.14 }, { "text": "is just this comma here, to specify\nthat I would like to apply this styling,", "start": 3999.33, "duration": 4.26 }, { "text": "not just to td's but\nalso to th's as well.", "start": 4003.59, "duration": 4.89 }, { "text": "We'll take a look at some\nadditional examples of CSS selectors", "start": 4008.48, "duration": 3.6 }, { "text": "in just a moment.", "start": 4012.08, "duration": 2.01 }, { "text": "But next, let's turn our attention\nto some more tricky instances", "start": 4014.09, "duration": 3.72 }, { "text": "where we might want to apply styling\nto multiple elements at the same time.", "start": 4017.81, "duration": 4.72 }, { "text": "Let's imagine-- and let's go back to\nstyle.html, where we had some style", "start": 4022.53, "duration": 4.85 }, { "text": "code, where I had one heading.", "start": 4027.38, "duration": 3.01 }, { "text": "I'll call this Heading 1.", "start": 4030.39, "duration": 2.82 }, { "text": "And let's get myself to other\nheadings, Heading 2 and Heading 3.", "start": 4033.21, "duration": 4.59 }, { "text": "All of these now are h1 elements that\nare going to show up the same way,", "start": 4037.8, "duration": 4.71 }, { "text": "such that now if I style and say, I\nwould like all h1s to show up with", "start": 4042.51, "duration": 4.95 }, { "text": "a color of blue, then when I open\nthis page where I have three h1 tags,", "start": 4047.46, "duration": 5.43 }, { "text": "each of which has a color of\nblue, when I open up style.html,", "start": 4052.89, "duration": 5.37 }, { "text": "what I'm going to see\nis something like this--", "start": 4058.26, "duration": 2.3 }, { "text": "three headings, each of which\nhappens to have a color of blue.", "start": 4060.56, "duration": 3.64 }, { "text": "But what would happen now if I wanted\nto style only the first heading.", "start": 4064.2, "duration": 4.23 }, { "text": "I want Heading 1 to be blue.", "start": 4068.43, "duration": 1.84 }, { "text": "But I don't want to style\nHeading 2 and Heading 3.", "start": 4070.27, "duration": 4.25 }, { "text": "How do I do that?", "start": 4074.52, "duration": 1.66 }, { "text": "Well, one thing we could do is\ngo back to the inline styling", "start": 4076.18, "duration": 3.59 }, { "text": "we did a moment ago, where inside\nof h1, I said style color is blue.", "start": 4079.77, "duration": 5.67 }, { "text": "And that would say for just\nthis very first heading,", "start": 4085.44, "duration": 2.76 }, { "text": "I would like that to be blue, but\nnot the other elements at all.", "start": 4088.2, "duration": 4.08 }, { "text": "But this again we decided\nwas not the best design.", "start": 4092.28, "duration": 2.7 }, { "text": "This inline styling, commingling of HTML\nand CSS just gets a little bit messy.", "start": 4094.98, "duration": 5.16 }, { "text": "And it would be nice to be able\nto factor all of our style code", "start": 4100.14, "duration": 2.94 }, { "text": "to a separate part of\nthe page altogether.", "start": 4103.08, "duration": 3.03 }, { "text": "So how do we do this?", "start": 4106.11, "duration": 1.27 }, { "text": "Well, we need some way to uniquely\nreference this particular HTML element.", "start": 4107.38, "duration": 5.41 }, { "text": "And in order to do so, we\ncan given HTML element an ID.", "start": 4112.79, "duration": 4.56 }, { "text": "An ID is just some unique name\nwe give to an HTML element,", "start": 4117.35, "duration": 4.75 }, { "text": "so that we can reference\nit more easily later on.", "start": 4122.1, "duration": 2.96 }, { "text": "Let me just go ahead and\ngive this an ID of Foo.", "start": 4125.06, "duration": 2.54 }, { "text": "It could be any idea you want.", "start": 4127.6, "duration": 1.25 }, { "text": "But Foo is just a generic name here.", "start": 4128.85, "duration": 2.19 }, { "text": "And now, we've given this heading a name\nsuch that in other parts of our page", "start": 4131.04, "duration": 4.17 }, { "text": "or in other code, we can reference\nand find this particular HTML element.", "start": 4135.21, "duration": 5.17 }, { "text": "And in particular now, in the\nstyle section of my web page,", "start": 4140.38, "duration": 3.26 }, { "text": "instead of styling all h1\nelements, I only want to style", "start": 4143.64, "duration": 4.32 }, { "text": "the element that has an ID of Foo.", "start": 4147.96, "duration": 2.67 }, { "text": "IDs are by definition unique.", "start": 4150.63, "duration": 1.62 }, { "text": "There can only be one element in\nthis page that has an ID of Foo,", "start": 4152.25, "duration": 3.56 }, { "text": "otherwise it's not valid HTML.", "start": 4155.81, "duration": 2.35 }, { "text": "And so in order to do so,\nwe're going to use #Foo.", "start": 4158.16, "duration": 2.65 }, { "text": "The hash mark symbol is just CSS's\nway of selecting just something", "start": 4163.43, "duration": 4.06 }, { "text": "with a particular ID.", "start": 4167.49, "duration": 1.73 }, { "text": "So instead of just h1 for\nselecting all of the h1 tags,", "start": 4169.22, "duration": 4.24 }, { "text": "if I want to select\nsomething by its ID, I", "start": 4173.46, "duration": 2.16 }, { "text": "say #Foo to say only style the\nelement that has an ID of Foo", "start": 4175.62, "duration": 5.64 }, { "text": "and give it a color\nof blue, for example.", "start": 4181.26, "duration": 4.26 }, { "text": "So this style code now will find\nsomething with a particular ID", "start": 4185.52, "duration": 3.16 }, { "text": "and give it a style\nto correspond with it,", "start": 4188.68, "duration": 3.28 }, { "text": "such that now if I reload this\npage, only Heading 1 is styled.", "start": 4191.96, "duration": 4.53 }, { "text": "Heading 2 and Heading 3 are not.", "start": 4196.49, "duration": 1.94 }, { "text": "I've been able to name Heading 1,\ngive it a name of Foo, an ID of Foo,", "start": 4198.43, "duration": 4.03 }, { "text": "and then in my style code, just style\nthat particular part of my HTML page.", "start": 4202.46, "duration": 6.91 }, { "text": "Of course, what if I wanted to style\nmultiple, but not all of the headings?", "start": 4209.37, "duration": 4.26 }, { "text": "Like maybe I want to style\nboth Heading 1 and Heading 2.", "start": 4213.63, "duration": 3.84 }, { "text": "Now, I could use a second ID.", "start": 4217.47, "duration": 1.54 }, { "text": "Maybe give us an ID of Bar, for example.", "start": 4219.01, "duration": 2.63 }, { "text": "And then style both the element with\nID Foo and the element with ID Bar.", "start": 4221.64, "duration": 4.53 }, { "text": "But now we're starting\nto add IDs unnecessarily.", "start": 4226.17, "duration": 3.12 }, { "text": "I have too many different names.", "start": 4229.29, "duration": 1.62 }, { "text": "Things can start to\nget messy, especially", "start": 4230.91, "duration": 1.71 }, { "text": "as my web pages start to get bigger.", "start": 4232.62, "duration": 2.37 }, { "text": "So while IDs are a way of giving a\nname to an HTML element that is unique,", "start": 4234.99, "duration": 5.43 }, { "text": "sometimes I want to give a name to\nan HTML element that is not unique,", "start": 4240.42, "duration": 4.17 }, { "text": "some name that can apply to\nmultiple different HTML elements.", "start": 4244.59, "duration": 3.84 }, { "text": "And when we do that,\nwe call that a class.", "start": 4248.43, "duration": 2.88 }, { "text": "An ID is a way of giving a\nunique name to an HTML element,", "start": 4251.31, "duration": 3.54 }, { "text": "while a class is a way of giving\na name to an HTML element that", "start": 4254.85, "duration": 3.27 }, { "text": "might not be unique.", "start": 4258.12, "duration": 0.9 }, { "text": "It might apply it to zero or one or\ntwo or more different HTML elements.", "start": 4259.02, "duration": 5.76 }, { "text": "So here's what that might look like.", "start": 4264.78, "duration": 1.74 }, { "text": "Instead of giving each of these\nh1s an ID that's different,", "start": 4266.52, "duration": 3.54 }, { "text": "I can give each one a class.", "start": 4270.06, "duration": 1.74 }, { "text": "We'll give this a class of Baz,\nagain, just another arbitrary name", "start": 4271.8, "duration": 2.94 }, { "text": "that we've chosen.", "start": 4274.74, "duration": 1.54 }, { "text": "And I'll give this each\none a class of Baz as well.", "start": 4276.28, "duration": 3.93 }, { "text": "They both belong to the same\nclass called Baz, in this case.", "start": 4280.21, "duration": 4.76 }, { "text": "And now, inside of my style code,\nI would like to say just the style", "start": 4284.97, "duration": 3.96 }, { "text": "the elements that are of class Baz.", "start": 4288.93, "duration": 3.05 }, { "text": "And just as we have a\nspecial symbol, the hashtag,", "start": 4291.98, "duration": 2.09 }, { "text": "for styling definitely\nsomething with a particular ID,", "start": 4294.07, "duration": 3.72 }, { "text": "to style everything with a\nparticular class, I can use a dot.", "start": 4297.79, "duration": 3.9 }, { "text": "So dot Baz, in this case, is going\nto style only the elements that", "start": 4301.69, "duration": 4.64 }, { "text": "have a class of Baz.", "start": 4306.33, "duration": 2.71 }, { "text": "So here, I can now say, take all\nof the elements with a class of Baz", "start": 4309.04, "duration": 3.83 }, { "text": "and go ahead and give\nthose a color of blue.", "start": 4312.87, "duration": 5.03 }, { "text": "So now, I have two h1s\nthat belong to class Baz.", "start": 4317.9, "duration": 3.65 }, { "text": "The other h1 does not.", "start": 4321.55, "duration": 1.78 }, { "text": "And I've styled only the\nthings that are of class Baz,", "start": 4323.33, "duration": 3.32 }, { "text": "such that now when I go back to the\npage and refresh the page, my first two", "start": 4326.65, "duration": 3.6 }, { "text": "headings, those do get styled as blue.", "start": 4330.25, "duration": 2.48 }, { "text": "But the third heading\ndoes not, because I've", "start": 4332.73, "duration": 1.84 }, { "text": "applied a class to these two\nelements that does not get", "start": 4334.57, "duration": 2.7 }, { "text": "applied to this third element there.", "start": 4337.27, "duration": 2.95 }, { "text": "So oftentimes, it can\nbe very helpful if you", "start": 4340.22, "duration": 1.97 }, { "text": "have to start to design\nlarger web pages where", "start": 4342.19, "duration": 2.01 }, { "text": "you have multiple different\nelements, some of which", "start": 4344.2, "duration": 2.31 }, { "text": "might be styled in some ways and other\nelements that might be styled similarly", "start": 4346.51, "duration": 3.57 }, { "text": "to one another, you can add IDs\nand classes to your HTML elements", "start": 4350.08, "duration": 4.71 }, { "text": "just to clean up the way\nthat you write your CSS,", "start": 4354.79, "duration": 2.34 }, { "text": "to be able to very specifically\npinpoint one element that you", "start": 4357.13, "duration": 2.97 }, { "text": "want to apply a style to or to apply\nstyling to the entire class of elements", "start": 4360.1, "duration": 5.16 }, { "text": "as well.", "start": 4365.26, "duration": 1.59 }, { "text": "Now, one tricky thing\nyou might imagine now", "start": 4366.85, "duration": 2.46 }, { "text": "is that now we have multiple ways of\nreferencing the exact same element.", "start": 4369.31, "duration": 6.03 }, { "text": "So, for example, if\nyou imagine that I just", "start": 4375.34, "duration": 2.13 }, { "text": "had a single h1, which had an ID\nof Foo, for example, that I've", "start": 4377.47, "duration": 4.95 }, { "text": "named Foo, what would happen if, for\ninstance, I said all of the h1s I", "start": 4382.42, "duration": 5.27 }, { "text": "will like those to be colored red, and\nall of the elements with an ID of Foo,", "start": 4387.69, "duration": 4.72 }, { "text": "or the only element with an ID of Foo,\nI would like that to be colored blue?", "start": 4392.41, "duration": 4.8 }, { "text": "What might happen then?", "start": 4397.21, "duration": 0.96 }, { "text": "These would seem to be\nconflicting, where now suddenly we", "start": 4398.17, "duration": 2.85 }, { "text": "have an h1 style tag that is saying\nI should style h1s in this way,", "start": 4401.02, "duration": 6.09 }, { "text": "but I should style element\nFoo in another way.", "start": 4407.11, "duration": 2.74 }, { "text": "So what happens if I have an h1 whose ID\nis Foo, how do I choose to style that?", "start": 4409.85, "duration": 5.42 }, { "text": "And in order to deal with\nthat we have to start", "start": 4415.27, "duration": 2.07 }, { "text": "to deal with the CSS problem of\nspecificity, of what happens when", "start": 4417.34, "duration": 3.84 }, { "text": "I have multiple different CSS selectors\nthat could apply to the exact same HTML", "start": 4421.18, "duration": 5.82 }, { "text": "element?", "start": 4427.0, "duration": 0.99 }, { "text": "And this often happens when we start\nto add IDs and classes to our elements", "start": 4427.99, "duration": 5.67 }, { "text": "as well.", "start": 4433.66, "duration": 1.24 }, { "text": "So when we deal with specificity,\nspecificity goes in a particular order.", "start": 4434.9, "duration": 3.97 }, { "text": "There's an order of\nprecedence that we can", "start": 4438.87, "duration": 1.93 }, { "text": "follow for determining what\nstyle should ultimately", "start": 4440.8, "duration": 3.12 }, { "text": "be applied to any particular element.", "start": 4443.92, "duration": 2.83 }, { "text": "The first, most powerful--", "start": 4446.75, "duration": 1.85 }, { "text": "most specific way of referencing an\nelement is inline styling, literally", "start": 4448.6, "duration": 4.2 }, { "text": "adding a style equals\nattribute to our HTML elements", "start": 4452.8, "duration": 3.6 }, { "text": "in the way we did way\nat the beginning when", "start": 4456.4, "duration": 1.8 }, { "text": "we were first taking a look at CSS.", "start": 4458.2, "duration": 2.31 }, { "text": "If we associate inline styling\nwith an HTML element, that's", "start": 4460.51, "duration": 3.69 }, { "text": "going to take precedence over any\nstyling that's inside the style", "start": 4464.2, "duration": 3.63 }, { "text": "section of our head of the web page\nor inside of a separate dot CSS file,", "start": 4467.83, "duration": 4.32 }, { "text": "because the reasoning goes, if you\nare literally putting the style", "start": 4472.15, "duration": 4.38 }, { "text": "code attached to the element\nitself, then we probably", "start": 4476.53, "duration": 3.27 }, { "text": "want to apply it to that element.", "start": 4479.8, "duration": 2.55 }, { "text": "After that, specificity goes\nin order of how precisely we", "start": 4482.35, "duration": 5.37 }, { "text": "are identifying an element.", "start": 4487.72, "duration": 1.47 }, { "text": "An ID is a unique way\nto identify an element.", "start": 4489.19, "duration": 2.49 }, { "text": "There is only one element\nwith that particular ID.", "start": 4491.68, "duration": 2.8 }, { "text": "So if I've added style\nto a particular ID,", "start": 4494.48, "duration": 3.08 }, { "text": "that is going to be pretty highly\nvalued in terms of how specific it is.", "start": 4497.56, "duration": 4.14 }, { "text": "Next, we look at classes.", "start": 4501.7, "duration": 1.42 }, { "text": "So if there's no ID\nselector, we look for,", "start": 4503.12, "duration": 2.63 }, { "text": "did we reference the\nelement by its class?", "start": 4505.75, "duration": 2.4 }, { "text": "And if so, then that\ntakes next precedence.", "start": 4508.15, "duration": 3.16 }, { "text": "And otherwise, then we fall back\nto what type of HTML element it is.", "start": 4511.31, "duration": 4.16 }, { "text": "Is it an h1?", "start": 4515.47, "duration": 1.08 }, { "text": "Is it an ordered list?", "start": 4516.55, "duration": 1.35 }, { "text": "Is it a table?", "start": 4517.9, "duration": 1.08 }, { "text": "So in short, the type\nis the least specific.", "start": 4518.98, "duration": 2.29 }, { "text": "Class is slightly more specific.", "start": 4521.27, "duration": 1.82 }, { "text": "ID is more than that.", "start": 4523.09, "duration": 1.42 }, { "text": "And the most specificity we can provide\nis by literally putting the CSS inline", "start": 4524.51, "duration": 4.82 }, { "text": "with the HTML element itself.", "start": 4529.33, "duration": 2.56 }, { "text": "So let's take a look\nat an example of this.", "start": 4531.89, "duration": 2.04 }, { "text": "Let's look at this code, for\nexample, where, for instance, I", "start": 4533.93, "duration": 3.62 }, { "text": "have a div, whose ID is Foo, inside of\nwhich I'm just saying the word hello.", "start": 4537.55, "duration": 4.83 }, { "text": "And the CSS code that I've included\nhere is I've said for all div,", "start": 4542.38, "duration": 3.63 }, { "text": "I would like to give\nthose a color of blue.", "start": 4546.01, "duration": 2.31 }, { "text": "Obviously, in that case,\nthere's nothing conflicting.", "start": 4548.32, "duration": 2.4 }, { "text": "What we're going to see is we're\ngoing to see the word Hello.", "start": 4550.72, "duration": 2.55 }, { "text": "And we're going to see\nthe word Hello in blue.", "start": 4553.27, "duration": 3.3 }, { "text": "But what happens now if we add anything\nwith ID Foo should be colored red?", "start": 4556.57, "duration": 5.1 }, { "text": "Well, because ID has higher specificity\nthan just an individual tag,", "start": 4561.67, "duration": 4.74 }, { "text": "well, then next, what we're going to say\nis that this Hello is going to show up", "start": 4566.41, "duration": 3.3 }, { "text": "is red.", "start": 4569.71, "duration": 0.87 }, { "text": "The ID is more specific.", "start": 4570.58, "duration": 1.8 }, { "text": "And so this element is going\nto show up red instead.", "start": 4572.38, "duration": 3.54 }, { "text": "And it doesn't matter\nwhat order these are in.", "start": 4575.92, "duration": 1.92 }, { "text": "It's not that the later\none takes precedence.", "start": 4577.84, "duration": 1.9 }, { "text": "If I were to flip these around, where\nID of Foo, color red, div color blue", "start": 4579.74, "duration": 4.67 }, { "text": "is in that order, it's still going\nto show up as red, because this ID", "start": 4584.41, "duration": 3.93 }, { "text": "selector is more specific than just the\nname div, which is the name of the HTML", "start": 4588.34, "duration": 6.66 }, { "text": "element that happens to be there.", "start": 4595.0, "duration": 2.38 }, { "text": "And so as you start to develop\nmore sophisticated style sheets,", "start": 4597.38, "duration": 2.84 }, { "text": "you might find that\nsome of your CSS code", "start": 4600.22, "duration": 1.89 }, { "text": "is going to conflict with each other.", "start": 4602.11, "duration": 1.56 }, { "text": "And that's where it's important to\nbear in mind how these specificity", "start": 4603.67, "duration": 2.87 }, { "text": "rules work to know as you\nadd style to your elements", "start": 4606.54, "duration": 3.4 }, { "text": "how are they actually\ngoing to end up showing up.", "start": 4609.94, "duration": 4.06 }, { "text": "Now, we've seen a\ncouple of CSS selectors", "start": 4614.0, "duration": 1.83 }, { "text": "now in terms of selecting a\nsingle element, selecting an ID,", "start": 4615.83, "duration": 3.54 }, { "text": "selecting a class, selecting\nmultiple elements as well.", "start": 4619.37, "duration": 3.3 }, { "text": "It turns out, there are a\nnumber of other CSS selectors", "start": 4622.67, "duration": 2.55 }, { "text": "that we can use too.", "start": 4625.22, "duration": 1.29 }, { "text": "So we saw, for example, the\nmultiple element selector,", "start": 4626.51, "duration": 3.15 }, { "text": "like td comma th for selecting\ntable data but also table headers.", "start": 4629.66, "duration": 5.26 }, { "text": "But there's a number of other selectors.", "start": 4634.92, "duration": 1.67 }, { "text": "Here is just a sampling of ones.", "start": 4636.59, "duration": 1.89 }, { "text": "You can specify like\ndescendants or children.", "start": 4638.48, "duration": 2.73 }, { "text": "So if I only want to style\ndivs that are inside of tables,", "start": 4641.21, "duration": 3.78 }, { "text": "or I only want the style lists\nthat are inside of certain classes,", "start": 4644.99, "duration": 4.17 }, { "text": "I can use these defendant\nand child selectors", "start": 4649.16, "duration": 2.25 }, { "text": "to add styling and\nthose particular ways.", "start": 4651.41, "duration": 2.79 }, { "text": "And there are a number of other\nCSS selectors we can add as well.", "start": 4654.2, "duration": 3.89 }, { "text": "And we'll go ahead and\nexplore a couple of these,", "start": 4658.09, "duration": 2.05 }, { "text": "just to give you a sample of how some\nof the CSS selectors can actually work.", "start": 4660.14, "duration": 5.14 }, { "text": "And we'll start by taking a look\nat the descendent selector, which", "start": 4665.28, "duration": 3.98 }, { "text": "is used to select all of the\nelements that are descendants", "start": 4669.26, "duration": 3.18 }, { "text": "of some other element, for example.", "start": 4672.44, "duration": 2.92 }, { "text": "So let's go ahead and create a new\nfile, that I'll call descendant.html,", "start": 4675.36, "duration": 7.07 }, { "text": "that again, we'll start\nwith the same code.", "start": 4682.43, "duration": 3.15 }, { "text": "And inside the body of this\npage, I want an ordered list", "start": 4685.58, "duration": 3.36 }, { "text": "that maybe has a list item\n1 and maybe a list item 2.", "start": 4688.94, "duration": 5.43 }, { "text": "And it turns out with lists in HTML, you\ncan nest lists inside of other lists.", "start": 4694.37, "duration": 5.55 }, { "text": "Maybe you've seen bullet points where\nthere's like nested bullets inside", "start": 4699.92, "duration": 3.09 }, { "text": "of other bullet points.", "start": 4703.01, "duration": 1.17 }, { "text": "I can do that here.", "start": 4704.18, "duration": 1.11 }, { "text": "I can add an unordered list and\ncreate a sublist, like sublist item 1", "start": 4705.29, "duration": 6.06 }, { "text": "and sublist item 2.", "start": 4711.35, "duration": 3.12 }, { "text": "And maybe down here,\nhere's another list item,", "start": 4714.47, "duration": 4.13 }, { "text": "such as that now I\nhave a couple of items,", "start": 4718.6, "duration": 2.05 }, { "text": "but some that are inside\nof an unordered sub list.", "start": 4720.65, "duration": 3.75 }, { "text": "Let's go ahead and\nopen up descendent.html", "start": 4724.4, "duration": 3.18 }, { "text": "and see what that looks like.", "start": 4727.58, "duration": 2.02 }, { "text": "So here's what we have.", "start": 4729.6, "duration": 1.01 }, { "text": "We have a list item 1, list\nitem 2, another list item", "start": 4730.61, "duration": 3.09 }, { "text": "that is probably actually list item 3.", "start": 4733.7, "duration": 5.0 }, { "text": "So we have three items.", "start": 4738.7, "duration": 1.02 }, { "text": "But inside of list item 2,\nI have an unordered list.", "start": 4739.72, "duration": 3.81 }, { "text": "Let's imagine, for example,\nthat I wanted to only style", "start": 4743.53, "duration": 4.59 }, { "text": "these sublist items\nas a particular color.", "start": 4748.12, "duration": 2.93 }, { "text": "That maybe I want those\nto be blue, for example.", "start": 4751.05, "duration": 3.05 }, { "text": "If in the style section\nof my web page, I", "start": 4754.1, "duration": 2.81 }, { "text": "say that I would like for all list\nitems to be styled blue, well then--", "start": 4756.91, "duration": 5.73 }, { "text": "not styled, colored blue rather--", "start": 4762.64, "duration": 2.52 }, { "text": "then what I'm going\nto see when I refresh", "start": 4765.16, "duration": 1.95 }, { "text": "the page is that all of the\nitems are going to be blue", "start": 4767.11, "duration": 3.75 }, { "text": "instead of just the two sublist items.", "start": 4770.86, "duration": 3.0 }, { "text": "But I could instead say that, you\nknow what, I only want list items that", "start": 4773.86, "duration": 4.65 }, { "text": "are children of unordered lists.", "start": 4778.51, "duration": 2.49 }, { "text": "And I can do direct children\nusing this greater than symbol", "start": 4781.0, "duration": 2.46 }, { "text": "to say that only if there is a ul that\nimmediately contains an li within it,", "start": 4783.46, "duration": 5.23 }, { "text": "then I would like for\nthat to be colored blue.", "start": 4788.69, "duration": 3.12 }, { "text": "And now, if I refresh that, now you'll\nsee that the ordered items, list item", "start": 4791.81, "duration": 4.19 }, { "text": "1, 2, 3, those do not get\ncolored, but only the list items", "start": 4796.0, "duration": 4.14 }, { "text": "that are inside of the\nunordered list that", "start": 4800.14, "duration": 1.95 }, { "text": "are directly children\nof that unordered list", "start": 4802.09, "duration": 2.88 }, { "text": "actually get the CSS styling applied.", "start": 4804.97, "duration": 2.94 }, { "text": "This greater than symbol here is\nspecifying immediate children.", "start": 4807.91, "duration": 4.37 }, { "text": "I could get rid of it, ul li, like\nthis, and this would also work.", "start": 4812.28, "duration": 3.73 }, { "text": "You still see sublist item 1 and 2.", "start": 4816.01, "duration": 2.24 }, { "text": "But this is a more general selector\ncalled the descendent selector", "start": 4818.25, "duration": 3.55 }, { "text": "that selects all descendant elements.", "start": 4821.8, "duration": 1.89 }, { "text": "So they might not be\nthe children elements.", "start": 4823.69, "duration": 1.8 }, { "text": "They might be grandchildren\nelement, so to speak,", "start": 4825.49, "duration": 2.34 }, { "text": "if those children elements\nhave other children that", "start": 4827.83, "duration": 2.76 }, { "text": "are attached to them as well.", "start": 4830.59, "duration": 1.3 }, { "text": "Again, for all of this,\nit's helpful to begin", "start": 4831.89, "duration": 1.88 }, { "text": "to think about things in terms of\nthat Document Object Model, that DOM", "start": 4833.77, "duration": 3.9 }, { "text": "structure, that tree that represented\nhow all of our various different HTML", "start": 4837.67, "duration": 4.77 }, { "text": "elements are related to one another.", "start": 4842.44, "duration": 3.77 }, { "text": "So next up, we can begin to take a\nlook at some of the other selectors", "start": 4846.21, "duration": 2.92 }, { "text": "that we have access to.", "start": 4849.13, "duration": 1.48 }, { "text": "So one of the selectors\nmight be something", "start": 4850.61, "duration": 2.24 }, { "text": "like modifying only on a specific\nattribute of a particular HTML element.", "start": 4852.85, "duration": 5.91 }, { "text": "So we can use the attribute\nselector for that.", "start": 4858.76, "duration": 2.92 }, { "text": "I'll create a new file called\nattribute.html, where here,", "start": 4861.68, "duration": 5.04 }, { "text": "let's go ahead and\ncreate a unordered list.", "start": 4866.72, "duration": 5.1 }, { "text": "That's going to have a\nnumber of different links", "start": 4871.82, "duration": 2.0 }, { "text": "to various different websites.", "start": 4873.82, "duration": 1.62 }, { "text": "So here's a list item that is\ngoing to be a link to Google.", "start": 4875.44, "duration": 3.93 }, { "text": "So I'll link to google.com\nand say, Google.", "start": 4879.37, "duration": 3.99 }, { "text": "And I'll go ahead and add\na link to facebook.com.", "start": 4883.36, "duration": 3.84 }, { "text": "Call that Facebook.", "start": 4887.2, "duration": 2.04 }, { "text": "And I'll go ahead and add a link\nto amazon.com and call that Amazon.", "start": 4889.24, "duration": 6.06 }, { "text": "And let's imagine for a moment that I\nonly wanted to style the Facebook link,", "start": 4895.3, "duration": 4.09 }, { "text": "like I want to really\nhighlight the Facebook link,", "start": 4899.39, "duration": 2.09 }, { "text": "tell people to click on\nthat one as by coloring it", "start": 4901.48, "duration": 2.59 }, { "text": "in entirely different color.", "start": 4904.07, "duration": 2.3 }, { "text": "Well, to style things\nnormally, I would say something", "start": 4906.37, "duration": 3.15 }, { "text": "like links should be colored,\nyou know, blue, for example.", "start": 4909.52, "duration": 4.25 }, { "text": "They're colored blue by default,\nbut I could be explicit about it", "start": 4913.77, "duration": 2.71 }, { "text": "and say, links should\nbe color blue like,", "start": 4916.48, "duration": 1.7 }, { "text": "such that now when I\nopen up attribute.html", "start": 4918.18, "duration": 3.95 }, { "text": "all the links are colored blue.", "start": 4922.13, "duration": 2.96 }, { "text": "But I could also say,\nI would like links that", "start": 4925.09, "duration": 2.73 }, { "text": "have an href attribute of\nfacebook.com, I would like", "start": 4927.82, "duration": 5.55 }, { "text": "those links to be colored red instead.", "start": 4933.37, "duration": 4.86 }, { "text": "So this square bracket\nnotation I can use", "start": 4938.23, "duration": 2.07 }, { "text": "to specify a particular\nattribute of an HTML element.", "start": 4940.3, "duration": 3.57 }, { "text": "Only anchor tags, a tags, who's\nhref is equal to facebook.com,", "start": 4943.87, "duration": 3.89 }, { "text": "those should be the\nonly ones colored red.", "start": 4947.76, "duration": 3.41 }, { "text": "So now, when I refresh this,\nI now see that Facebook", "start": 4951.17, "duration": 2.72 }, { "text": "is a link that is now colored red,\ninstead of colored blue, because I've", "start": 4953.89, "duration": 3.72 }, { "text": "been very specific about\npicking an attribute", "start": 4957.61, "duration": 2.37 }, { "text": "that I would like to use in order to\nreference that particular HTML element.", "start": 4959.98, "duration": 5.71 }, { "text": "And we can use CSS selectors in more\npowerful ways too, maybe not just", "start": 4965.69, "duration": 4.04 }, { "text": "to style a particular\nelement always, but to style", "start": 4969.73, "duration": 2.88 }, { "text": "an element only under certain\nconditions or only when", "start": 4972.61, "duration": 3.21 }, { "text": "an element is in a particular state.", "start": 4975.82, "duration": 2.43 }, { "text": "And this is very often\ndone for something", "start": 4978.25, "duration": 1.71 }, { "text": "like when you hover over something, when\nyou hover over a button and something", "start": 4979.96, "duration": 4.14 }, { "text": "pops out, or you hover over something\nand it changes color slightly.", "start": 4984.1, "duration": 3.49 }, { "text": "We can begin to do this by adding\nwhat we call a pseudo class to a CSS", "start": 4987.59, "duration": 4.7 }, { "text": "selector.", "start": 4992.29, "duration": 0.87 }, { "text": "So let's take a look\nat an example of that", "start": 4993.16, "duration": 2.01 }, { "text": "to see how we can modify an element\nwhen a user hovers their cursor", "start": 4995.17, "duration": 4.44 }, { "text": "over that element, for example.", "start": 4999.61, "duration": 2.28 }, { "text": "So I'll go ahead and open up a new file,\nhover.html, where here, I'll go ahead", "start": 5001.89, "duration": 5.49 }, { "text": "and inside the body of the\npage just give myself a button.", "start": 5007.38, "duration": 3.99 }, { "text": "This button is going to say, Click Me.", "start": 5011.37, "duration": 3.54 }, { "text": "And let's add some style to the button.", "start": 5014.91, "duration": 1.99 }, { "text": "By default, buttons show\nup as fairly simple buttons", "start": 5016.9, "duration": 2.43 }, { "text": "that just look something like this.", "start": 5019.33, "duration": 1.58 }, { "text": "I might like to add a little bit more\nto this button and say, you know what,", "start": 5020.91, "duration": 3.3 }, { "text": "let's add some style to the button,\nand give it a width of 200 pixels,", "start": 5024.21, "duration": 4.8 }, { "text": "a height of 50 pixels, a\nfont size of 24 pixels,", "start": 5029.01, "duration": 4.95 }, { "text": "and maybe a background\ncolor of green, for example.", "start": 5033.96, "duration": 4.11 }, { "text": "So I've specified some size information,\nhow big I'd like the font to be,", "start": 5038.07, "duration": 3.87 }, { "text": "and also a background color for\nthe button, such that now here's", "start": 5041.94, "duration": 3.33 }, { "text": "what that button looks like.", "start": 5045.27, "duration": 1.17 }, { "text": "Shrink it down a little bit.", "start": 5046.44, "duration": 1.16 }, { "text": "It says, Click Me.", "start": 5047.6, "duration": 1.69 }, { "text": "But many buttons, especially nowadays,\nthey give you a little bit of feedback.", "start": 5049.29, "duration": 3.96 }, { "text": "You hover over them, and they\nchange their color slightly.", "start": 5053.25, "duration": 3.09 }, { "text": "How do they do that?", "start": 5056.34, "duration": 1.18 }, { "text": "Well, often it's using\na CSS pseudo class,", "start": 5057.52, "duration": 3.2 }, { "text": "where I can say button\ncolon hover, meaning", "start": 5060.72, "duration": 3.99 }, { "text": "when I am hovering\nover a button, then I'd", "start": 5064.71, "duration": 3.57 }, { "text": "like you to change the\nbackground color to orange,", "start": 5068.28, "duration": 3.91 }, { "text": "for example, some other color.", "start": 5072.19, "duration": 2.43 }, { "text": "So now, I specified that by\ndefault normally for a button,", "start": 5074.62, "duration": 3.45 }, { "text": "your background color\nshould be green, but when", "start": 5078.07, "duration": 2.37 }, { "text": "the button is being\nhovered over instead,", "start": 5080.44, "duration": 2.28 }, { "text": "now change the background\ncolor to orange,", "start": 5082.72, "duration": 2.76 }, { "text": "such that now when I open up\nthis page and go to Click Me,", "start": 5085.48, "duration": 3.0 }, { "text": "if I hover over the button, the\ncolor of the button changes.", "start": 5088.48, "duration": 3.69 }, { "text": "Normally green changes to orange.", "start": 5092.17, "duration": 2.34 }, { "text": "And so that is a very powerful feature\nthat we have access to as well.", "start": 5094.51, "duration": 4.72 }, { "text": "All right, so now we've seen how\nwe can use various different CSS", "start": 5099.23, "duration": 3.08 }, { "text": "selectors to very precisely define how\nwe want our web pages to be styled.", "start": 5102.31, "duration": 4.71 }, { "text": "But one other thing we can use\nCSS for that's quite powerful", "start": 5107.02, "duration": 2.82 }, { "text": "is responsive design.", "start": 5109.84, "duration": 1.86 }, { "text": "And responsive design\nis all about making sure", "start": 5111.7, "duration": 2.43 }, { "text": "that our web pages look good, no matter\nhow you're looking at the web page.", "start": 5114.13, "duration": 3.57 }, { "text": "Nowadays, people aren't always looking\nat web pages on their computers.", "start": 5117.7, "duration": 3.11 }, { "text": "But they're looking at web pages on\ntheir mobile phones or on their tablets", "start": 5120.81, "duration": 3.13 }, { "text": "as well.", "start": 5123.94, "duration": 0.85 }, { "text": "And it's important as we begin to\ndesign web pages that we design our web", "start": 5124.79, "duration": 3.2 }, { "text": "pages in a responsive way.", "start": 5127.99, "duration": 1.98 }, { "text": "So we'll look at a\nnumber of different ways", "start": 5129.97, "duration": 1.8 }, { "text": "we can implement responsive\ndesign in our web pages,", "start": 5131.77, "duration": 3.24 }, { "text": "starting with the\ndiscussion of the viewport.", "start": 5135.01, "duration": 3.21 }, { "text": "And what the viewport is is the viewport\nis the visual part of the screen", "start": 5138.22, "duration": 4.41 }, { "text": "that the user can actually see.", "start": 5142.63, "duration": 1.91 }, { "text": "So the viewport is this\nentire area of the web page", "start": 5144.54, "duration": 3.22 }, { "text": "that displays content to the user.", "start": 5147.76, "duration": 2.4 }, { "text": "So one question you might ask is, what's\ngoing to happen when you take this page", "start": 5150.16, "duration": 3.48 }, { "text": "and translate it onto a mobile screen?", "start": 5153.64, "duration": 3.27 }, { "text": "Well, one thing that many\nmobile devices do by default", "start": 5156.91, "duration": 2.85 }, { "text": "is treat their viewport as though it\nis the same width as a computer screen.", "start": 5159.76, "duration": 4.65 }, { "text": "Because not all web pages are optimized\nfrom all device mobile devices,", "start": 5164.41, "duration": 3.66 }, { "text": "you want to make sure that on a\nmobile device you can see everything.", "start": 5168.07, "duration": 2.88 }, { "text": "And so many phones will\ntake a web page like this", "start": 5170.95, "duration": 3.12 }, { "text": "and just shrink it down to\nfit onto a mobile screen that", "start": 5174.07, "duration": 3.87 }, { "text": "looks a little something like that.", "start": 5177.94, "duration": 1.86 }, { "text": "Now, of course, that's probably not\nreally what we want it to look like.", "start": 5179.8, "duration": 3.0 }, { "text": "Ideally, we want our page to\nadapt to different sized screens.", "start": 5182.8, "duration": 3.69 }, { "text": "Maybe we want the heading\nand the image and the text,", "start": 5186.49, "duration": 2.4 }, { "text": "if that's what these are, to grow a\nlittle bit to fill that entire screen.", "start": 5188.89, "duration": 4.17 }, { "text": "And so one simple thing we can do\nis just to add a little line of code", "start": 5193.06, "duration": 4.32 }, { "text": "to our HTML inside the head section of\nour page that controls the viewport.", "start": 5197.38, "duration": 5.16 }, { "text": "This line of code here is providing some\nmetadata to our HTML page and saying,", "start": 5202.54, "duration": 4.92 }, { "text": "I would like you to\nchange the viewport to be", "start": 5207.46, "duration": 2.52 }, { "text": "specifically the width of the device.", "start": 5209.98, "duration": 3.09 }, { "text": "By default, many phones will\nuse a viewport that's actually", "start": 5213.07, "duration": 2.55 }, { "text": "wider than the width\nof the device, treat", "start": 5215.62, "duration": 1.99 }, { "text": "it as if they're loading\na page in a computer,", "start": 5217.61, "duration": 2.09 }, { "text": "and then shrinking it down to\nthe size of a mobile device.", "start": 5219.7, "duration": 3.12 }, { "text": "If you and your web\npage specify, though,", "start": 5222.82, "duration": 2.07 }, { "text": "that you want the viewport\nto be just the device width,", "start": 5224.89, "duration": 2.91 }, { "text": "oftentimes a page is going to look a\nwhole lot better on a mobile device.", "start": 5227.8, "duration": 5.05 }, { "text": "But in addition to just\nadding a line like this,", "start": 5232.85, "duration": 2.0 }, { "text": "there are other actual\nchanges we can make", "start": 5234.85, "duration": 1.83 }, { "text": "to our page to make it look a\nlittle better on different screens.", "start": 5236.68, "duration": 3.51 }, { "text": "And one of those has to\ndo with media queries.", "start": 5240.19, "duration": 2.67 }, { "text": "And media queries are\nall about controlling", "start": 5242.86, "duration": 2.37 }, { "text": "how our page is going to look depending\non how we render that particular page,", "start": 5245.23, "duration": 4.83 }, { "text": "or what size screen we're\nrendering that page on.", "start": 5250.06, "duration": 2.76 }, { "text": "So let's take a look\nat an example of how", "start": 5252.82, "duration": 2.13 }, { "text": "we might go about using\nmedia queries in order", "start": 5254.95, "duration": 3.06 }, { "text": "to control what a page actually looks\nlike depending on what type of page", "start": 5258.01, "duration": 5.52 }, { "text": "or what type of browser\nwe're using to view it.", "start": 5263.53, "duration": 3.05 }, { "text": "So I'll go ahead and open a new\nfile that I'll call responsive.html,", "start": 5266.58, "duration": 3.76 }, { "text": "because we're going to try and\nbuild a responsive web page now.", "start": 5270.34, "duration": 3.24 }, { "text": "And now, I'll go ahead and\ninside the body of my page", "start": 5273.58, "duration": 3.21 }, { "text": "just include a big heading that says\nWelcome to My Web Page, for example.", "start": 5276.79, "duration": 5.86 }, { "text": "And just to demonstrate what you\ncan do now with responsive design", "start": 5282.65, "duration": 3.68 }, { "text": "is I could say something like,\nlet me add a style tag here,", "start": 5286.33, "duration": 4.2 }, { "text": "where I want to say that if the size\nof the screen is a certain width,", "start": 5290.53, "duration": 4.74 }, { "text": "then I want to style\nthe page in one way.", "start": 5295.27, "duration": 2.16 }, { "text": "And if the size of the\npage is a different width,", "start": 5297.43, "duration": 2.5 }, { "text": "then I might want to style\nthe page in a different way.", "start": 5299.93, "duration": 2.3 }, { "text": "You might imagine that\nas you shrink the screen", "start": 5302.23, "duration": 1.65 }, { "text": "you want to move\nelements around in order", "start": 5303.88, "duration": 1.7 }, { "text": "to rearrange them to make the\npage just look a little bit nicer", "start": 5305.58, "duration": 2.92 }, { "text": "on a mobile screen.", "start": 5308.5, "duration": 1.26 }, { "text": "So we'll do a very simple example\nof just changing the color depending", "start": 5309.76, "duration": 4.02 }, { "text": "on the size of the screen.", "start": 5313.78, "duration": 1.81 }, { "text": "So let me specify now in a media query.", "start": 5315.59, "duration": 2.72 }, { "text": "And the syntax for media\nquery looks like this.", "start": 5318.31, "duration": 2.35 }, { "text": "I'm going to use the @\nsymbol and say media and then", "start": 5320.66, "duration": 3.17 }, { "text": "specify for what type of media I\nwould like to apply this query.", "start": 5323.83, "duration": 4.51 }, { "text": "I can say something like, if\nthe minimum width of the page", "start": 5328.34, "duration": 3.68 }, { "text": "is 600 pixels, in other words,\nif the width of the page", "start": 5332.02, "duration": 2.91 }, { "text": "is 600 pixels or anything\nlarger than 600 pixels, well,", "start": 5334.93, "duration": 4.38 }, { "text": "then go ahead and take the body and\ngive it a background color of red.", "start": 5339.31, "duration": 7.54 }, { "text": "But then I could also add\nanother media query and say,", "start": 5346.85, "duration": 2.61 }, { "text": "you know what, for this media query let\nme give it a max width of 599 pixels,", "start": 5349.46, "duration": 5.46 }, { "text": "meaning if the size of the\nscreen is 599 pixels or fewer,", "start": 5354.92, "duration": 4.65 }, { "text": "then maybe I'd like to take the body\nand give it a background color of blue,", "start": 5359.57, "duration": 5.13 }, { "text": "for example.", "start": 5364.7, "duration": 1.76 }, { "text": "So now let's take a look at what\nhappens when I take this page", "start": 5366.46, "duration": 2.59 }, { "text": "and actually open it\nand see what's going on.", "start": 5369.05, "duration": 2.65 }, { "text": "I'll open up responsive.html.", "start": 5371.7, "duration": 2.66 }, { "text": "And here's what I see normally.", "start": 5374.36, "duration": 1.44 }, { "text": "I see a red web page, because my\nscreen is longer than 600 pixels wide.", "start": 5375.8, "duration": 4.42 }, { "text": "But notice what happens\nas a shrink this web page.", "start": 5380.22, "duration": 2.27 }, { "text": "If I go ahead and shrink it,\nlooking at it on a smaller screen,", "start": 5382.49, "duration": 3.6 }, { "text": "eventually it turns to blue.", "start": 5386.09, "duration": 2.61 }, { "text": "If it's above 600 pixels\nwide, it's going to be red.", "start": 5388.7, "duration": 2.97 }, { "text": "If it's below 600 pixels wide,\nthe color changes to blue.", "start": 5391.67, "duration": 4.45 }, { "text": "So we're able to now use these media\nqueries to really fine tune control", "start": 5396.12, "duration": 3.56 }, { "text": "how our page is going to look on\nvarious different types of devices.", "start": 5399.68, "duration": 4.23 }, { "text": "If it's on a big screen, maybe you want\nthe elements to look a certain way.", "start": 5403.91, "duration": 3.16 }, { "text": "If it's a smaller screen,\nmaybe they'll look differently.", "start": 5407.07, "duration": 2.38 }, { "text": "And you don't just need to\ncontrol a background color.", "start": 5409.45, "duration": 2.25 }, { "text": "You can control any CSS property you\nwant just by using these media queries.", "start": 5411.7, "duration": 4.48 }, { "text": "You can say on a big screen, you want\ncertain amounts of spacing or padding.", "start": 5416.18, "duration": 3.67 }, { "text": "You can even hide elements\non smaller screens", "start": 5419.85, "duration": 1.97 }, { "text": "if you want to by using a particular CSS\nproperty called the display property.", "start": 5421.82, "duration": 4.44 }, { "text": "That controls whether or not\nan element is even visible.", "start": 5426.26, "duration": 3.24 }, { "text": "And ultimately put together, this can\nhelp to make your pages a little bit", "start": 5429.5, "duration": 3.48 }, { "text": "more responsive.", "start": 5432.98, "duration": 1.05 }, { "text": "And there are a number\nof different media", "start": 5434.03, "duration": 1.71 }, { "text": "queries that we can apply\nto our page as well.", "start": 5435.74, "duration": 2.1 }, { "text": "We can check to see whether a mobile\ndevice is vertical or landscape.", "start": 5437.84, "duration": 3.81 }, { "text": "We can check to see whether the user\nis viewing the page on their computer", "start": 5441.65, "duration": 3.12 }, { "text": "screen or if they've tried to print\nout the contents of the page as well.", "start": 5444.77, "duration": 3.58 }, { "text": "So there are a number\nof different options", "start": 5448.35, "duration": 1.75 }, { "text": "that we have to really control\nhow a page is going to look.", "start": 5450.1, "duration": 4.0 }, { "text": "There are some other tools we have\nin our toolbox as well, though,", "start": 5454.1, "duration": 2.88 }, { "text": "for dealing with mobile responsiveness.", "start": 5456.98, "duration": 2.04 }, { "text": "And one of the tools built\ninto the latest version of CSS", "start": 5459.02, "duration": 3.06 }, { "text": "is something called flexbox.", "start": 5462.08, "duration": 1.97 }, { "text": "And flexbox is quite helpful if we\nhave multiple elements that we're all", "start": 5464.05, "duration": 3.88 }, { "text": "trying to display on the same\npage at the same time that", "start": 5467.93, "duration": 3.93 }, { "text": "might overflow if we're not careful\nabout how we do responsive design.", "start": 5471.86, "duration": 3.44 }, { "text": "If we're really not\ncareful-- let's imagine", "start": 5475.3, "duration": 1.8 }, { "text": "I have six elements that show\nup on my computer's monitor.", "start": 5477.1, "duration": 2.86 }, { "text": "When you translate that\nto a mobile screen,", "start": 5479.96, "duration": 1.92 }, { "text": "you can imagine they might all\nshrink down so that they're", "start": 5481.88, "duration": 2.41 }, { "text": "barely visible, something like this.", "start": 5484.29, "duration": 2.0 }, { "text": "This is probably not\nwhat we want if we're", "start": 5486.29, "duration": 1.77 }, { "text": "trying to design a mobile\nresponsive page, for example.", "start": 5488.06, "duration": 3.44 }, { "text": "So you might imagine, how can\nwe do a little bit better?", "start": 5491.5, "duration": 2.98 }, { "text": "Well, another thing we could\ndo is take these elements", "start": 5494.48, "duration": 2.76 }, { "text": "and go ahead and keep\nthem the same size,", "start": 5497.24, "duration": 2.16 }, { "text": "but make you have to\nscroll through them.", "start": 5499.4, "duration": 2.1 }, { "text": "This is now slightly better.", "start": 5501.5, "duration": 1.23 }, { "text": "The elements that are\nat least still visible.", "start": 5502.73, "duration": 1.62 }, { "text": "And they're large enough\non the screen, but it", "start": 5504.35, "duration": 1.77 }, { "text": "would be nice not to have\nto scroll through them.", "start": 5506.12, "duration": 2.04 }, { "text": "What would be really nice is given\nthat we have all this extra space,", "start": 5508.16, "duration": 3.18 }, { "text": "I would like to be able\nto wrap around elements", "start": 5511.34, "duration": 2.67 }, { "text": "if I don't have enough\nspace for them, such", "start": 5514.01, "duration": 2.01 }, { "text": "that if I'm translating these\nsix elements to a mobile screen,", "start": 5516.02, "duration": 2.97 }, { "text": "they translate, but I get\nthem in like two rows,", "start": 5518.99, "duration": 2.55 }, { "text": "for example, three on\nthe top and three below.", "start": 5521.54, "duration": 2.67 }, { "text": "And flexbox is an easy way to\nbe able to implement something", "start": 5524.21, "duration": 3.27 }, { "text": "like this inside of our web pages.", "start": 5527.48, "duration": 2.71 }, { "text": "So let's take a look at\nwhat that might actually", "start": 5530.19, "duration": 2.0 }, { "text": "look like to add flexbox to our page.", "start": 5532.19, "duration": 3.31 }, { "text": "So I'll go ahead and create a\nnew file called flexbox.html.", "start": 5535.5, "duration": 3.98 }, { "text": "We'll start with the same HTML code.", "start": 5539.48, "duration": 2.13 }, { "text": "And now, inside of the body, I'm\ngoing to create first a div that", "start": 5541.61, "duration": 6.78 }, { "text": "is going to be called the container.", "start": 5548.39, "duration": 2.65 }, { "text": "And we're creating a\ncontainer, because we're", "start": 5551.04, "duration": 1.88 }, { "text": "going to specifically say that\neverything inside the container,", "start": 5552.92, "duration": 3.52 }, { "text": "I would like to add flexbox\nto, to be able to wrap it", "start": 5556.44, "duration": 2.39 }, { "text": "around so that things can go onto\nmultiple lines if I ever need to.", "start": 5558.83, "duration": 4.05 }, { "text": "And now, let me just\nadd some sample text.", "start": 5562.88, "duration": 1.77 }, { "text": "So this is some sample text\ninside of a div to demo flexbox.", "start": 5564.65, "duration": 6.21 }, { "text": "And I'll go ahead and repeat\nthis may maybe like 12 times.", "start": 5570.86, "duration": 2.56 }, { "text": "And I'll number each one.", "start": 5573.42, "duration": 1.05 }, { "text": "Here's 1, 2, 3, 4, and\nI'll number all the rest.", "start": 5574.47, "duration": 5.15 }, { "text": "This is just to give a demonstration\nof what these elements could actually", "start": 5579.62, "duration": 3.87 }, { "text": "look like.", "start": 5583.49, "duration": 1.83 }, { "text": "Ideally, these would be different\npieces of content, though.", "start": 5585.32, "duration": 3.88 }, { "text": "So now, inside of my\nstyle tag, here's what", "start": 5589.2, "duration": 3.48 }, { "text": "I'm going to say, just to demonstrate.", "start": 5592.68, "duration": 2.1 }, { "text": "I'll say, take the ID container--\nagain the hashtag specifies get me", "start": 5594.78, "duration": 3.78 }, { "text": "something with a particular ID.", "start": 5598.56, "duration": 2.13 }, { "text": "And I want to display it using flexbox.", "start": 5600.69, "duration": 3.81 }, { "text": "And in particular, I would\nlike to use the flex wrap", "start": 5604.5, "duration": 2.34 }, { "text": "property to say if there's not enough\nroom at the end of a line for all", "start": 5606.84, "duration": 3.81 }, { "text": "of the elements, go ahead and\nwrap around those elements", "start": 5610.65, "duration": 2.98 }, { "text": "onto the next line instead.", "start": 5613.63, "duration": 3.41 }, { "text": "And now, I can specify some\nadditional CSS properties", "start": 5617.04, "duration": 3.48 }, { "text": "for the divs inside of the container.", "start": 5620.52, "duration": 3.06 }, { "text": "So I can say, for the container all\nof the div inside of that container,", "start": 5623.58, "duration": 4.56 }, { "text": "again using this child\nselector to get all", "start": 5628.14, "duration": 2.31 }, { "text": "of the divs that are\ninside of the container,", "start": 5630.45, "duration": 2.91 }, { "text": "I can add some CSS to that too.", "start": 5633.36, "duration": 2.08 }, { "text": "I can say, let's give these a background\ncolor of like a shade of green.", "start": 5635.44, "duration": 3.92 }, { "text": "I can give them a particular\nfont, maybe 20 pixel font.", "start": 5639.36, "duration": 3.66 }, { "text": "Give them some margin and\npadding, just to add some space.", "start": 5643.02, "duration": 3.45 }, { "text": "And maybe each one is going\nto be 200 pixels wide.", "start": 5646.47, "duration": 3.45 }, { "text": "So just adding some spacing\nto those individual divs,", "start": 5649.92, "duration": 2.88 }, { "text": "the important part is\nthis right here, where", "start": 5652.8, "duration": 2.49 }, { "text": "I've said that this whole container\nis going to be a flexbox container.", "start": 5655.29, "duration": 3.91 }, { "text": "And I'd like to wrap around\nelements if you ever reach the end.", "start": 5659.2, "duration": 4.11 }, { "text": "So now, I'll open up flexbox.html.", "start": 5663.31, "duration": 3.37 }, { "text": "And so here, I now see 12 elements\nthat are on multiple lines.", "start": 5666.68, "duration": 4.52 }, { "text": "But notice what happens\nas I shrink the page.", "start": 5671.2, "duration": 2.51 }, { "text": "If there isn't room for all of them,\nelements move onto other lines.", "start": 5673.71, "duration": 3.96 }, { "text": "Now, there's only three\nelements in any particular row.", "start": 5677.67, "duration": 2.56 }, { "text": "Now, there's only two elements\non any particular row.", "start": 5680.23, "duration": 2.35 }, { "text": "And so I can use flexbox\nto very well adapt myself", "start": 5682.58, "duration": 3.63 }, { "text": "to different sized screens.", "start": 5686.21, "duration": 1.12 }, { "text": "And no matter whether you're looking at\nthis on a big screen or a small screen,", "start": 5687.33, "duration": 3.51 }, { "text": "the content is still going to look good,\nbecause I'm able to adapt responsively", "start": 5690.84, "duration": 4.5 }, { "text": "to whatever might be happening.", "start": 5695.34, "duration": 2.02 }, { "text": "So this is one layout paradigm that\nexists within CSS, this flexbox layout.", "start": 5697.36, "duration": 4.61 }, { "text": "There are other layouts\nthat exist as well.", "start": 5701.97, "duration": 2.04 }, { "text": "One common one is the\ngrid layout for anytime", "start": 5704.01, "duration": 2.43 }, { "text": "you want to arrange things\nin a particular grid, where", "start": 5706.44, "duration": 2.82 }, { "text": "maybe certain columns\nneed to be certain widths,", "start": 5709.26, "duration": 2.07 }, { "text": "but others can maybe be a\nlittle bit more flexible.", "start": 5711.33, "duration": 3.0 }, { "text": "I'll show one example of that too, just\nto give you a demonstration of what", "start": 5714.33, "duration": 3.24 }, { "text": "that grid layout might look like.", "start": 5717.57, "duration": 2.5 }, { "text": "So here's grid.html, where I'll go\nahead and inside the body of this page,", "start": 5720.07, "duration": 5.69 }, { "text": "give myself a div.", "start": 5725.76, "duration": 2.1 }, { "text": "I'll give it an ID of grid.", "start": 5727.86, "duration": 3.51 }, { "text": "And then let me just add\ndiv class equals grid item.", "start": 5731.37, "duration": 4.8 }, { "text": "Again, a class, because there\nmight be multiple items,", "start": 5736.17, "duration": 3.15 }, { "text": "but I'll go ahead and just create\na whole bunch of grid items", "start": 5739.32, "duration": 2.81 }, { "text": "and number each one, so 2, 3,\n4, 5, 6, 7, 8, 9, 10, 11, 12.", "start": 5742.13, "duration": 7.24 }, { "text": "So I have a whole bunch of grid items\ninside of a div whose ID is grid.", "start": 5749.37, "duration": 5.19 }, { "text": "And now, I'd like to\nadd some style here.", "start": 5754.56, "duration": 3.84 }, { "text": "I'll say for the grid, let's\ngive it a background color.", "start": 5758.4, "duration": 3.61 }, { "text": "Maybe the background\ncolor should be green.", "start": 5762.01, "duration": 2.88 }, { "text": "Display is going to be grid.", "start": 5764.89, "duration": 1.86 }, { "text": "I want this to show up as a grid.", "start": 5766.75, "duration": 1.74 }, { "text": "And now, there are a couple\nof attributes or properties", "start": 5768.49, "duration": 3.09 }, { "text": "that I'm going to specify here.", "start": 5771.58, "duration": 1.48 }, { "text": "Maybe I want some padding\naround the grid first.", "start": 5773.06, "duration": 2.0 }, { "text": "But the important grid\nproperties are grid column gap.", "start": 5775.06, "duration": 4.59 }, { "text": "How much space goes between\neach of the columns?", "start": 5779.65, "duration": 3.3 }, { "text": "Maybe I'll say like 20 pixels.", "start": 5782.95, "duration": 2.16 }, { "text": "Likewise there is also a grid row gap.", "start": 5785.11, "duration": 2.07 }, { "text": "How much space goes between\neach of the rows of the grid?", "start": 5787.18, "duration": 2.94 }, { "text": "Maybe I'll say 10 pixels here.", "start": 5790.12, "duration": 2.11 }, { "text": "And then finally, grid template\ncolumns is a way for me", "start": 5792.23, "duration": 4.19 }, { "text": "to specify how many columns\nthere are going to be", "start": 5796.42, "duration": 3.09 }, { "text": "and how wide should each\nof those columns be.", "start": 5799.51, "duration": 2.55 }, { "text": "So if I want maybe three columns,\nI can specify that the first column", "start": 5802.06, "duration": 4.23 }, { "text": "should be 200 pixels.", "start": 5806.29, "duration": 1.93 }, { "text": "The second column should\nalso be 200 pixels.", "start": 5808.22, "duration": 2.81 }, { "text": "And the third column can\nbe automatically sized,", "start": 5811.03, "duration": 2.88 }, { "text": "just grow or shrink to fill the screen.", "start": 5813.91, "duration": 2.45 }, { "text": "So we'll say auto.", "start": 5816.36, "duration": 1.52 }, { "text": "So first column 200 pixels,\nsecond column 200 pixels,", "start": 5817.88, "duration": 3.62 }, { "text": "third column just do it automatically.", "start": 5821.5, "duration": 3.18 }, { "text": "And now, for all of the\ngrid items, well, those I", "start": 5824.68, "duration": 3.66 }, { "text": "can add some styling to as well.", "start": 5828.34, "duration": 1.92 }, { "text": "I'll give them a\nbackground color of white,", "start": 5830.26, "duration": 1.8 }, { "text": "just to distinguish them, and also give\nthem some font size and some padding", "start": 5832.06, "duration": 5.66 }, { "text": "and maybe center them as well.", "start": 5837.72, "duration": 1.66 }, { "text": "So just adding some additional\nCSS properties in order", "start": 5839.38, "duration": 2.97 }, { "text": "to make it display the way I want to.", "start": 5842.35, "duration": 1.62 }, { "text": "But the important ones to care\nabout here are display is grid.", "start": 5843.97, "duration": 3.93 }, { "text": "And then I'm specifying,\nhere is how the grid", "start": 5847.9, "duration": 2.58 }, { "text": "should be laid out, how\nmuch space between columns,", "start": 5850.48, "duration": 2.28 }, { "text": "how much space between rows, and how\nwide are each of those rows going", "start": 5852.76, "duration": 4.05 }, { "text": "to be.", "start": 5856.81, "duration": 1.2 }, { "text": "Now, if I open up, grid.html,\nhere's what that grid looks like.", "start": 5858.01, "duration": 4.92 }, { "text": "I now have a first\ncolumn 200 pixels wide,", "start": 5862.93, "duration": 2.84 }, { "text": "a second column also 200\npixels wide, and a third column", "start": 5865.77, "duration": 3.61 }, { "text": "that's going to resize\ndynamically based on how wide", "start": 5869.38, "duration": 2.85 }, { "text": "or how narrow my screen happens to be.", "start": 5872.23, "duration": 2.1 }, { "text": "So as I shrink the screen, the\nthird column shrinks with it.", "start": 5874.33, "duration": 3.15 }, { "text": "As I grow the screen, it also\ngrows alongside with how big", "start": 5877.48, "duration": 4.62 }, { "text": "this window happens to be.", "start": 5882.1, "duration": 3.13 }, { "text": "And so flexbox and grid are\nsome very powerful tools", "start": 5885.23, "duration": 2.79 }, { "text": "that we can use and\njust to make it easier", "start": 5888.02, "duration": 2.07 }, { "text": "for us to be able to use\nmobile responsive design,", "start": 5890.09, "duration": 3.21 }, { "text": "to be able to make sure\nthat our pages look good", "start": 5893.3, "duration": 2.46 }, { "text": "no matter what kind of\nbrowser or what kind of device", "start": 5895.76, "duration": 3.27 }, { "text": "the user is using in\norder to look at our page.", "start": 5899.03, "duration": 2.73 }, { "text": "But it turns out that\nexists a lot of libraries", "start": 5901.76, "duration": 2.43 }, { "text": "out there that do a lot of this for us,\nsome people that have already written", "start": 5904.19, "duration": 3.42 }, { "text": "CSS code to make our text look\ngood, to make our buttons look good,", "start": 5907.61, "duration": 3.48 }, { "text": "in order to make sure that\nthings are mobile responsive.", "start": 5911.09, "duration": 2.34 }, { "text": "And one of those is called Bootstrap.", "start": 5913.43, "duration": 2.46 }, { "text": "Bootstrap was a very\npopular CSS library that we", "start": 5915.89, "duration": 2.34 }, { "text": "can use in order to use\nsome styling that they", "start": 5918.23, "duration": 3.12 }, { "text": "have written, such that we don't need\nto write all the styling from scratch.", "start": 5921.35, "duration": 3.96 }, { "text": "So this is what Bootstrap's\nwebsite looks like.", "start": 5925.31, "duration": 1.96 }, { "text": "I'll go ahead and show\nit to you now just", "start": 5927.27, "duration": 1.7 }, { "text": "to give you a sampling for\nwhat's available inside", "start": 5928.97, "duration": 2.13 }, { "text": "of a library like Bootstrap.", "start": 5931.1, "duration": 2.43 }, { "text": "If I go to getbootstrap.com,\nhere's Bootstrap's website.", "start": 5933.53, "duration": 5.54 }, { "text": "And if I go to their documentation\non this first link here,", "start": 5939.07, "duration": 3.4 }, { "text": "I can look at all of the Bootstrap\ncomponents that I'm given access to.", "start": 5942.47, "duration": 3.62 }, { "text": "These are things like\nalerts, for example.", "start": 5946.09, "duration": 2.43 }, { "text": "That here's an alert that's\nstyled in a very particular way.", "start": 5948.52, "duration": 2.64 }, { "text": "It's in a specific font.", "start": 5951.16, "duration": 1.17 }, { "text": "It's got a certain amount of\npadding and certain colors.", "start": 5952.33, "duration": 2.61 }, { "text": "And if I want to just copy this alert,\nonce I've used Bootstrap's code,", "start": 5954.94, "duration": 4.05 }, { "text": "I can just apply\ncertain classes to a div", "start": 5958.99, "duration": 3.54 }, { "text": "and Bootstrap will handle the process\nof applying the right styles for me.", "start": 5962.53, "duration": 3.36 }, { "text": "I don't need to write all of these\nstyles by myself from scratch.", "start": 5965.89, "duration": 3.17 }, { "text": "Bootstrap's written a lot\nof the styling already.", "start": 5969.06, "duration": 3.67 }, { "text": "So how do you actually\ngo about using Bootstrap?", "start": 5972.73, "duration": 2.42 }, { "text": "Well, to get started\nwith Bootstrap, all you", "start": 5975.15, "duration": 1.84 }, { "text": "need to do is copy the CSS\nlink that Bootstrap gives you", "start": 5976.99, "duration": 3.72 }, { "text": "to the top of your file.", "start": 5980.71, "duration": 1.63 }, { "text": "So if I take the CSS link and then\ngo back to something like hello.html,", "start": 5982.34, "duration": 4.73 }, { "text": "which you'll recall originally looked\nsomething like this, just Hello World,", "start": 5987.07, "duration": 5.16 }, { "text": "I can add some Bootstrap\nto it to say, all", "start": 5992.23, "duration": 2.58 }, { "text": "right, I would like\nto take this HTML file", "start": 5994.81, "duration": 4.41 }, { "text": "and apply Bootstrap styling to it\nto make it look a little bit nicer.", "start": 5999.22, "duration": 4.06 }, { "text": "So I refreshed the page.", "start": 6003.28, "duration": 1.16 }, { "text": "And now, you'll notice Bootstrap's\nchosen a custom font for me", "start": 6004.44, "duration": 2.82 }, { "text": "just to make things look a little\nnicer in Bootstrap's own eyes.", "start": 6007.26, "duration": 3.64 }, { "text": "And now, if I want to\nadd Bootstrap elements,", "start": 6010.9, "duration": 2.39 }, { "text": "I can say, all right, let\nme go to their components.", "start": 6013.29, "duration": 3.28 }, { "text": "And I want to add an alert.", "start": 6016.57, "duration": 1.31 }, { "text": "I can just copy their alert code.", "start": 6017.88, "duration": 2.33 }, { "text": "Here's their alert code for a primary\nalert, an alert that looks blue.", "start": 6020.21, "duration": 4.45 }, { "text": "And I can just inside the body of\nmy page go ahead and add an alert,", "start": 6024.66, "duration": 4.85 }, { "text": "and maybe change the text to\nhere is my alert, for example.", "start": 6029.51, "duration": 5.65 }, { "text": "Now, when I reload hello.html, I\nnow see an alert that shows up,", "start": 6035.16, "duration": 4.5 }, { "text": "styled according to Bootstrap styling.", "start": 6039.66, "duration": 2.82 }, { "text": "And again, I can change that styling\njust by changing these classes.", "start": 6042.48, "duration": 4.54 }, { "text": "So a primary alert shows up as blue.", "start": 6047.02, "duration": 2.0 }, { "text": "A success alert shows up as green.", "start": 6049.02, "duration": 1.62 }, { "text": "A danger alert is red.", "start": 6050.64, "duration": 1.42 }, { "text": "So if I want to give a danger alert--\nthe user is doing something wrong", "start": 6052.06, "duration": 2.96 }, { "text": "on the web page, for example--", "start": 6055.02, "duration": 1.56 }, { "text": "I can change alert primary here inside\nmy HTML to something like alert danger", "start": 6056.58, "duration": 5.22 }, { "text": "instead.", "start": 6061.8, "duration": 1.08 }, { "text": "And now when I refresh this\npage, I now see the alert", "start": 6062.88, "duration": 2.73 }, { "text": "shows up as red instead of blue.", "start": 6065.61, "duration": 2.91 }, { "text": "So Bootstrap gives us access to a\nlot of these various different types", "start": 6068.52, "duration": 3.48 }, { "text": "of components, different ways of adding\nbreadcrumbs and alerts and carousels", "start": 6072.0, "duration": 4.29 }, { "text": "and other elements to our page just to\nmake it easy to make our page look good", "start": 6076.29, "duration": 3.78 }, { "text": "very, very quickly without having\nto worry too much about writing", "start": 6080.07, "duration": 2.88 }, { "text": "our own CSS, because Bootstrap's\nwritten a lot of that for us.", "start": 6082.95, "duration": 3.8 }, { "text": "Bootstrap even includes\na way to make sure", "start": 6086.75, "duration": 2.44 }, { "text": "that web pages are mobile\nresponsive using something", "start": 6089.19, "duration": 2.61 }, { "text": "called Bootstrap's column model.", "start": 6091.8, "duration": 2.94 }, { "text": "So I'll show you an example of that now.", "start": 6094.74, "duration": 1.84 }, { "text": "Bootstrap divides its page\ninto 12 distinct columns.", "start": 6096.58, "duration": 5.07 }, { "text": "So one thing I can do\nis I've pulled this up", "start": 6101.65, "duration": 2.09 }, { "text": "in an example I have in advanced\ncalled column zero.html.", "start": 6103.74, "duration": 3.87 }, { "text": "Notice that inside of\nthe body of my page now,", "start": 6107.61, "duration": 2.73 }, { "text": "I have a div whose class is container\nand then a div whose class is row.", "start": 6110.34, "duration": 5.13 }, { "text": "And Bootstrap divides every\nrow into a 12-unit column.", "start": 6115.47, "duration": 4.84 }, { "text": "So here, for example,\nI have a whole bunch", "start": 6120.31, "duration": 1.79 }, { "text": "of divs that are each 3-unit columns.", "start": 6122.1, "duration": 3.06 }, { "text": "So if I have four 3-unit\ncolumns, that will take up", "start": 6125.16, "duration": 3.09 }, { "text": "a total amount of space\nequal to 12, meaning", "start": 6128.25, "duration": 2.88 }, { "text": "filling up the entirety of the screen.", "start": 6131.13, "duration": 2.83 }, { "text": "So if I now open up source column\nzero.html, here's what that looks like.", "start": 6133.96, "duration": 6.14 }, { "text": "I have four columns, each\nof which is of width 3.", "start": 6140.1, "duration": 3.6 }, { "text": "And as a result, as I\nshrink it, those columns", "start": 6143.7, "duration": 2.76 }, { "text": "will automatically resize to\nmake sure that they're always", "start": 6146.46, "duration": 2.79 }, { "text": "the appropriate size.", "start": 6149.25, "duration": 1.5 }, { "text": "Now, as long as they add up to 12,\nthey don't only to be the same size.", "start": 6150.75, "duration": 4.09 }, { "text": "So, for example, if I only wanted\nthree columns, instead of four,", "start": 6154.84, "duration": 3.8 }, { "text": "I could get rid of the fourth\ncolumn by deleting those rows.", "start": 6158.64, "duration": 3.73 }, { "text": "And maybe change the second column\ninstead of being a column of size 3,", "start": 6162.37, "duration": 4.34 }, { "text": "let's make it a column of size 6.", "start": 6166.71, "duration": 1.83 }, { "text": "So that's a length 6 column instead.", "start": 6168.54, "duration": 3.03 }, { "text": "And now if I refresh\nthe page, now suddenly I", "start": 6171.57, "duration": 2.61 }, { "text": "see three columns where\nthe middle one is twice", "start": 6174.18, "duration": 3.03 }, { "text": "as large as the ones on either end.", "start": 6177.21, "duration": 2.13 }, { "text": "And as I shrink this down, I can\nsee that it shrinks down as well.", "start": 6179.34, "duration": 4.91 }, { "text": "And one of the advantages\nof using Bootstrap columns", "start": 6184.25, "duration": 2.57 }, { "text": "is that they too can\nbe mobile responsive.", "start": 6186.82, "duration": 2.4 }, { "text": "They too can wrap around other\nlines if they ever need to.", "start": 6189.22, "duration": 3.81 }, { "text": "So, for example, let me\npull up columns one.html.", "start": 6193.03, "duration": 2.83 }, { "text": "Here, for example, I have a row.", "start": 6198.53, "duration": 2.27 }, { "text": "And let's take a look at\nwhat's going on in here.", "start": 6200.8, "duration": 2.05 }, { "text": "Recall that every row in Bootstrap\nis divided up into 12-column units.", "start": 6202.85, "duration": 5.04 }, { "text": "But Bootstrap, in addition to letting\nme specify how many units a column", "start": 6207.89, "duration": 3.51 }, { "text": "should take up, also lets me\nspecify how many units that column", "start": 6211.4, "duration": 3.45 }, { "text": "should take up depending\non the size of the screen.", "start": 6214.85, "duration": 3.25 }, { "text": "So if I'm on a large\nscreen, as indicated by LG,", "start": 6218.1, "duration": 3.95 }, { "text": "this is saying that on\na large screen, this div", "start": 6222.05, "duration": 2.97 }, { "text": "should take up 3 units of space.", "start": 6225.02, "duration": 2.34 }, { "text": "And this div should also\ntake up 3 units of space.", "start": 6227.36, "duration": 2.42 }, { "text": "And for each of these four\ndivs, on a large screen,", "start": 6229.78, "duration": 2.98 }, { "text": "each will take up 3 of the\ntotal 12 units of space.", "start": 6232.76, "duration": 3.66 }, { "text": "So they'll all show up on one row.", "start": 6236.42, "duration": 2.91 }, { "text": "What happens on a small screen, though?", "start": 6239.33, "duration": 2.4 }, { "text": "Well, here col sm, for\ncolumn on a small screen,", "start": 6241.73, "duration": 3.72 }, { "text": "I've said on a small screen\neach column should only", "start": 6245.45, "duration": 2.49 }, { "text": "take up 6 units of space, 6, or half,\nof the total 12 that I have in the row.", "start": 6247.94, "duration": 5.7 }, { "text": "And so I use up 6 here,\n6 here for a total", "start": 6253.64, "duration": 2.16 }, { "text": "of 12 in one row, which means\nthe next two, also a size 6,", "start": 6255.8, "duration": 4.29 }, { "text": "need to go on to a second row.", "start": 6260.09, "duration": 2.13 }, { "text": "And Bootstrap is smart\nenough to do this math for me", "start": 6262.22, "duration": 2.55 }, { "text": "and figure out how exactly these\nelements should ultimately be laid out.", "start": 6264.77, "duration": 4.44 }, { "text": "So now if I open up columns 1.html and\nsee what's there, on a large screen,", "start": 6269.21, "duration": 8.21 }, { "text": "I see four columns, all in the same row.", "start": 6277.42, "duration": 2.91 }, { "text": "But as I shrink down\nto a smaller screen,", "start": 6280.33, "duration": 1.92 }, { "text": "eventually we'll see that things change.", "start": 6282.25, "duration": 3.15 }, { "text": "I now see the third and fourth\nsections move down onto the second row,", "start": 6285.4, "duration": 4.14 }, { "text": "because on a smaller screen\nnow, when the window is smaller,", "start": 6289.54, "duration": 3.9 }, { "text": "now I only have the ability to show\ntwo elements in any particular row.", "start": 6293.44, "duration": 3.91 }, { "text": "So I get to on the first row and\nthen two on the row underneath that.", "start": 6297.35, "duration": 5.14 }, { "text": "So all in all, there are\na lot of different ways", "start": 6302.49, "duration": 2.32 }, { "text": "now that we can use CSS in order to make\nsure our pages are mobile responsive.", "start": 6304.81, "duration": 4.07 }, { "text": "We can use Bootstrap\ncolumn model to make", "start": 6308.88, "duration": 2.25 }, { "text": "sure the columns move around whenever\na size of the window shrinks or grows.", "start": 6311.13, "duration": 4.35 }, { "text": "We can also use things like\nflexbox and the grid model,", "start": 6315.48, "duration": 2.49 }, { "text": "writing our own CSS to make sure\nthat our page is responsive depending", "start": 6317.97, "duration": 4.29 }, { "text": "on the size of the screen that the\nuser happens to be using in order", "start": 6322.26, "duration": 3.3 }, { "text": "to visit our website page.", "start": 6325.56, "duration": 1.69 }, { "text": "So these are some of the very powerful\nfeatures that we get using just CSS.", "start": 6327.25, "duration": 5.06 }, { "text": "But one thing you might imagine is that\nas we begin to write more and more CSS,", "start": 6332.31, "duration": 3.84 }, { "text": "there's going to be more and more\nrepetition, things that appear again", "start": 6336.15, "duration": 3.81 }, { "text": "and again and again.", "start": 6339.96, "duration": 1.55 }, { "text": "And we've already seen some ways that\nwe can minimize redundancy in CSS.", "start": 6341.51, "duration": 3.43 }, { "text": "We've seen how we can move CSS into\nthe style section of our web page.", "start": 6344.94, "duration": 4.38 }, { "text": "We've even seen how we can move\nCSS to an entirely different file.", "start": 6349.32, "duration": 4.15 }, { "text": "However, what we haven't yet seen is how\nto deal with other types of redundancy.", "start": 6353.47, "duration": 5.12 }, { "text": "And so let's take a look\nat an example of that now.", "start": 6358.59, "duration": 3.0 }, { "text": "Let's imagine, for example,\nthat I want to style", "start": 6361.59, "duration": 2.31 }, { "text": "multiple different elements in different\nways, but using some common properties.", "start": 6363.9, "duration": 6.28 }, { "text": "So, for example, let me create a\nnew file that I'll, in this case,", "start": 6370.18, "duration": 2.75 }, { "text": "call variables.html.", "start": 6372.93, "duration": 2.49 }, { "text": "And you'll see why in a moment.", "start": 6375.42, "duration": 1.86 }, { "text": "I'll go ahead and copy\nhello.html, but I'll get rid", "start": 6377.28, "duration": 2.58 }, { "text": "of all this Bootstrap inside of it.", "start": 6379.86, "duration": 2.81 }, { "text": "Let's imagine that here I have in\nmaybe two list, an ordered list", "start": 6382.67, "duration": 4.67 }, { "text": "and an unordered list,\nwhere my unordered list has", "start": 6387.34, "duration": 5.07 }, { "text": "an ordered item, maybe\nthree unordered items,", "start": 6392.41, "duration": 4.11 }, { "text": "and my ordered list also\nhas three ordered items.", "start": 6396.52, "duration": 5.25 }, { "text": "Again, just for sake\nof demonstration, I'm", "start": 6401.77, "duration": 1.86 }, { "text": "showing that we have\nthese two lists now.", "start": 6403.63, "duration": 2.13 }, { "text": "And I'll open up\nvariables.html just to give you", "start": 6405.76, "duration": 3.42 }, { "text": "a sense for what that could look like.", "start": 6409.18, "duration": 3.09 }, { "text": "We have three unordered\nitems in an unordered list,", "start": 6412.27, "duration": 2.82 }, { "text": "three ordered items in our ordered list.", "start": 6415.09, "duration": 3.09 }, { "text": "Let's imagine I wanted to style\nthese a little bit differently.", "start": 6418.18, "duration": 3.28 }, { "text": "Maybe inside the style\nsection of my page", "start": 6421.46, "duration": 2.33 }, { "text": "I want to style the unordered list\nto have a font size of 14 pixels", "start": 6423.79, "duration": 5.13 }, { "text": "and maybe a color of red.", "start": 6428.92, "duration": 2.34 }, { "text": "And my ordered list, I would like that\nto have a font size of maybe larger, 18", "start": 6431.26, "duration": 4.47 }, { "text": "pixels, but also a color of red.", "start": 6435.73, "duration": 2.2 }, { "text": "I want to keep the same\ncolor for all the text,", "start": 6437.93, "duration": 2.3 }, { "text": "but I want the font\nsizes to be different.", "start": 6440.23, "duration": 2.97 }, { "text": "Now, if I refresh this\npage, here's what I see.", "start": 6443.2, "duration": 2.19 }, { "text": "They are indeed of different sizes.", "start": 6445.39, "duration": 1.6 }, { "text": "The ordered list items are larger\nthan the unordered list items.", "start": 6446.99, "duration": 3.71 }, { "text": "And they're all red.", "start": 6450.7, "duration": 1.66 }, { "text": "But there was some\nredundancy, some repetition", "start": 6452.36, "duration": 2.15 }, { "text": "that was introduced when\nI was writing my CSS code.", "start": 6454.51, "duration": 3.0 }, { "text": "In particular when I\nwas writing my CSS code,", "start": 6457.51, "duration": 3.51 }, { "text": "I've repeated this\nusage of the color red.", "start": 6461.02, "duration": 2.7 }, { "text": "If I ever want to change the color\nfrom red to blue, for example,", "start": 6463.72, "duration": 2.88 }, { "text": "I'm going to have to change my\ncode in two different places.", "start": 6466.6, "duration": 3.66 }, { "text": "Ultimately, I'd just like for my CSS\nto be a little bit more powerful.", "start": 6470.26, "duration": 4.28 }, { "text": "And so that brings us to our last topic\ntoday, which is a language called Sass.", "start": 6474.54, "duration": 4.54 }, { "text": "And Sass is a language that is\nessentially an extension to CSS.", "start": 6479.08, "duration": 3.78 }, { "text": "It adds additional\nfeatures to what CSS has", "start": 6482.86, "duration": 2.46 }, { "text": "to offer, just to make\nit a little bit more", "start": 6485.32, "duration": 1.98 }, { "text": "powerful for us to be able to use\nand manipulate CSS in a way that's", "start": 6487.3, "duration": 3.72 }, { "text": "going to be faster and\nremove some of the repetition", "start": 6491.02, "duration": 3.33 }, { "text": "that we might have\nhad in CSS previously.", "start": 6494.35, "duration": 2.58 }, { "text": "And one of the key features of Sass\nis the ability to have variables.", "start": 6496.93, "duration": 5.26 }, { "text": "So let's take a look at\nan example of this now.", "start": 6502.19, "duration": 2.6 }, { "text": "I'm going to create a new file,\nnormally when we created our CSS files,", "start": 6504.79, "duration": 3.6 }, { "text": "we called them like\nvariables.css, something", "start": 6508.39, "duration": 3.0 }, { "text": "dot CSS to stand for a CSS file.", "start": 6511.39, "duration": 3.12 }, { "text": "Sass is a different language, though.", "start": 6514.51, "duration": 2.04 }, { "text": "So it's going to require\na different extension.", "start": 6516.55, "duration": 2.22 }, { "text": "We're going to conventionally use dot\nscss to stand for this is a Sass file.", "start": 6518.77, "duration": 6.55 }, { "text": "So here is now variables.scss.", "start": 6525.32, "duration": 3.26 }, { "text": "And now what I can do in Sass is\nI can actually create variables", "start": 6528.58, "duration": 3.1 }, { "text": "in the same way that we could create\nvariables in a programming language,", "start": 6531.68, "duration": 3.05 }, { "text": "like Python, which we'll soon see.", "start": 6534.73, "duration": 2.01 }, { "text": "CSS normally doesn't\nsupport variables, but Sass", "start": 6536.74, "duration": 2.55 }, { "text": "is going to give us that power.", "start": 6539.29, "duration": 1.86 }, { "text": "In Sass, all variables\nbegin with a dollar sign.", "start": 6541.15, "duration": 3.1 }, { "text": "So I can create a variable $color\nto create a variable called color.", "start": 6544.25, "duration": 5.02 }, { "text": "And I can say the variable called\ncolor is going to be equal to red.", "start": 6549.27, "duration": 4.33 }, { "text": "So this line here, line\n1, is my way of telling", "start": 6553.6, "duration": 2.52 }, { "text": "Sass I'd like to create\na variable called color", "start": 6556.12, "duration": 2.46 }, { "text": "and I'd like for its value to be red.", "start": 6558.58, "duration": 3.45 }, { "text": "And now, I can add the\nsame styling I had before.", "start": 6562.03, "duration": 2.19 }, { "text": "I can just use normal CSS\nand say for an unordered list", "start": 6564.22, "duration": 3.15 }, { "text": "I'd like the font size to be 14 pixels.", "start": 6567.37, "duration": 2.61 }, { "text": "But the color, instead of saying red\nhere, I can use the name of a variable.", "start": 6569.98, "duration": 5.25 }, { "text": "I can say $color to mean go ahead and\nuse the value of the variable color", "start": 6575.23, "duration": 6.15 }, { "text": "as the color for this unordered list.", "start": 6581.38, "duration": 2.97 }, { "text": "Then for an ordered list, I'll\nalso say font size 18 pixels", "start": 6584.35, "duration": 4.56 }, { "text": "and say color should also be\nthis variable called color.", "start": 6588.91, "duration": 4.77 }, { "text": "By using a variable, I've\nremoved the repetition.", "start": 6593.68, "duration": 2.85 }, { "text": "Rather than having the word red show\nup in multiple places in my code", "start": 6596.53, "duration": 3.31 }, { "text": "where I would need to change it\ntwice if I ever needed to change it,", "start": 6599.84, "duration": 2.84 }, { "text": "now I have defined the variable once.", "start": 6602.68, "duration": 2.25 }, { "text": "And I only ever need to\nchange it in one place", "start": 6604.93, "duration": 2.31 }, { "text": "if I ever need to make modifications\nto this particular file.", "start": 6607.24, "duration": 4.09 }, { "text": "So now, let's try and link this file.", "start": 6611.33, "duration": 3.41 }, { "text": "We'll go back to variables.html.", "start": 6614.74, "duration": 2.58 }, { "text": "Instead of putting the style code here,\nI'll go ahead and link a style sheet", "start": 6617.32, "duration": 7.21 }, { "text": "and say, the href should\nbe variables.scss,", "start": 6624.53, "duration": 3.66 }, { "text": "because that's the file\nwhere my styling exists.", "start": 6628.19, "duration": 3.31 }, { "text": "So now let me try and open up\nvariables.html after I've linked", "start": 6631.5, "duration": 4.1 }, { "text": "the CSS.", "start": 6635.6, "duration": 1.75 }, { "text": "And, all right, something\nseems not quite right.", "start": 6637.35, "duration": 2.34 }, { "text": "I specified font sizes.", "start": 6639.69, "duration": 1.44 }, { "text": "I specified that\neverything should be red.", "start": 6641.13, "duration": 1.95 }, { "text": "But it's not showing up.", "start": 6643.08, "duration": 1.05 }, { "text": "Everything is showing up black.", "start": 6644.13, "duration": 1.69 }, { "text": "And I don't see any of\nthe differences in sizing.", "start": 6645.82, "duration": 3.41 }, { "text": "And the reason for this is while the web\nbrowser, things like Chrome and Safari", "start": 6649.23, "duration": 4.41 }, { "text": "and Firefox can understand CSS,\nthey can't by default understand", "start": 6653.64, "duration": 4.71 }, { "text": "SCSS, or Sass.", "start": 6658.35, "duration": 1.56 }, { "text": "Sass is an extension to CSS that\nweb browsers don't understand out", "start": 6659.91, "duration": 3.96 }, { "text": "of the box.", "start": 6663.87, "duration": 1.48 }, { "text": "So in order to solve this problem,\nonce we've written our Sass file,", "start": 6665.35, "duration": 3.62 }, { "text": "we need to compile it, convert\nit, translate it, so to speak,", "start": 6668.97, "duration": 3.45 }, { "text": "from Sass into plain old CSS so that\nour browser is able to understand it.", "start": 6672.42, "duration": 5.83 }, { "text": "And in order to do this,\nyou'll need to install", "start": 6678.25, "duration": 2.3 }, { "text": "a program called Sass on your computer.", "start": 6680.55, "duration": 1.97 }, { "text": "And you can install it\non Mac or PC or Linux.", "start": 6682.52, "duration": 2.53 }, { "text": "And now, in the terminal, in\norder to do this compilation,", "start": 6685.05, "duration": 2.91 }, { "text": "I'm going to say Sass variables.scss,\nthe file I'd like to compile,", "start": 6687.96, "duration": 7.44 }, { "text": "colon variables.css.", "start": 6695.4, "duration": 2.99 }, { "text": "So variables.scss is the file\nthat I would like to compile.", "start": 6698.39, "duration": 4.19 }, { "text": "And the file I'd like to\ngenerate is variables.css.", "start": 6702.58, "duration": 3.44 }, { "text": "I'd like to turn my Sass file\ninto a plain old CSS file.", "start": 6706.02, "duration": 4.77 }, { "text": "I'll go ahead and press Return.", "start": 6710.79, "duration": 1.71 }, { "text": "And all right, that compilation\nprocess is now done.", "start": 6712.5, "duration": 3.02 }, { "text": "And so now, inside of variables.html,\ninstead of referencing the SCSS file,", "start": 6715.52, "duration": 6.94 }, { "text": "I'm going to reference the\nCSS file as the style sheet,", "start": 6722.46, "duration": 3.36 }, { "text": "because my web browser only understands\nCSS, it doesn't understand Sass.", "start": 6725.82, "duration": 5.69 }, { "text": "Now, when I load the page,\nnow I see the result I expect.", "start": 6731.51, "duration": 3.39 }, { "text": "Everything shows up as red and\nthe font sizes are different.", "start": 6734.9, "duration": 3.27 }, { "text": "So ultimately, this\nwas a 2-step process.", "start": 6738.17, "duration": 2.4 }, { "text": "I first needed to take my Sass\ncode, compile it into CSS.", "start": 6740.57, "duration": 4.29 }, { "text": "And then I could link the\nCSS to this particular page.", "start": 6744.86, "duration": 3.75 }, { "text": "But the advantage now is that if ever\nI want to make some sort of change,", "start": 6748.61, "duration": 3.3 }, { "text": "I want to change the color, rather\nthan change it in two places,", "start": 6751.91, "duration": 3.13 }, { "text": "or you might imagine in a more complex\npage, like tens or dozens of places,", "start": 6755.04, "duration": 4.13 }, { "text": "I just go to the SCSS file, and I\nchange the color from red to blue.", "start": 6759.17, "duration": 6.45 }, { "text": "Now, if I refresh the page, all\nright everything is still red.", "start": 6765.62, "duration": 3.35 }, { "text": "And that's because I forgot a step.", "start": 6768.97, "duration": 1.7 }, { "text": "I changed the Sass file.", "start": 6770.67, "duration": 1.84 }, { "text": "But that doesn't automatically\nchange the CSS file.", "start": 6772.51, "duration": 2.91 }, { "text": "I need to now recompile the CSS\nfile by saying Sass variables.scss", "start": 6775.42, "duration": 5.76 }, { "text": "variables.css, to compile the file\nagain using the updated Sass file.", "start": 6781.18, "duration": 5.58 }, { "text": "And now, I see the updated changes.", "start": 6786.76, "duration": 3.09 }, { "text": "And if you're curious as to what\nthe updated file looks like,", "start": 6789.85, "duration": 2.55 }, { "text": "I'm actually look at variables.css\nto see what code happens to be there,", "start": 6792.4, "duration": 4.47 }, { "text": "and, though, it's styled\na little bit strangely.", "start": 6796.87, "duration": 2.04 }, { "text": "You can see that I have a UL with a\nfont size a 14 and a color of blue.", "start": 6798.91, "duration": 4.17 }, { "text": "So they've substituted the\nword blue for this variable.", "start": 6803.08, "duration": 2.97 }, { "text": "And they've done the same thing\nfor ordered lists as well.", "start": 6806.05, "duration": 4.07 }, { "text": "Now, in practice, it's\ngoing to be pretty annoying", "start": 6810.12, "duration": 2.31 }, { "text": "if I'm building a web\npage, building using Sass,", "start": 6812.43, "duration": 2.7 }, { "text": "if I constantly need to go back\nand recompile my Sass into CSS", "start": 6815.13, "duration": 3.87 }, { "text": "every single time.", "start": 6819.0, "duration": 1.14 }, { "text": "What I'd like to do is\njust automate that process.", "start": 6820.14, "duration": 2.43 }, { "text": "And Sass makes it easy to do this.", "start": 6822.57, "duration": 2.01 }, { "text": "I can just say, Sass dash dash\nwatch variables.scss variables.css.", "start": 6824.58, "duration": 7.19 }, { "text": "And what that's going to do is now\nyou see Sass is watching for changes.", "start": 6831.77, "duration": 3.88 }, { "text": "Sass is going to monitor\nthe variables.scss file.", "start": 6835.65, "duration": 3.9 }, { "text": "And if ever I change my Sass file,\nSass is going to know about it.", "start": 6839.55, "duration": 3.75 }, { "text": "And it's automatically going to\nrecompile the corresponding CSS file.", "start": 6843.3, "duration": 4.16 }, { "text": "And you can do this not just with\nsingle files, but entire directories", "start": 6847.46, "duration": 2.92 }, { "text": "as well if you have multiple\ndifferent Sass files.", "start": 6850.38, "duration": 2.73 }, { "text": "So now, what I can do is if in\nthe variables.scss file I change", "start": 6853.11, "duration": 5.82 }, { "text": "the color--", "start": 6858.93, "duration": 0.81 }, { "text": "instead of blue, I now want\nit to be green, for example--", "start": 6859.74, "duration": 2.96 }, { "text": "I now save the variables.scss file.", "start": 6862.7, "duration": 3.04 }, { "text": "And now, without doing anything--\ntake a look at my terminal--", "start": 6865.74, "duration": 3.3 }, { "text": "Sass detected a change\nto variables.scss,", "start": 6869.04, "duration": 3.61 }, { "text": "so it gave me a new version\nof my original CSS file.", "start": 6872.65, "duration": 4.38 }, { "text": "If I go back to my web browser now,\nrefresh the page, now, all of the text", "start": 6877.03, "duration": 4.51 }, { "text": "is green, as I would expect it to be.", "start": 6881.54, "duration": 3.59 }, { "text": "So that's one of the very powerful\nfeatures that Sass gives us.", "start": 6885.13, "duration": 3.5 }, { "text": "It gives us the ability to add\nvariables to our CSS code just", "start": 6888.63, "duration": 3.54 }, { "text": "to factor out commonalities.", "start": 6892.17, "duration": 1.59 }, { "text": "If there are common fonts, common\ncolors, common borders, common styling,", "start": 6893.76, "duration": 3.96 }, { "text": "that I want to apply to a\nlot of different things,", "start": 6897.72, "duration": 2.28 }, { "text": "it becomes much easier just\nto use Sass in order to do so.", "start": 6900.0, "duration": 4.31 }, { "text": "And finally, we'll take a look\nat a couple of other features", "start": 6904.31, "duration": 2.92 }, { "text": "that Sass gives us the\nability to do, one of them", "start": 6907.23, "duration": 3.18 }, { "text": "is the ability to nest CSS selectors\ninside of other CSS selectors.", "start": 6910.41, "duration": 5.5 }, { "text": "So one thing you've seen\nso far, for example,", "start": 6915.91, "duration": 2.19 }, { "text": "is that in CSS, if I wanted to style all\nof the unordered lists that are inside", "start": 6918.1, "duration": 5.93 }, { "text": "of divs, for example, I could say\nlike, div arrow unordered list,", "start": 6924.03, "duration": 5.67 }, { "text": "in order to style unordered\nlists that are inside of divs.", "start": 6929.7, "duration": 4.74 }, { "text": "What Sass will do is that will give\nus a bit of a nicer syntax for doing", "start": 6934.44, "duration": 4.2 }, { "text": "this type of thing, in particular,\nby allowing us to nest CSS inside", "start": 6938.64, "duration": 4.98 }, { "text": "of other pieces of CSS.", "start": 6943.62, "duration": 2.45 }, { "text": "So just as an example\nof this, I'll go ahead", "start": 6946.07, "duration": 2.11 }, { "text": "and open up a file I already\nbrought, called nesting.html.", "start": 6948.18, "duration": 4.74 }, { "text": "And so here is what we might\nsee inside of nesting.html.", "start": 6952.92, "duration": 2.63 }, { "text": "Here is the body of the page.", "start": 6955.55, "duration": 2.44 }, { "text": "Inside the body of the page,\nI have a div, inside of which", "start": 6957.99, "duration": 3.9 }, { "text": "is a paragraph inside the div and\nalso a list, an unordered list,", "start": 6961.89, "duration": 3.72 }, { "text": "or ul, that's inside\nof this div as well.", "start": 6965.61, "duration": 3.67 }, { "text": "And then we also have a paragraph\nthat's outside of the div.", "start": 6969.28, "duration": 2.93 }, { "text": "And a list that's outside of\nthe div in addition to that.", "start": 6972.21, "duration": 3.2 }, { "text": "So a number of different elements,\nsome of which are located inside", "start": 6975.41, "duration": 2.8 }, { "text": "of other elements.", "start": 6978.21, "duration": 1.05 }, { "text": "And what I'd like to do is be very\nprecise about how I style these pages.", "start": 6979.26, "duration": 5.39 }, { "text": "What Sass is going to\nallow us to do is it", "start": 6984.65, "duration": 2.41 }, { "text": "lets us write a Sass file that\nlooks a little something like this.", "start": 6987.06, "duration": 4.39 }, { "text": "Let's take a look at what it's doing.", "start": 6991.45, "duration": 1.55 }, { "text": "It's saying, for the\nentire div, I would like", "start": 6993.0, "duration": 2.97 }, { "text": "to give that div a\nfont size of 18 pixels.", "start": 6995.97, "duration": 3.18 }, { "text": "And then, what CSS normally\ndoesn't allow us to do,", "start": 6999.15, "duration": 3.06 }, { "text": "but we can do now using\nthe power of Sass,", "start": 7002.21, "duration": 2.4 }, { "text": "is say, for any paragraphs\nthat are inside of that div,", "start": 7004.61, "duration": 3.9 }, { "text": "go ahead and give those\nparagraphs the color of blue.", "start": 7008.51, "duration": 2.73 }, { "text": "And for any unordered lists\nthat are inside of the div,", "start": 7011.24, "duration": 3.09 }, { "text": "give those unordered\nlists a color of green.", "start": 7014.33, "duration": 2.94 }, { "text": "By nesting these CSS\nselectors inside of others,", "start": 7017.27, "duration": 3.18 }, { "text": "we've been able to get\nacross the idea that I only", "start": 7020.45, "duration": 2.91 }, { "text": "want to style the paragraph\nif it is inside of a div.", "start": 7023.36, "duration": 3.42 }, { "text": "And this is just a little bit\nof a nicer, cleaner syntax", "start": 7026.78, "duration": 3.12 }, { "text": "for doing some of these more complex\nstyling tasks that might come up.", "start": 7029.9, "duration": 4.57 }, { "text": "So what does this actually look like?", "start": 7034.47, "duration": 1.55 }, { "text": "If I like take this SCSS file\nand turn it into normal CSS,", "start": 7036.02, "duration": 4.17 }, { "text": "what is the result going to be?", "start": 7040.19, "duration": 1.83 }, { "text": "Well, let's take a look.", "start": 7042.02, "duration": 1.36 }, { "text": "We can try it out by let me\ngo into my nesting folder", "start": 7043.38, "duration": 3.77 }, { "text": "where all these files are located.", "start": 7047.15, "duration": 1.89 }, { "text": "And if I run Sass nesting.scss,\nturn it into nesting.css,", "start": 7049.04, "duration": 7.93 }, { "text": "now let's open up nesting.css\nand see what it looks like.", "start": 7056.97, "duration": 3.74 }, { "text": "Here, it's turned into\na take all of the divs,", "start": 7060.71, "duration": 2.73 }, { "text": "give them a font size of 18 pixels.", "start": 7063.44, "duration": 2.24 }, { "text": "And then, we're using the same\ndescendant selector notation", "start": 7065.68, "duration": 3.97 }, { "text": "that we saw before, where all\nthe paragraphs inside of divs", "start": 7069.65, "duration": 3.27 }, { "text": "should be colored blue, all the\nunordered lists inside of a div", "start": 7072.92, "duration": 3.21 }, { "text": "should be colored green.", "start": 7076.13, "duration": 1.29 }, { "text": "And this certainly works.", "start": 7077.42, "duration": 1.21 }, { "text": "And we could have just written\nthis CSS from the beginning,", "start": 7078.63, "duration": 2.75 }, { "text": "but it can be a little bit cleaner, a\nlittle bit easier to read to use Sass", "start": 7081.38, "duration": 4.35 }, { "text": "in order to really say,\nparagraphs inside of divs", "start": 7085.73, "duration": 3.2 }, { "text": "should be structured this way, unordered\nlists are styled in some other way.", "start": 7088.93, "duration": 3.83 }, { "text": "And using this nothing approach\njust makes it often easier", "start": 7092.76, "duration": 2.84 }, { "text": "to take a look at this SCSS\npage and really understand", "start": 7095.6, "duration": 3.96 }, { "text": "how all of the different style\ncode interacts with each other.", "start": 7099.56, "duration": 3.83 }, { "text": "So after all of this now,\nif I open up nesting.html,", "start": 7103.39, "duration": 5.2 }, { "text": "we might see something that looks\na little something like this.", "start": 7108.59, "duration": 3.0 }, { "text": "The paragraph inside the div and\nthe list inside of the div, those", "start": 7111.59, "duration": 3.72 }, { "text": "both get changes to the way\nthat they've been styled.", "start": 7115.31, "duration": 3.18 }, { "text": "But unlike them, these\nparagraphs outside of the div", "start": 7118.49, "duration": 3.24 }, { "text": "and the list that is\nalso outside of the div,", "start": 7121.73, "duration": 2.13 }, { "text": "those get styled a\nlittle bit differently.", "start": 7123.86, "duration": 3.43 }, { "text": "So two features now we've\nseen inside of Sass.", "start": 7127.29, "duration": 2.45 }, { "text": "We've first seen the\nability to have variables", "start": 7129.74, "duration": 2.57 }, { "text": "to make sure we're not\nrepeating ourselves", "start": 7132.31, "duration": 1.75 }, { "text": "in many places throughout the code.", "start": 7134.06, "duration": 1.68 }, { "text": "And now, we've seen the ability to\nnest CSS selectors inside of each other", "start": 7135.74, "duration": 4.62 }, { "text": "by taking advantage of Sass.", "start": 7140.36, "duration": 2.52 }, { "text": "And finally, we'll take a\nlook at one last feature", "start": 7142.88, "duration": 2.46 }, { "text": "that Sass is going to give us.", "start": 7145.34, "duration": 1.44 }, { "text": "And that is something\ncalled inheritance.", "start": 7146.78, "duration": 2.28 }, { "text": "If we have certain CSS selectors that\nare related to other CSS selectors,", "start": 7149.06, "duration": 4.65 }, { "text": "but they're may be adding\nsome additional information.", "start": 7153.71, "duration": 3.18 }, { "text": "And in this case, I'm actually going\nto show you the finished product first.", "start": 7156.89, "duration": 3.46 }, { "text": "So let's go into inheritance and\nlet me open up inheritance.html.", "start": 7160.35, "duration": 5.75 }, { "text": "And here, you see I've\ntried to almost implement", "start": 7166.1, "duration": 2.79 }, { "text": "Bootstrap-style alert messages in HTML.", "start": 7168.89, "duration": 3.48 }, { "text": "I have a success message up at the\ntop, a warning message, and then", "start": 7172.37, "duration": 2.91 }, { "text": "an error message.", "start": 7175.28, "duration": 1.2 }, { "text": "And each of these messages you'll\nnotice are styled differently.", "start": 7176.48, "duration": 2.88 }, { "text": "In particular they're\neach a different color.", "start": 7179.36, "duration": 2.13 }, { "text": "But despite that, they\nshare a lot in common.", "start": 7181.49, "duration": 2.52 }, { "text": "They share a common border.", "start": 7184.01, "duration": 1.26 }, { "text": "They share a common font.", "start": 7185.27, "duration": 1.32 }, { "text": "They share a common size\nand many other properties", "start": 7186.59, "duration": 2.7 }, { "text": "are all shared between these elements.", "start": 7189.29, "duration": 1.8 }, { "text": "There are just some things that are\na little bit different about them.", "start": 7191.09, "duration": 3.75 }, { "text": "I could have written three\ndifferent CSS selectors", "start": 7194.84, "duration": 2.46 }, { "text": "to deal with all of these cases, but\nthere might be some repetition there.", "start": 7197.3, "duration": 3.73 }, { "text": "So here's what I can do by\ntaking advantage of the features", "start": 7201.03, "duration": 2.93 }, { "text": "that Sass gives me.", "start": 7203.96, "duration": 1.65 }, { "text": "Let me go ahead and look at\ninheritance.scss to look at the code", "start": 7205.61, "duration": 4.95 }, { "text": "for doing this.", "start": 7210.56, "duration": 1.97 }, { "text": "And it looks a little\nbit cryptic at first.", "start": 7212.53, "duration": 3.12 }, { "text": "But here's what I've defined.", "start": 7215.65, "duration": 1.71 }, { "text": "I've here defined using a percent sign\nthat this is what a generic message is", "start": 7217.36, "duration": 4.44 }, { "text": "going to be, something that I can extend\nlater to add additional information to.", "start": 7221.8, "duration": 4.41 }, { "text": "All of the messages, whether they be\nsuccess messages or danger messages", "start": 7226.21, "duration": 3.18 }, { "text": "or warning messages, they're\nall going to have the same font.", "start": 7229.39, "duration": 2.81 }, { "text": "They're all going to\nhave the same border.", "start": 7232.2, "duration": 1.75 }, { "text": "They're all going to have the\nsame padding and margin, spacing", "start": 7233.95, "duration": 2.58 }, { "text": "around and outside of it.", "start": 7236.53, "duration": 1.56 }, { "text": "But each of the specific messages\nare going to be slightly different.", "start": 7238.09, "duration": 4.86 }, { "text": "How are they different?", "start": 7242.95, "duration": 1.09 }, { "text": "Well, let's take a look down here.", "start": 7244.04, "duration": 1.91 }, { "text": "Anything with a class of success, I'm\ngoing to say extends this message.", "start": 7245.95, "duration": 6.12 }, { "text": "And by extends this message what I\nmean is that anything with a class", "start": 7252.07, "duration": 3.42 }, { "text": "of success is going to inherit all\nof these CSS properties-- the font,", "start": 7255.49, "duration": 4.77 }, { "text": "the border, the padding in the margin--", "start": 7260.26, "duration": 2.4 }, { "text": "but it's going to add\nadditional information to it.", "start": 7262.66, "duration": 2.13 }, { "text": "In particular, we're\ngoing to add a color.", "start": 7264.79, "duration": 2.34 }, { "text": "We're going to say that\nfor success messages,", "start": 7267.13, "duration": 1.89 }, { "text": "the background color\nis going to be green.", "start": 7269.02, "duration": 2.71 }, { "text": "I've extended the basics of\nwhat a message is, but said", "start": 7271.73, "duration": 2.78 }, { "text": "that this message in particular has\nsome additional style that we're", "start": 7274.51, "duration": 3.6 }, { "text": "going to assign to it as well.", "start": 7278.11, "duration": 2.22 }, { "text": "And the other two messages\nbehave in very similar ways.", "start": 7280.33, "duration": 2.67 }, { "text": "My warning message extends\nthe message, but instead", "start": 7283.0, "duration": 3.18 }, { "text": "says the background\ncolor should be orange.", "start": 7286.18, "duration": 2.22 }, { "text": "And finally, the error message\nalso extends the message.", "start": 7288.4, "duration": 2.82 }, { "text": "But this time, it gives us the\nbackground color of red instead.", "start": 7291.22, "duration": 4.51 }, { "text": "So now, when you compile\nthis all together", "start": 7295.73, "duration": 2.3 }, { "text": "into inheritance.css, which\nI compiled it in advance,", "start": 7298.03, "duration": 4.3 }, { "text": "this is what this is\nultimately going to look like.", "start": 7302.33, "duration": 2.18 }, { "text": "It translates what I've\nwritten into saying,", "start": 7304.51, "duration": 2.34 }, { "text": "all right, success\nand warning and errors", "start": 7306.85, "duration": 2.82 }, { "text": "should have all of these properties.", "start": 7309.67, "duration": 2.19 }, { "text": "But success should also\nhave this background color,", "start": 7311.86, "duration": 2.36 }, { "text": "warning should have\nthis background color,", "start": 7314.22, "duration": 1.75 }, { "text": "error should have this background color.", "start": 7315.97, "duration": 1.96 }, { "text": "So again, we could\nhave written this CSS.", "start": 7317.93, "duration": 2.18 }, { "text": "There is nothing that\nSass does that we couldn't", "start": 7320.11, "duration": 2.76 }, { "text": "have written ourselves using CSS.", "start": 7322.87, "duration": 2.58 }, { "text": "Sass we'll just make it a little bit\neasier to do many of the same thing.", "start": 7325.45, "duration": 3.67 }, { "text": "So we can write things in a\nlittle bit of a nicer syntax", "start": 7329.12, "duration": 2.57 }, { "text": "by saying the success message\ninherits from the message", "start": 7331.69, "duration": 3.15 }, { "text": "but adds a background color.", "start": 7334.84, "duration": 1.6 }, { "text": "And likewise, the warning and\nerror messages do the same thing,", "start": 7336.44, "duration": 3.36 }, { "text": "but in a simpler syntax and a bit\nof a nicer syntax, such that later", "start": 7339.8, "duration": 3.8 }, { "text": "we can let the computer take the Sass\ncode and compile it into CSS instead.", "start": 7343.6, "duration": 6.0 }, { "text": "And so those now are\nsome of the fundamentals", "start": 7349.6, "duration": 2.46 }, { "text": "of what we've seen in building\nweb programs using HTML and CSS.", "start": 7352.06, "duration": 3.99 }, { "text": "We've seen how we can use HTML to\ndescribe the structure of our web page,", "start": 7356.05, "duration": 3.9 }, { "text": "deciding what's going to show up where\non the page, and then we looked at CSS", "start": 7359.95, "duration": 3.57 }, { "text": "and how CSS can then be used to style\nour web page in various different ways,", "start": 7363.52, "duration": 4.05 }, { "text": "adding custom styling\nlike colors and layouts,", "start": 7367.57, "duration": 2.49 }, { "text": "but also thinking about\nthings like responsive design,", "start": 7370.06, "duration": 3.03 }, { "text": "like what happens on a\nmobile screen or on a tablet,", "start": 7373.09, "duration": 2.52 }, { "text": "and making sure that our web pages\nlook good on those screens too.", "start": 7375.61, "duration": 3.67 }, { "text": "And then finally, we took a look\nat Sass, an extension to CSS,", "start": 7379.28, "duration": 3.43 }, { "text": "that adds a number of\nadditional features,", "start": 7382.71, "duration": 1.75 }, { "text": "features like variables and\nnesting and inheritance,", "start": 7384.46, "duration": 3.14 }, { "text": "that make it even easier for\nus to be able to write style", "start": 7387.6, "duration": 2.77 }, { "text": "that we can apply to our web pages.", "start": 7390.37, "duration": 2.09 }, { "text": "From there, we're going\nto be transitioning now", "start": 7392.46, "duration": 1.96 }, { "text": "to looking at how we can use HTML\nand CSS in larger web applications", "start": 7394.42, "duration": 4.14 }, { "text": "as we begin to incorporate other\ntools, tools like Python and JavaScript", "start": 7398.56, "duration": 4.11 }, { "text": "and other languages and\nframeworks altogether.", "start": 7402.67, "duration": 2.25 }, { "text": "So this is Web Programming\nwith Python and JavaScript.", "start": 7404.92, "duration": 3.09 }, { "text": "We'll see you next time.", "start": 7408.01, "duration": 2.09 } ]