Course Introduction and Path
- Massive course designed to prepare learners as full-stack developers
- Hands-on projects including building games, cloning Google & Instagram, AI investing apps, and Chrome extensions
- Focus on active coding, type out code manually, and solving over 500 interactive challenges
Foundational Web Development
HTML & CSS
- Core HTML tags, nesting, buttons, input fields, links, and lists
- Proper HTML document structure and accessibility features like alt texts
- CSS basics: selectors, properties like margin, padding, borders, box model
- Flexbox for responsive layouts, centering, spacing, and alignment
- Deployment of static sites with Netlify
JavaScript Essentials
- Variables, functions, DOM manipulation, event listeners
- Using states and interactive elements to build real-world apps like passenger counters
- Working with strings, numbers, booleans, conditionals, loops (for loops)
- Arrays, objects, ES6+ features including arrow functions, template strings
- Fetch API for asynchronous network requests, promises, async/await
(You can deepen your foundational JavaScript knowledge with the Complete JavaScript Beginner Course: Projects, Fundamentals, and API Integration.)
React Development
Fundamentals
- React elements and JSX syntax
- Composable, reusable components
- Passing props for data-driven rendering
- State management in components
- Event handling and conditional rendering
Advanced React Topics
- Forms handling including controlled components and new React 19 form actions
- useEffect hook for handling side effects and lifecycle events
- React confetti integration
- Accessibility best practices with ARIA roles, labels and live regions
(For an in-depth dive, consider the Complete TypeScript Course: From Basics to Advanced React Integration, which complements React learning with strong typing fundamentals.)
TypeScript
- Basic and custom types, optional properties, union types
- Typing React components, hooks, props, and callback functions
- Utility types: Partial, Omit, Generics
- Strong typing for safer, more maintainable code
Node.js and Backend Development
- Basics of Node.js environment
- Creating servers with HTTP module
- Handling requests, responses with status codes and headers
- Serving static files and APIs with routing and query parameters
- File system operations: read/write files, directories
- Building RESTful APIs with JSON data
(Expand your backend proficiency by building real-world projects in Build a Full-Stack LMS with React, Node.js, MongoDB & Stripe.)
APIs and Asynchronous Programming
- Understanding API concepts: requests, responses, JSON data
- Making fetch requests with fetch/then and async/await
- Handling errors with try/catch and response.ok property
AI Engineering and OpenAI API Integration
- Integrating AI models for text and image generation
- Handling OpenAI tokens, chat completions, and prompt engineering
- Using few-shot learning and temperature settings
- Best practices for AI safety and prompt injection
Next.js Full Stack Development
- Setting up Next.js apps with TypeScript and Tailwind CSS
- File-based routing including dynamic and nested routes
- Layouts and Shared UI components
- Client vs Server components with "use client" directives
- Static Site Generation, Incremental Static Regeneration, Server-side Rendering
- Link components and client-side navigation
- Handling search params for dynamic filtering
- Image and font optimization in Next.js
Community and Learning Strategy
- Community interaction encouraged via Scribba Discord and forums
- Emphasis on active retrieval, spaced repetition, and hands-on projects
- Avoid tutorial hell by coding along and trying challenges independently
- Use of AI assistants and community support for problem-solving
Summary
This comprehensive program builds your capabilities from web fundamentals through advanced full-stack techniques, React proficiency, TypeScript strong typing, backend API development, AI model integration, and modern full-stack framework Next.js. With continuous hands-on coding and community support, it prepares you for real-world development roles and projects.
Flagged: false
This massive course will prepare you to be a full stack developer. It's taught by many different instructors and put
together by Scribba. Here's Pere Borggan, the CEO of Scribba, introducing the course. Hi there and welcome to this
massive full stack developer path. These modules that you are about to watch have helped countless students over on
scribble.com break into the tech industry as developers and not in the boring theoretical way. No, in a fun way
where you build games, clone Google and Instagram, build AI investing apps, even Chrome extensions. And when I say you, I
really mean you. Because the only way to learn this is to type the code out yourself. Throughout this course, the
teachers will throw challenges your way, actually over 500 times. And the starter code for these challenges can be found
on GitHub or over on scrimba.com in the interactive expanded version of this course. We're going to start out with
the basics of HTML, CSS, JavaScript, and so forth, and then move on to the frameworks and technologies that are
used in the industry like React, Node, Next, SQL, TypeScript, testing, and even AI engineering. So, this really is your
one-stop shop towards becoming a professional fullstack developer. Now, I would love to follow you on this
journey. So, be sure to send me a LinkedIn connection request so that I can share for you from the sidelines.
With that, let's dive in. >> The French philosopher Renee Deart once said three clever words,
ergo, sum, which translates in English to I code, therefore I am. So let us prove to ourselves that we actually do
exist by coding this out in HTML. And the way we do that is actually not too different from how you would write this
out in a regular text editor. as there you would simply write out the sentence. And then if you wanted it a bit more
prominent, you'd probably highlight it and then click on normal text here and choose another content type for your
text. You can see heading one, heading two, heading three. Let's hover over heading one and then click on it. And
there you can see that the text became a lot more prominent. It became a heading one. Now if we want to do this in HTML,
we'd simply create an HTML file which you can see here. It's called index.html. HTML as that is a common
name to give your HTML files. And here I would write I code therefore I am. Now if we open up a browser and point this
browser to our HTML file and then run it then we can see that the text indeed appears in the browser. However, it's
pretty small. So if we wanted to turn it into a heading one instead what we do is wrap the text in HTML tags. So before
the text, I'll do this two angle brackets with the text H1 inside of them. That's short for heading one. And
then at the very end of the text, I would do the same H1. But since this is a closing tag and not an opening tag, I
would also have to give it a slash before the text. And now if I rerun the code, there you go. We have made our
text a lot more prominent. Now I think our website should give proper credit here. So let's write reneart underneath
the H1 like that. If we now rerun the code, you can see that the text is just normal. It's not an H1. And that is
because it is only the text which is within the opening H1 and closing H1 that gets formatted as a proper heading
in the browser. In my view, this line right here should be a bit bigger. I want it to instead look something like
this where the name is pretty thick and big but not as big as the heading one. And that brings me to your first
challenge. I'm going to paste it in here. So, what you are going to do is try to make our web page look like the
design in the provided slide. And if you are struggling to think of what kind of HTML tag you'll have to wrap this name
in, well, I've got a little hint for you. What comes after one? So, pause this scrim, jump into the code, and try
to solve this challenge right now. And then when you return back to me, I will of course show you the solution as well.
Good luck. Okay, hopefully that went well. The way you solve this is by instead of using
the H1, using its smaller sibling, the H2. Like that. It has the exact same so-called syntax as the H1. So instead
of a one you use a two. If we now run this, there you go. We have achieved the design we wanted. So great job. Let's
move on. Before we move on to the next challenge, there's one thing I want to make sure
that you are aware of. And that is that if you have an HTML file locally on your computer and you have a browser, what
you can do is simply drag and drop that file into the browser and then it'll be rendered. So that is actually more or
less the same thing that's happening here on Scribba. Though here we have a mini browser and the text editor inside
of well your browser because Scribba itself is browser based. So a little bit meta but it's essentially the same
thing. Okay. Now, it's time for you to get some more muscle memory on how to write HTML tags and also get to know two
new tags because I want you to create a news article and more specifically this news article right here which has a
title that says humans have reached Mars. It has a subheading right here and also some regular text. And the HTML
tags are H1 for the title, H3 for this one. You haven't used an H3 for, but I think you know how to do it. And then
there's finally a P tag for the text at the bottom. P is short for paragraph and I have provided a little syntax example
for you here. However, if you've understood the logic of how to write these tags by now, it shouldn't come as
a surprise how you do that. Okay, here is also the text so that you don't have to write all of that out. You can just
copy paste it instead. So now starting here on line 13, write the HTML we need in order to create this news article.
Okay, hopefully that went well. Let's start with the H1. I'm going to create the open and closing tag and then paste
in the text like that. Running the code. Yes, it works. Moving on to the H3. Copying the text.
Then rerunning the browser. And there we go. Finally, there is the paragraph like this.
rerunning the code and there we go. We have achieved this exact layout. Great job. Let's move on.
Now you are going to learn about images because I really think our Mars article needs an image. The way to do that is by
using the img tag. So we start with our angle brackets and then write simply img inside of those. And what's unique about
this tag is that you don't need a closing tag. So there is no closing img as there is a closing a run or closing
paragraph. This is simply not needed. So it's often called a self-closing tag and some people use the slash at the end of
the opening tag like this just to signify that it is closing itself. However, it's not really needed. So we
can skip it. And I think in general that less code is better code. So I am just going to skip it. However, if you prefer
to have it like this, that's totally fine as well. Okay, enough syntax. How do we get this image to work? Because
right now, if we rerender this page, nothing has happened. And that is because we haven't told the image tag
which image we want to render. And the way to do that is by writing src, which is short for source. And then we write
equals, and then two quotes, because inside of these two quotes, we're going to specify the image we want to render.
And here on the left hand side you can see I have mars.jpeg. It is in the same directory as our
index.html file. Meaning I can simply do mars.jpg. Then run the code. And there we go. We
have our image. That is super cool. However, you can see that this image behaves a little bit differently from
our paragraph for example because where is the paragraph take up the entire width? the image just take up whatever
width it needs, leaving us with white space on the right hand side if the browser is too wide or cutting off the
image if the browser is too narrow. And I actually want this image to behave like our other paragraphs. So I'm going
to show you a little hack to do that because normally you'd use CSS for doing this. But there is a little trick we can
use by simply utilizing the width attribute. So that is an attribute just like source is an attribute and it uses
the same syntax. We'll do with equals and then two quotes and then inside of the quotes we can write for example
100%. If we now rerun this you can see yes our image is now scaling with the size of
our browser looking super neat. Now as I said this is a hack. So, if you show this around to people, you might get
this annoying guy saying, "Well, actually, that's not valid HTML according to the specification." But you
know what? Let's not care about that. At this point, you should not give a darn about specifications, validity, and aka
correct HTML. You should instead look at yourself like a hacker who grabs whatever tool you need in order to get
the job done. So now we're going to use this even though we know it's a hack because later down the line you're going
to learn the proper way of doing this using CSS, the language we use for styling websites. So with that out of
the way, I want to show you one more thing before I give you a challenge. Because one thing that's super cool is
that you can actually borrow images from wherever you want online. So if you find an image you like, you can borrow it and
use it in your project. Let me show you how. So if we Google Mars for example and click on the images tab and then
click on whatever image we think is cool. For example, this one right here. And then in this image view on the right
hand side here, you can rightclick and choose copy image address. Once you've copied that, you can simply paste it
into the source attribute. So I'm going to remove Mars.jpeg and paste in the image address which I just copied. If we
now run the code, you can see there we go. We have borrowed this super cool image from another website online.
So, it's time for a challenge. What I want you to do now is add a second image to our article. I want you to find one
via Google and then place it under the H1 element but above the H3 element. So, that is right here. And finally,
remember to use the width attribute to make the image as wide as the other elements. I'm going to leave you here
with the marks image again and wish you good luck. go ahead and solve this challenge right now.
Okay, hopefully that went well. What you needed to do was write the angle brackets img. Then set the source to
whatever image you found online. I'm going to reuse the one I found earlier like that. If we're rendering this, this
is a really wide image by default. That's not what we want. We want it to scale with our browser. So, we need the
width attribute. width equals a 100% like that. And now we have two super cool images in our article, both scaling
up and down with the size of the browser. Great job. Let's move on. Okay, now you're going to learn about
something called nesting, which is the act of nesting HTML elements inside of other HTML elements. So, let me show it
to you in practice. Let's say that we want to group all of these elements here together. What we then do is above all
of the HTML tags, write another HTML tag. And in this case, we use the so-called div, which is short for
divider. However, I don't think that is a very good name. I would rather call this, for example, a container, though
div is what it's called. So, we're just going to have to stick with that. Now, in order to nest elements inside of this
div, we'd write the closing tag below all of the HTML tags in our article. And then for readability purposes, we'd
indent all of the tags in our article. So now our H1, image, H3, P, and image here are all children of this div tag
right here. This doesn't change our layout at all. So this div tag here is invisible. However, it has now given us
the ability to target the entire article just by targeting this div right here. And that is useful if we, for example,
want to add some styling to our entire article using CSS or somehow manipulated using JavaScript, which is the
programming language that you use in browsers. And very often, you'll actually see a ton of divs on a page. So
for example, you'd see another div around this image element here, which then would have been indented yet
another time in order to signal that this is indeed a child of this div, which again is a child element of this
div. Now if we were to visualize an HTML document, it would look something like this. You'd have, for example, a div up
here and it would have two children which could be their own divs like this. And then this lefth hand div here would
for example have an image tag as its first child and also an H3 as its second child. The other div on the right hand
side could have an H1 tag as its child, P tag as its child, maybe even another div as its child. And then if we go yet
another level deep, this paragraph tag might have its own child, which could be for example an A tag, which you haven't
learned about yet, but which you'll learn about soon, as that is the so-called anchor tag that allows you to
create links on websites. And looking at this visualization, you might think, well, this kind of looks like a family
tree. And yes, it does. And that is exactly why we call this structure the HTML document tree because we are inside
of an HTML document. and how they are nested inside of each other becomes kind of like a tree where you have a trunk
and then branches going out from that and then yet again new branches going out from those branches and so on and so
on. So now that you know that let's move on to the next scrimm. Okay, now we're going to use your newly
acquired internet superpowers in order to perform a little practical joke because you might have a friend who is
far too obsessed with a sports team. For example, I myself am a Manchester United fan and one of the worst things I can
imagine is if some rich billionaire buys the club and changes its name. That would make me truly outrageous. So, what
we're going to do now is change the news on BBC Sports so that you then can show this page to a Man United fan and thus
make them really upset while you get a good laugh. So, let's go ahead and do this here on the BBC Sports page on this
top article here. I'm going to write click on the text and then you can see it gives me the option to choose
inspect. Now, note that this is on a Chrome browser as that is what I'm using. If you're in a different browser,
there might be slightly different steps here or a different wording, but overall in general, the steps are the same. So,
I'm going to click on inspect. And then you can see that it opens up this panel on the bottom of the browser. This is
called the developer tools. And here you can see we are in the elements tab. And that shows us the HTML elements that are
on the page. And here the one we have chosen now which happens to light up this area on the BBC site contains the
title of our article and it is an A tag which I've just briefly mentioned and that you're going to learn more about
later. Now we can't see any text here. So I'm going to click on this age tag and there you can see it contains an
age3 tag nested inside of it. If we click on that one as well you can see that there we see the text that is
rendered in the browser. So here we can double click on that text and change it for example to something as awful as
Jeff Bezos to buy Man United and rename the club after himself. Oh my god that is about the worst piece of news any
United fan can read. So if we now hit enter there you can see boom we have changed the text on BBC. Now let's click
on this paragraph here as well open it up because there we can also change the text that is written underneath the
title. Let's paste in the US billionaire says he doesn't follow the Premier League but wants to own the club to grow
his personal brand. This just gets worse and worse. So now if we hit enter that is also rendered in the browser. Now I'm
going to scroll a little bit up in the dev tools here and hover over this div tag here because as you can see that
highlights our image. So it seems to be that our image is nested inside of a div tag. Let's open it up by clicking on
this triangle. And there we can see another div tag. Well, okay. Still highlighting the image. Let's open up
that one as well. Oh, wow. There we have yet another div tag. A div inside of a div inside of a div. This is web
development in a nutshell. Let's open it up again. And there, yes, we can see our image tag. I'll scroll a bit down. And
you can see there are tons of different attributes here. We're going to ignore almost all of these and then instead
direct our attention towards the src attribute. That one we know because that is the one we need to change in order to
change this image. So now let's open up a new window. Search for Jeff Bezos. Click on an image we like. For example,
this one right here. Right click on it and choose copy image address. Then can do now is double click on this source
and then remove the existing source inside of the quotes like that and then paste in our image of Jeff Bezos.
However, if we now hit enter, you can see nothing changed. And that is because BBC is a little bit fancy here. They use
another attribute called src set, which helps the browser render different sized images on different types of screens
depending on what kind of image is appropriate for the given screen the website is rendered on. So, what we're
going to do here is just double click on the src set so that everything's highlighted and just delete all of it
and then hit enter. And boom, there you go. We have Jeff Bezos looking pretty ready to acquire this football club and
rename it Bezos United. Finally, I'm going to close this panel by clicking on the X in the right corner here. And
there you go. We have our article. So now the final step is just to take this site, show it to someone who is a
Manchester United fan, and get a good laugh. Now, a final notice. If you refresh this page, you will lose your
changes because you only made your changes locally. And when you refresh it, the entire page gets the fresh data
from the database of BBC and not from whatever local changes you did. And since it is local, that also, of course,
implies that your changes only happen on your computer. You don't change BBC in production, of course. So, go ahead and
play around with some sites online. See if you can come up with a fun little practical joke for a friend. Have fun
and I'll see you in the next Scrim. Now, we're going to get you on boarded to the Scriber community because this
career path is so much more than just a course. It's also a social experience where you are able to get help, meet
like-minded people, network, and find inspiration. Our Discord server is at the heart of our community and thousands
of coding students just like you are online at any given time. We pride ourselves on keeping our Discord an
ultra supportive and friendly space and we welcome coders of all abilities from complete beginner to professional and we
have a ton of channels for all kinds of coding and workrelated subjects. So in a moment click on this link, this
screenshot or any of the screenshots you see in this scrim. That's right. Remember, a scrim is not a video. So,
the link that you can see right here, that is a live link. You can click it. This is going to take you through to
Discord, and you can just follow the steps to get registered and onboarded into our Discord server. And that will
no doubt involve proving that you're human by identifying elks or something. Once you're done, why not make your
first stop on our Discord server, the introduce yourself channel. Let us know who you are, where you're from, what
your aims are, what you like to do when you're not coding. This is your first opportunity to interact with the
community. And then why not browse the channels? And I'm just going to point out a few highlights. We have the
announcements channel for news and updates. There's a stay accountable section with today I will and today I
did. These channels can help you set goals and brag about your success. Career chat, as the name suggests, is
where you can get and give help on career related matters. The I built this channel is a great place to show off the
amazing projects you've been building. And if we just scroll down a little bit more, we can see that we've got the
general help channels here for JavaScript, design, HTML, React. And then here we've got specific channels
for each module of this career path. So you can always go there if you get stuck and you need a bit of help or if you
want to pay it forward and help out some other students. Now, if we go right back up to the top, we have event. And this
will show you up and cominging events for the Scriber community. Every Tuesday we host the Scriber town hall on
Discord. And if you click into events, you'll see that the next town hall is already scheduled and it will show you
the time in your local time zone. So for me here in the UK, it's at 5:00 p.m. on Tuesdays. The town hall is a live event
especially for the Scriber community with 45 minutes to an hour of chat on all things Scrimber, learning to code,
and getting jobs in tech. Each week is a bit different. Sometimes we interview students who recently got hired to hear
about the process for example or we review some code or give feedback on a CV. But we always have time to answer
your questions. So do come along and join us. It's an interactive experience. You can chat with us and it would be
great to see you there. It's a great chance for you to interact with the Scriber team and have your say. You'll
find the town hall channel right here in the sidebar. Also check out the Scrimbert podcast. There is a new
episode every week and it's packed with motivational advice and job hunting strategies from developers who've been
exactly where you are now. You can click this slide or find it wherever you usually get your podcasts. I'm going to
leave you with these two links. We've got the Scriber podcast and our Discord server. Once you've checked them out,
come back here and you're ready to get started coding your very first web app. Now you're going to learn about your
very first interactive HTML element and that is the button tag because buttons are all over the web. So to create a
button, simply start with your angle bracket and a button opening tag and then a button closing tag like that. And
in between the two tags, you write whatever text you want inside of your button. Now, as you can see, it's styled
with a background color that also has a border around it. And you can even click it. Now, this button doesn't do
anything. In order to hook this up with some kind of feature, for example, trigger a purchase. Then you'd have to
learn JavaScript, and that is outside the scope of this course, but something you'll learn later in the front-end
developer career path. So, for now, our button will just be there and pretend to do something while actually being pretty
useless. Now that you've seen this once, I want to put you on the spot and give you a challenge. I want you to create a
layout according to the design in this slide. So imagine that you are building a website where people are to sign up.
Then it would be very natural to have something like this where you have an H1 at the top welcoming them, a paragraph
with a little message and then a sign up button. So I want you to create this layout. You don't have to write the text
because I've provided it here. Just make sure that you set up the HTML tags correctly so that it renders properly on
the page. Good luck. Okay, hopefully that went well. Let's now do it together. I'll start with the
welcome H1 tag like that. Paste that in. And boom, there we go. Next up, there's the paragraph, opening tag, closing tag,
and then pasting the text in between. Running this code. It still looks correct. Finally, the button like that
with sign up written inside of it. And boom, there we go. We have our completely useless signup form that
doesn't do anything. But in the next scrim, we're going to add on to this. So stay tuned and then I'll see you there.
The signup section we have here is actually pretty useless because there's no way for our users to add, for
example, their username or a password. So in this scrim, we're going to fix that. Which leads us to the input tag.
The input tag is just like images, a self-closing tag. So we only write the opening tag and not the closing tag like
we do with buttons for example. However, we have to specify what kind of type our input should be. So it has this type
attribute just as the image has a source attribute and the value of the type can be a range of different options, but
we're going to start off with the most common one and that is text. If we run this, you can see we get this nice
little text box in the browser. Another handy attribute is the placeholder. That's where we can give the user a hint
about what kind of data we're asking for. So, for example, enter username like that. If we run this, you can see
it says enter username. Okay, let's do a mini challenge. We of course want them to enter their password as well. So, I
want you to create a new input field on line four, which is identical to the one on line three, though it should say
enter password in the placeholder as opposed to enter username. And don't just copy this line and change this
word. I want you to get some muscle memory here. So, go ahead and do that right now.
Okay, hopefully you did like this. Input type equals text placeholder enter password like that. And there we go. Now
you can enter a username and a password. However, in the real world, passwords are never exposed like that. The
characters are always masked. And the way we achieve that is simply by changing the type from text to password
like that. If we run the code now, you can see the username is shown but the password is masked. Really nice. And
speaking of this type attribute here, it can take a range of different values which turn into really interesting
interactive elements on the page. For example, you can do type equals date. Let's say you want the user to add their
birth date during sign up. And then you get this nice little date picker. Or you can do type equals time. For example, if
you want the user to be able to configure when they should get some kind of notification, that gives the user a
nice time picker. Or let's say you want to give the user a way to configure the theme of their profile with colors. Then
you can do type equals color. And then you get this powerful color picker where the user can add basically any color
there is through moving around on these dots. So, the input tag is a really versatile tool in your toolbox. Okay,
let's move on to the main challenge because I want our users to have profile pictures, which means that you need to
add an HTML input field that lets them upload image files. And I'm not going to tell you what kind of type that input
field has. I'm just going to show you how it looks, which is like this. You've probably seen it online before. It's
basically a button. And when you click it, it lets you choose an image from your local file system. And the reason I
want you to figure out what the type attributes should be here is because being good at Googling is actually huge
part of being a good programmer. And the two are actually not that easy to separate from each other. So this gives
you a way to practice those Googling skills. And I'm going to give you a hint that the keywords you should use are
found in this last sentence right here. So go ahead and solve this challenge right now and then I will of course show
you the solution when you return back to me. Okay, hopefully that went well. Let's do
this. The keywords I think are important here are HTML input because we know we're looking for an HTML input tag. And
then what is our intent? Well, it is to upload image files. And I think Google can handle this just by combining HTML
input upload image files. If we just paste that into Google, let's see what we get. And as you can see, when we
search for that, we get a first hit from developer.mmazilla.org. Let's click into that. And here you can
see the title is input type equals file. And we get this little code snippet here. And it also says input elements
with type file let the user choose one or more files from their device storage. Sounds pretty good so far. Let's zoom in
on the code here. And there you can see that they are actually using the profile picture example themselves. Choose a
profile picture with this button which looks suspiciously similar to what I just showed you a couple of minutes ago.
So I think we've found it. What we're looking for is type equals file. Let's add this up above the signup button.
put a equals file like that. If we run this code, yes, there we go. We get this button which looks like exactly what
we're looking for. Okay, now we're going to move on from using Google to building Google. I mean,
how cool is that? You've learned HTML for just about 30 minutes and now you're going to build the most visited website
in the world. That is just amazing. As you can see here on the similar web overview, Google is at the very top
amongst the most visited websites in the world, beating sites like YouTube, Facebook, Instagram, Wikipedia, and all
the way at 10th, a pornography site, of course. And by the way, it's a little bit sad to see that this adult site has
almost three times the average visit ruration of Wikipedia. So, a pretty deep insight about humankind right there.
Anyway, we are going to build google.com and it'll look like this. However, now you're probably wondering, how can we
make a page look like this? This doesn't look like regular HTML. And that is because I've cheated a little bit and
added this line up here, which is a link tag to styles.css. And if you look at the file menu in the left hand side, you
can see that actually we have a file called styles.css, CSS which contains exactly that cascading stylesheets which
is the language for styling websites and which you're going to learn all about a little bit later in this course.
However, for now, I want you to completely ignore this. What you should do instead is just create the four HTML
tags we need in order to create a google.com clone. And then this CSS will be pulled in and take care of styling
the elements as they should be. So that it will look like this. And to give you a hint, this is an image file pointing
to google.png, the file I've added here. And PNG is just a file format just like JPEG. You can use it in the exact same
way as we used JPEGs earlier on. So you should know how to do that. And this is an input field. You have to figure out
what kind of type it is. I think you might have a clue. This is a button on the left hand side. And this is also a
button. So basically it is these four tags you need to create in order to build a clone of the world's biggest
website. So go ahead and do that. Start down here and ignore the line up here. And then when you return back to me, I
will of course show you the solution as well. Good luck. Okay, hopefully that went well. If not,
no worries. Let's do it together. So, starting with the image tag for the Google logo, I'm going to do img like
that. And it's a self-closing one. So, I don't need a closing tag, but I need a source attribute. And it should point to
the Google.png file. So, I'll just do Google.png like that. And let's run this. And ooh,
there we go. We got the logo. Okay, moving on. Let's do the input field. Also, a self-closing tag.
running the code and there we go. We have a input field looking pretty good. Okay, next up there's the two buttons.
One saying Google search and one saying I'm feeling lucky. So I'm going to add both of these button Google search and
then since I'm lazy I'm going to copy it and do I'm feeling lucky like that. Let's run this. And there we go. We have
a Google clone with just four HTML elements. So, if you did this, give yourself a pat on the back. It is
fantastically well done. You should really be proud of yourself. And if you didn't manage to do it, just try it
again and I think you'll make it. At this point, it might be a good idea to take a little break and digest
everything you've learned. And then when you are ready to continue, I will see you in the next scrim.
Okay. Now that you've built google.com, you probably want to showcase your project on some kind of portfolio page.
So, let's pretend we're creating exactly that. Here we have the index.html page, the main page of our portfolio. And as
you can see, it says Pier Harold Borggan, developer, teacher, procrastinator. So, a really good
description of myself. Though, what it lacks is some kind of page or section which describes my projects. though I
have actually created the underlying page for exactly that over here on work.html.
As you can see, this is a few tags that describes my google.com project. However, there's no way for the users to
know this. The only way they can get to this page now is by actually typing work.html up in the browser here and
then it is rendered. We don't want that. Instead, we want some kind of link from the index page that is this one that
points towards the work.html. HTML. And in order for us to achieve that, you have to learn about anchor tags, aka
links. An anchor tag is simply an HTML tag with an A. So, let's open and close an anchor tag and write, for example,
check out my projects here. Like that. If we run this, it seemingly looks just like our
paragraph. And we can't click it either. And that is because for anchor tags, you also have to provide it with an href
attribute. That's short for hypertext reference. Really fancy, scary looking word right there. Don't worry about it.
All this attribute does is decide where the link should point to. So if we do equal and then two quotes, we can inside
the quotes simply write work.html. If we now run this, you can see that it renders as a link. And when we click it,
boom, we're taken to the work.html HTML page. Really nice. Now, another thing I want to show you with with anchor tags
is that you can nest them inside of other tags and actually inline in a text block. So, let's say that we want to
link to google.com from this site. Then, we'll create a paragraph, which can say something like check out the live demo
here. And we only want the here word to be a clickable link. Well, then we'll simply wrap the anchor tag around here
as well and we'll close it before we close the paragraph. And then we'll do the href paste in the URL to google.com.
Now, this is a link that points to an external website, not to any of our pages. So, if we run this, you can see
that the link is now only over the hairword. However, if I click this link now, the Scribba mini browser will try
to head over to google.com and we only allow the mini browser to render Scribba projects at the moment. So, that won't
work. Instead, what I'm going to do is make this link open in a new tab. The way we do that is through a new
attribute. So, first I'm just going to break this into a new line just to improve the readability a little bit.
And then here I'm going to write target equals blank. Now, that is a cryptic way of
saying that you want the link to open up in a new tab. I know. But if we now run this, if you click on this link, what
you'll see is that in your main browser, a new tab will be opened at the Google.com homepage. So, I'm not going
to go deeper into why it's called target equals blank, but this is the way to do it. I of course wish that HTML had a
better solution for this. for example, new tab equals yes, that would have made a lot more sense to me. But this is how
it is. You just have to accept it. Okay, that was a lot of talking for me. Now, it's time for a challenge. I want you to
create an anchor tag that links back to the index.html page because if a user ends up on this page, they also need a
way to get back to the main page. So, create that link here however you want and then I will show you the solution
when you return back to me. Okay, hopefully that went well. Let's create this anchor tag. I'll wrap it
inside of a paragraph and write turn to homepage and then I'll simply wrap the homepage word in an anchor tag like that
and point that anchor tag to index.html. If we run this, you can see return to homepage. And if we click that, we are
back at the homepage. Great job. Let's move on. Okay, we're back at our Google example
here. And now I want you to add a anchor tag to the page because sometimes you'll see that Google adds a little text
underneath the buttons. For example, something about privacy like we protect your privacy then with a learn how link
that you can click on to read more about that. So that is exactly what I want you to do. I want you to add an anchor tag
that points to blog.html. As you can see, I've added a blog.html file up here. And I want you to wrap the
link inside of a paragraph tag. So, just as it is here, you can see it's an entire paragraph here, but the anchor
tag is only wrapping the second sentence. So, go ahead and do that right now.
Okay. Hopefully that went well. Let's do it. We'll start with the paragraph opening and closing tag. and then do we
protect your privacy like that. And here we're going to add the anchor tag in line. So I'll do a open and close and do
an href as well. Point it to blog.html and the text should be learn how. Let's run this. And boom, there we go. We have
added a nice little link here. If we want to learn more about Google privacy, then we can click this link. But not
much to see here. Turns out that privacy probably isn't as important for a company who makes money by showing ads
to users. Anyway, we can click on this link, return back to Google, and there we are. Great job solving this
challenge. Let's move on. Okay, now we're going to talk about how to structure HTML documents because the
structure we have here isn't actually correct. It's a very simplified structure compared to how it should be.
Though it does work. So, I didn't want to give you all of these theoretical boring structure things up front. I
wanted you to build stuff from the get- go without the added complexity of the proper HTML structure as my philosophy
is first make it work and then make it better. However, now we're at the point where we should make it better. So,
let's have a look at how to structure HTML documents properly. And HTML is actually quite like us humans. It has a
head and a body. And what do you place inside of these elements? Well, in the body, that's where you place the tags
you see on the page. And that is these tags here. So, our image, our input, button, paragraph, and our anchor tag
because these are visible on the page. Now, of course, the CSS styling up here also results in a different layout, but
the link tag in itself is not something that is rendered on the page. So, it should not be in the body tag. So, let's
just add the body right here. We'll add the starting tag and then the closing tag down here on line nine. And then
we'll indent everything inside of the body like that. So, moving on to the head. That's where we add metadata. And
what do I mean about that? Well, it can be many things. For example, styles. So, this link right here should be inside of
the head. We'll do head and then close it off here like that. Other things we'll have in the head is the title tag.
So let's have a look at what that is. If we navigate over to the BBC football page and zoom in on the top, you can see
up in the tab, it has a icon. It says football-b icon at the beginning here and this
sentence is controlled by elements we place inside of the heads tag. So if we want to add a title text in a tab,
simply write title and then for example google.com would be natural to write here. Though we haven't implemented tabs
in the mini browser here on screen so you won't see that. But had we done that it would have looked like this though of
course would have said google.com instead. So we don't need that. So let's just remove it. Another thing that is
controlled by tags inside of the head tag is how articles are shown on social media. So if we zoom out a little bit
here and click in on this article at the top here and if we now were to take this URL and share it for example on Twitter,
what we then would get is a different heading on the Twitter card than what the article natively has and also a
different image than the main image on the article. So this is metadata that has told Twitter that if this article is
shared on Twitter, we want you to use this heading instead of the heading that is inside of the article. and also this
image instead of this image right here. So that was a lot about the head tag. We're not going to use the head that
much, but I wanted to give you an understanding about why it is important. Now there's one more HTML tag we need
and that is the HTML tag in itself which should wrap all other HTML tags. So we need to up here at the very top write
HTML and at the very bottom close it off and also then indent everything inside of it like that. And then there's one
more thing which is to me a little bit annoying that we need that is the dock type declaration because you have to
tell the browser that we're actually using HTML 5 and not HTML 4. That's just a version of the HTML specification and
that is done by this line up here. You can see it's blue and it starts with an exclamation mark. So, it's actually not
an HTML tag. It's just metadata for the browser. Because if you don't do this, the browser will assume that you're not
using HTML 5, but an earlier version of HTML, and that might result in some quirks on the page. Though, in 99% of
cases, there will be no difference between adding this and not having it. So, at times, you'll probably see
tutorials on Scribba where I've forgotten to add this because for the purposes of our example, it won't make
any difference. But if you have something that you want to deploy to the world and have in production, then you
just have to accept that you need this sign up at the top. And sometimes you'll see people write it in capital letters
as well. Doesn't really matter. I prefer having lowercase letters. Okay, that was a lot of theory. It's time to get your
hands on the keyboard. And luckily though, we have a blog.html file which doesn't have the proper HTML structure.
So your challenge is simply to add the proper HTML document structure to this page. And I don't want you to copy paste
my tags, but write them out on your own instead so that you build up that ever so important muscle memory. Go ahead and
give this one a shot right now and then I will of course do it myself when you return back to me.
Okay, let's do this. I'll start with the body as that should wrap our visible elements on the page like that. Then
I'll do the head. Though we haven't linked to the styles on this page. So the head will actually just be empty
like this. So I'll keep it on one line. Moving on. It is the HTML document. And that should wrap everything. So I'll do
like that. And at the very end, I'll add the dock type HTML to tell the browser that we are working with HTML 5, not
HTML 4. So if we now navigate over to the blog.html site, you can see that nothing has seemingly changed. And as
goes for the main page itself. This structure we've added doesn't result in any visible change. We just have a more
correct underlying code file to work with. Great job. Let's move on. Now you're going to learn about lists
because let's say that you for example want to create some kind of tribute site. It could be for whatever. For
example, uh I don't know the Beijing Winter Olympics. If that's one of your interests, you might want to create a
tribute site where you list out the top nations who competed or something like that. And if so, you would have to use
an HTML list. So, let's first just figure out which nation actually won the most medals in the Beijing Olympics. So,
I'm going to click on the medals tab here on the Olympics site. And here we got it. And zoom in a little bit. And
oh, wow. It turns out that actually Norway, my country, completely obliterated
the other countries with 16 gold medals over other nations like Germany, China, and the US.
That is really astonishing, especially consider the fact that the size of the Norwegian population is this compared to
the other nations here. I mean, way to go Norway. We got to create this list in HTML. Okay. So, how do we do that? Well,
we have to use two different tags. One tag for wrapping the entire list and another tag for each list item. The
wrapper tag is one called O. That's short for ordered list. And then inside of the ordered list, we place the list
items, the li. So when we do this and write Norway here render this you can see that the browser
gives this a number as it is the first item in the list and also indents it a little bit from the left hand side. So
adding another one here it then gets the number two and is stacked below the first one. So let's add the final ones
like that. Looking pretty good. We have a list just like on the Olympic site. Now, if we wanted to be a little bit
more diplomatic here and not brag too much about this insane victory by Norway, we could change this O to a UL.
That is an unordered list. And as you can see, then the numbers are replaced with dots. And now you might ask
yourself, well, why do we need these unordered list? They look like kind of boring elements you just use in Word
documents or something like that. Well, once you learn about CSS, you'll be able to style your list however you want and
thus make it much more usable. If we, for example, head over to BBC Sports here and rightclick on the navbar here
and click inspect, then we'll see that actually this entire navbar is an unordered list item with each of the
categories being its own list items. So, lists are all over the web and important to learn. Okay, now I'm going to remove
all of this and give you a quick little challenge because I want you to create an ordered list inside of the body tag
and then fill it with your top three favorite foods. So, go ahead and give this a shot right
now. Okay, hopefully that went well. Let's do it. So, we start out with an O tag that
we're opening up and closing. And as for the list items, even though Norway is a great Winter Olympics country, it is a
truly mediocre country when it comes to food. So, my favorite food is definitely from other places than where I'm from. I
love Italian pasta. I love Japanese ramen soup. And lately, I've been really into pai.
So, there we have it. Rendered out on the page. Really good job learning about HTML lists. Let's keep up the pace and
move on. Okay, now you have arrived to the main project of this section. You are going
to build a website about yourself and we're going to personalize it as well plus deploy it to the world so that
anyone around the world can visit this website. It is going to be so much fun. And here is the website itself. As you
can see, it's pretty simple with hardly any styling by default. Just a little bit on the button and the input field
here. as with the border around this image. And building this lightly styled design is the first part, part one of
the challenge. And then in part two of the challenge, we are going to go crazy on the styling with just a few
parameters that you are to tweak and it's going to look so cool. But let's not get ahead of ourselves here. Let's
first just run through what kind of tags you need in order to build this website. So, first off, there is an image tag and
the image you should use should be added to the file system on the left hand side here. As you can see, there is a
pair.jpeg image here. And the way to add an image to this file system is simply by drag and dropping it over this
section. Next up, there's an H1 here as well with a title. Of course, you should write your own name, not my name. And
then there's an H2 heading as we need some fun facts about you. The fun facts itself are built using an unordered list
plus list items inside of the ul element. And then there is a paragraph with a link nested inside of it that
should go to your LinkedIn profile. So the point here obviously is to replace all of this information with fun facts
about you with your name with your image your LinkedIn profile so that when you share this with the Scribba community
other people will be able to get to know you better. And then finally, we have an input field here and a button that won't
really do anything cuz we're not hooking this up with a real newsletter. We are just pretending that you have a
newsletter that people can sign up to. So once you've done this, you've completed part one of the challenge and
you've also filled up this body element here with HTML tags. Next, you'll move on to part two of the challenge. What
you'll do there is take your existing design and modify it. So, if we head over to the index.javaScript file, you
can see that there are a bunch of so-called JavaScript functions, which probably look really scary at this
point, but don't worry. The only thing you're going to do here is take the word that you see inside of the quotes right
here, and replace them with one of the words that are commented out in the line above. because this will give you the
opportunity to change the styling on the page according to what word you change this argument to. So what you are to do
here is look at the name of this function. It says favorite movie genre and what is that? Do you like space
movies, scary movies, military movies, romantic movies, cowboy movies and so on. And then just take your preference
and change it like this. So if you choose cowboy for example, what then will happen is that the font on the
website suddenly became like a western movie. That's pretty cool. And moving on here you are to answer what is your
favorite fruit? Is it watermelon, tomato, banana? If it for example is banana, then you should replace regular
with banana. And what will then happen? If you run the code, then suddenly your page is banana colored. Really nice. So
now you are a cowboy banana. That's pretty cool. Finally, there's two more parameters you can tweak. First, tell me
is your favorite mode on your computer. Light mode or dark mode. If you choose dark and run the code again, then you
can see the colors have flipped and now it is primarily dark with the brown background and the light yellow color as
opposed to how it was previously with the yellow background and brown text color. And then at the very end, you are
to choose what kind of style you like your edges to be. Sharp, soft, or round. Let's say you like round. Well, then
you'll simply replace sharp with round. And there we go. We have a nice round layout where the image and the input and
button now have a much more round feeling to it. So, what happens here is that these are JavaScript functions that
execute code, which you can see further down in the index.js js file and change the layout accordingly. Though, you
should ignore everything below this line. Don't even try to understand it. It's far outside the scope of this
course and you're going to learn JavaScript later in the front-end developer path anyway. So, it's nothing
for you to worry about right now. Now, I'm going to reset all of these. Set these two to regular and these two to
light and sharp as that is the default styling that we should have. And then I'll leave you with this image right
here as it now is your turn to build this layout, personalize it with the JavaScript functions so that you have
your very own completely unique website. So go ahead and do this right now and then I will see you when you return back
to me. Okay, hopefully that went well. Let's now do this together. First, we need the
image tag. So I'm going to do img. The source is the pier.jpeg which I'd already added. Yes, there we
can see it is rendering properly. Next up, there is an H1. I my name is Pear like that. Very good.
Moving on, we have the H2 fun facts about me like that. And then there's the unordered list and the list
items. So, I'll do ul close that ul because the list items need to be inside of the ul and the first one is 36 years
old. I'm going to copy this one like that. And I live in Norway and I sing in a choir.
And there we go. Looking pretty good. Next up, there is the paragraph with the inline anchor tag. Here's the paragraph.
connect with me on LinkedIn like that. Oops, it should say me on LinkedIn here. And then we are to wrap LinkedIn here
into an href like that. And then I'm going to paste in the URL to my LinkedIn right here. And if you actually want to
connect with me on LinkedIn, feel free to click on this link as soon as I've added the target equals
blank so that it opens up in a new tab. Okay. Finally, we we need to add the input and the button.
Input type text like that and button with join newsletter as the text. Yes, that worked. And we finally just
need the placeholder in the input. And here we're going to write enter email. Enter email. Like that. And that
actually looks pretty good to me. That is what we were looking for. Yes. Okay. Next step.
We are going to personalize it. This will be easy for me. I really love movies about space. So I'm going to
choose space here as my favorite movie genre. It gives me this really neat sci-fiish font. And I am a huge avocado
fan. So, got to do that. Woo! Looking pretty good. I tend to prefer both light mode and dark mode, but let's try dark.
Yeah, not bad. And as for favorite edge style, I'm not going to do completely round, not completely sharp, but
something in between, as I think the answer often is something in between. And yes, there we go. Pretty cool
website. Now, the final thing I want you to do is head back to your note where you created your website and then click
on the bottom right icon, the cog wheel, and choose download as zip because that'll download your project to your
local machine. And we need that in order to deploy this project over the next few scrims. So, what I'd recommend you to do
is on your computer, create a dev folder and move that zip file you just downloaded to this dev folder. Double
click on it to open it. That'll give it this long obscure ID. So if I were you, I would change that to something
understandable, for example, personal site and just save it so that you have your project neatly placed with a good
name on your local computer so that we are ready to share it with the world over the next few scrims. It is going to
be epic. So I look forward to see you in the next scrim after you've done all of this. I'll see you there.
In order to get your personal site live on the worldwide web, we are going to use a service called Netlifi as it is
both free, easy to use, and powerful as it's used by tons of professional developers. So, if you're following this
course on scrimma.com, just click on this slide right here and you'll be taken to Netlify. Or if you're following
this course on YouTube, just head over to netify.com and you'll get to the exact same page. Once you're there, I
want you to click at the sign up button as that'll take you to an authentication screen where you can choose a bunch of
different options. I am going to go with the email option. So, I'll click on that and fill in my email and also choose a
password. Then I'll click sign up, which again will trigger Netify to send a verification email to my inbox. So, I'll
head over to my inbox and click on verify email. That'll take me to the Netlefy onboarding page where I have to
tell them a little bit about myself. So here I'm going to say that I'm using Netlefi for personal reasons. And
opening up this select box here, I'm going to classify myself as a hobby developer. And my first project will be
a personal/portfolio site. Then I'll scroll a bit down and give my team a name. I am just going to
call my team pair as it's common to use your first name, but you can choose whatever name you want on your team.
Once you're done with all of that, click on the setup and continue. Then you are taken to the page where you are to
deploy your first project. You can either import an existing project, start from a template, or deploy manually. And
that's exactly what we are going to do. So, what I want you to do here is return back to the folder you created in the
previous scrim called personal site. And then mark all of the files and drag and drop them into this rectangle. Once
you've done that, your browser might ask you if you actually want to upload the files to the site. Just confirm that by
clicking on upload and then Netlify starts its magic. At this point, they are working under the hood deploying
your site to the web. So here you might have to wait for a couple of minutes until you see this icon right here turn
into a screenshot of your personal site. Now if that doesn't happen within a couple of minutes, just try to refresh
the site itself as that'll probably do the trick. Then you can simply click on this URL right here and boom, you have
deployed your site so that anyone in the world can access it. That is a phenomenally great job and you should
truly be proud of yourself. The final step I think you should do now is to share your creation with the world. I
would recommend you to use either LinkedIn or Twitter as both of those have huge communities of developers. So
what you should do is basically what Jolene and Jess are doing here. Share a link to your personal site. Write a
couple of sentences about it. And also feel free to mention anyone else who've been involved in this project and add a
relevant hashtag like Jess is doing here. For example, 100 days of code. That that is a great hashtag to follow
and to use as it puts you in touch with a bunch of other people online who are going through the same learning journey
as you are. So I am looking forward to see your personal site either on LinkedIn or Twitter. And I'm also
looking forward to see you in the next scrim. Guess who is my favorite person in the
world right now? You are because you have just completed the HTML section of this course and that is a huge
milestone. So now let's have a look at all of the awesome things you've learned. Starting out you learned about
the core HTML tags that is the heading H1 H2 and so on and also the paragraph tag. And then you learned about nesting,
which is how some tags are inside of other tags, which again are inside of yet other tags, eventually creating a
tree structure of HTML tags. Then you learned about buttons and input fields, which are the elements that make your
website interactive. And then we talked about anchor tags, a super important concept as it allows you to create links
between different websites or web pages on the web. And then of course we had to learn about proper HTML document
structure as that is important with the doc type declaration the HTML tag head tag and also the body tag. From there,
we moved on to lists. Both unordered lists like this one right here and ordered lists, which is super cool and
almost as cool as what you followed up with, which was to deploy your personal web page to the web so that anyone
around the world can navigate to it and check out your creation. This was a lot of learning. I completely understand if
you're a little bit overwhelmed right now. And it's totally okay to now take a break, relax a little bit as in the next
section you are going to learn about CSS aka cascading stylesheets. That is how we design our web pages so that they go
from the dull default HTML styling into being beautifully designed, polished products that people enjoy looking at.
So super exciting times ahead of us. So when you are ready, I will see you in the CSS section.
Welcome to the second section of this course where you are going to graduate from HTML into the world of CSS or
cascading stylesheets as it stands for. This is super exciting because now you'll be able to make your sites look
beautiful as well. So the main project of this section is actually the google.com homepage because this time
around you are going to write the CSS as well. And this probably looks a little bit frightening right now, but don't
worry. I'm going to take you through it step by step. And actually, before we get going with Google, we're going to
get you familiar with the syntax here and have some fun destroying vikipedia.org.
So, it's going to be a lot of fun and we have no time to lose. Let's just get started.
Okay, so let's get you writing your first lines of CSS straight out of the gate. As you can see here, we have an
HTML file which has a body that simply has please accept our cookies as text directly in the body tag and that is
rendered here in the mini browser. However, as you'll notice, the style doesn't exactly look like default
browser styling. And that is because we've added this line here which says link meaning it's linking to something.
And what kind of relation does this link has to our HTML? Well, it's real stylesheet. It is a sheet that contains
styles. And where does this sheet live? Well, that is dictated by the href attribute, which you probably recognize
from anchor tags. And it's pointing to styles.css. And lo and behold, in our file system,
we have a styles.css file. And there we can see a few lines of scary looking code you've never seen before, perhaps.
However, don't worry. We're going to go through this. So what happens here is that this CSS code is being pulled into
the HTML file by this line three here and then it is applied to the website when it is rendered. So if we were to
comment out this line three here and rerun the example, it'll look very boring like this. So let's undo that.
Doesn't exactly look great now either, but it's at least some styling. Although this cookie widget is a little bit
weirdly designed in my opinion, which leads me to your challenge. You are going to redesign this cookie widget by
changing the values inside of this body selector. And now you might ask, well, what is a selector? Okay, let's go
through that because that is the basic CSS syntax you need to know in order to solve this challenge. So CSS works by
selecting certain elements on the page that is HTML elements and then styling them however you want. And the element
you select is what you start with when writing a CSS rule. Here we are selecting the body. That is the exact
same thing we're doing here. And what's our body? Well, it is this tag right here. Then in order to apply some
specific styling to the body tag, we write an opening curly bracket and a close curly bracket. And then inside of
those brackets, we have something called a property, which in this case is color, and a value, which in this case is red.
So here we're saying that the color, which is actually text color, that's what color means here. The text color in
the body should be red. So if I now change the color property from blue to red, you can see in the main browser we
have changed the text inside of our body to red because if we head over to the HTML, this text is indeed inside of our
body. Now as you might have noticed as well, the property is followed by colon and
the value is followed by semicolon. And you have to have that notation, otherwise you'll break the example.
So, what I want you to do now is redesign this cookie widget. Make sure you change all of the listed CSS
properties. That's background color, font size, font weight, text align, and margin top. And what you'll change it to
is up to you, but I've given you the hints of what kind of values the properties expect. Here in the comments
on the right hand side you can see comments in CSS is done with this star and slash character. So the gradeout
text as in with the HTML is not interpreted by the browser. It's just help text for you in order to solve this
challenge. And I'm intentionally not giving you any more information about what each of these properties mean
because I think they're pretty self-explanatory. So, I want you to experiment with changing them and draw
your own conclusions as to what, for example, the font size does to the styling on our page. And then once
you've done this, once you've redesigned the cookie widget, move on to the next scrim. And then I will show you how I
would do it as well. Good luck. So, really good job writing your first lines of CSS. That is no small
accomplishment. Now, I'm going to show you how I would design my cookie widget. So, I want my widget to have cookie
colors. So, for my background property, which is what sets the background color of the body, which fills up the entire
browser at this point, I'm going to choose a color called saddle brown. Like that. And you might wonder, well, how
did I know that saddle brown is a color that CSS supports? Well, you might have noticed as you wrote CSS values that VS
Code, our editor, starts suggesting values for you as you start typing. So that is how I found Saddle Brown. This
suggestion box here isn't recorded by Scribba itself. So you won't see it in recording, but you will see it as you
interact with the code yourself. So we have the background. Now let's move on to the next property, which is color.
And that dictates the color of the text. It is set to red. Though let's choose white here. That looks pretty good. The
next one, font size dictates well the size of the font. And here you can see we are using px values which is short
for pixels. And you can choose whatever value you want. Let's see what happens if we increase it up to 200. Oh wow,
that is far too big. So instead, let's try something like 25. Yeah, that's pretty good. Next, there's the font
weight. You can choose between lighter, normal, or bold. And if we change this to bold, you'll see there that our text
suddenly got a bit thicker, which is exactly what this property does. It changes the thickness of the font. Okay,
text align. It is set to right, but we can also set it to left or center. Let's see what happens if we do left. And that
bumps the text over to the left hand side. I think we should have our cookie widget with centered text like that.
Finally, margin top. What does that do? Well, if we try to change this to, for example, 50, you can see that. Oh, wow.
That created more space here at the top. So it adds margin aka spacing at the top. And here I think maybe 50 was a bit
too much. Let's do 30. Yeah, that is just right. Now you probably ended at a completely different styling than this.
That is okay. The point here was to experiment. Before you leave, I'll give you a sneak peek at another tool you can
experiment with, and that is a different way of describing colors in CSS called hex codes. So here I'll paste in this
weird looking code starting with a hashtag. And as you can see it created the exact same color. So this here is
actually a recipe for the saddle brown color. And it's actually a description of three different things. How much red,
green, and blue this saddle brown color consists of. So if I change this eight here to one instead, you can see that
completely changes the color. Now if that is confusing, don't worry. You'll learn more about that later. I just
wanted to give you a sneak peek on it. As with all of these other properties, you are going to get more comfortable
with all of this. So, it's not a problem at all if you completely forget about all of these properties and values over
time as you do it again and again. It'll become a part of your muscle memory. So, with that, let's carry on.
Now that you know enough CSS to be dangerous, let's use your newly acquired superpower in order to destroy
Wikipedia. And for that, we need a Wikipedia page. And about the coolest one there is is this list of helicopter
prison escapes. I mean, oh my god, how insane is that? So, click this image and you'll be taken to this article and then
I'll show you step by step how we can destroy it with CSS. So the first thing you need to do is to right click as
that'll open this menu where you can choose inspect and once you click that the dev tools will open. Then choose the
icon in the far left as that allows you to use your cursor to select elements on the page. So that when you hover over an
element like this one, you'll see that the dev tools selects it for you. So if you move your cursor over to the logo,
you'll see that one selected. And if you move your cursor over to the main part of the screen here, you can see it
selects the entire article. Once you're on that selection, I want you to click because that'll select the specific HTML
element here in the elements tab. And don't worry about all of this. You do not need to recognize the tags and
attributes and everything you see here. What I instead want you to do is head over to the right hand side where you
see element.style. Click there and you'll be able to actually apply CSS directly to this page. So you can, for
example, write background red and boom, there we have really ruined this article. Then if you select another
element on the page from this body content element here, you can do the exact same thing. Click on the element
style and now for example write font size and 30 pixels. And there you go. Now you can click on the X icon in the
far right corner here and then you can read about these helicopter prison escapes with a really bad background and
huge text if that's what you prefer. So feel free to spend an hour in this article and then I will see you in the
next scrim. Okay, so now it's time for you to yet again build the google.com homepage, but
this time around you're also going to write the CSS so that you'll understand everything that goes into building this
elegantly designed search engine. As you can see, I've set up the basic skeleton here in the HTML file for you. In the
body tag, we have an image which is pointing to the Google.png PNG image which lies in the same directory as our
index html folder up here. And we have an input type text which is our search field. And we're only going to start
with these two elements and then later move on to the buttons. Now, as you can see in the mini browser here, this looks
horrible. It has no styling. So the logo is far too large. The input field doesn't look very good. So in short,
there's a lot of work to do here. But before we can start writing CSS, you need to link to the CSS file. You can
see I have a style CSS here which just sets the background of the body to red as a way of testing whether it is
actually a link to the HTML. Currently, it's not. You are going to have to link to the CSS file on your own. And if you
remember a couple of scrims back, I showed you how to do that. Though, please don't look back at that scrim in
order to solve this challenge. Instead, Google it because I do that almost every single time I have to link from an HTML
file to a CSS file. So, you should not be ashamed for googling such a quote unquote simple thing. Instead, just do
that right now because it's important practice and then when you come back, I will show you how I would do it as well.
Okay, hopefully that went well. Now, let's have a look at how we can solve this. So, I would simply type how to
link to CSS into Google and click at the top result. This happens to be a W3 schools article. Here you can see that
there's a few different ways you can import CSS into the HTML file, but we're only going to worry about the first one
here called external CSS. As you can see, if we scroll a bit down, what we do is we type link re equals stylesheet and
href with a pointer to the CSS file itself. So we'll do link file equals stylesheet
href equals styles.css and then closing it. And if we now refresh the browser, boom, there we go.
It is red looking horrible. So we can remove that so that it looks white again. But now we know that we have
linked the CSS and the HTML together. So we are ready to move on and start styling our page.
The first thing we want to fix in our example here are the widths of the elements. Because if we compare it to
the finished design, you can see that the input field is meant to be wider than the logo. However, in our example,
that's not the case. Quite the opposite actually. The logo is much wider than the input field. So, we need to shrink
the logo and then make the input field wider. So, I'm going to start and do one of these and then you will do the other.
I happen to know that the width we want to have on this input field is 400 pixels. What I'm then going to do is
target the input field using the element name and create a CSS selector just writing input then open and close curly
bracket. Then simply write with and 400 px and boom there you can see suddenly the input field widened quite a lot. And
as you might have noticed, we're using this pixels value here again, which we've used a couple times already,
actually. And if you're a little bit confused as to what a pixel is, you can think of it as the smallest unit of
space that our screens can render. So a pixel is just a tiny square. So tiny that we actually need 400 of them
stacked up besides each other in order to get a width of this size. So with that, I want you to fix the width of the
Google logo. Select the image tag and set the width of the logo to 300 pixels. Go ahead and do that right now and then
I will show you how to do it as well when you return back to this scrim. Okay, let's do this. I'm going to break
this down into a few lines so I get some space above the input field and then target the img element, the image
element. open up the curly brackets and do with 300 pixels. Like that. Oo, we're not quite yet at the finished design,
but the ratio between the logo and the input field is now a lot better. Great job. Let's move on.
Okay, I've discovered a problem with our Google site, which is that if we make the browser really wide, you can see
that suddenly the items stack up besides each other on the same line. And that's obviously not the kind of behavior we
want. We want them to always be stacked on top of each other. And in order to fix this, you have to learn about inline
elements versus block elements. And that's best understood through the lens of an example. So let's say that you,
for example, have a collection of things you want to showcase. You could be like George Francen, for example, and collect
dinosaur poo. He actually has the world's largest collection of fossilized feces, and naturally, he wants to
exhibit them in a museum. And if he were to use display inline on his images, they would stack up besides each other
like this. So kind of like in a line horizontally. However, had he used display block on his images, then they
would stack up on top of each other. So rule of thumb is display block stacks on top. Another way to look at this is that
the block level element blocks out the rest of the available horizontal space so that nothing else can be placed
there. And that is regardless of how wide this image is, the content itself, display block requires control over all
the horizontal space in its given container. So when this block image is placed here and you add a new image, it
would have to be placed underneath the previous one. And if it is display block as well, it'll block out the rest of the
available horizontal space and the next image have to be placed below that one again and so on. So the solution is
obviously to turn these elements into blocks and I'm just going to give you the syntax here. This is how you write
it. Display colon block. Go ahead and do that for both of these and observe what happens to the example when you make the
browser wide. Good luck. Okay, let's do this. So I'll do display block up here and the same
here. If we look at the browser, seemingly nothing has happened. However, if we now make it wide, you can see yes,
no matter how wide the browser is, these will always stack up on top of each other. So, great job. Let's move on.
The next thing we need to fix is the lack of white space above our Google logo. Because if we take a look at the
design here, we want quite a lot of space in between the top of the browser and the logo. And I'm not going to tell
you how to add that, but if you can think back to the very first scrim in this section, we added some space above
the text in our cookie widget. And that specific space is called margin or margin top to be specific. So your job
is to add some margin on top of our image right here. You can start on line seven so that our example here gets some
breathing room, some white space above the logo and the input field. go ahead and give this one a shot and then I will
of course show you the solution when you return back to me. Okay, hopefully that went well. If not,
no worries. I really pushed you out on thin ice here. So, it's completely okay if you didn't remember that the property
is called margin top. And what you add there is a pixel value. So, for example, 100 px. And there we go. We've now added
a margin on the top of our image. And while we're still quite far off from our provided design here, we are getting
closer. Great job. Let's move on. Now, while it totally works to add the margin top directly on the image here,
you'd most likely not see professional developers do this because what they do instead is wrap these two elements in
some kind of container and then control the positioning of these elements indirectly via that container. And in
order to do this, you have to learn about the div. I'm going to create an opening div and then indent these two
and then a closing div below here. Now, if we run this code, seemingly nothing has happened because the div actually
does very little in itself. Though it is indispensable for web developers. Just to show you how important it is, let's
take a look at Facebook and my timeline. Here I've opened up dev tools and inspected one of the timeline items. And
you can see it is actually a div inside of a div inside of another div inside of yet another div inside of a div inside
of a div. Divs really do rule the world. So it's important that you learn about them. And
the way we'll use this div now is by removing the margin top styling from the image and then add it to the div itself.
And the reason this is important is let's say that for example Google decides to create a video here instead
or a interactive doodle or some kind of game. They often play around with the Google logo. Well, if so, it's a really
bad idea that it is the image itself that controls the margin from the top of the browser and down to the content
because that image might be removed. So, it is a solution that will get you into trouble in the future. So what we'll do
here is we'll simply instead target the div and then remove the margin top from the image and boom it has popped up. Now
we lost all of our white space but if we add it back to our div we are back at the design we started out with seemingly
nothing has changed but as you know we have a better HTML structure. So we have definitely made good progress here. So
with that, let's move on to the next scrim. The reason you need to learn about
classes now is because our current setup where we simply have the elements like this and then selecting the element
using the element selector in CSS will give us bugs down the line because when we add the two buttons beneath the input
field, we'll actually wrap these two in a div as well. And let's see what happens at this point. What I'll do now
is simply add the HTML for these buttons down here beneath the input field. So it is a div with two buttons inside of it.
And then you can see we are closing that div, the inner div, and then we are closing the outer div. Let's run this
code. And oh wow, what you can see is that the spacing between the input field and the buttons is totally off. And that
is because our CSS element selector here selects any div it can find in the HTML document and applies the margin top to
it. So it doesn't just select the first one, but it can select thousands of divs. So this is a very generic solution
and likely not something we want to use as we want to have multiple divs with different types of styling in our HTML
element. So let's now instead fix this by doing the following. I'll write class equals then for example main this here
is an attribute called class so it's built into HTML and this here is the name I'm giving my class I want to call
this div my main element and now the way I select that in the CSS is by instead of just writing the element name simply
doing dot main like that now if I rerun this code you can see now the margin top is only applied to the outer div, our
main class, and not to the div which wraps the two buttons. So that is exactly what we needed. Now I'm going to
remove these two buttons here because we don't want to deal with them just yet. And then I'm going to give you a
challenge. First, you're going to add a class to each of these two elements. That is the
image and the input. You have to decide what you will call the two classes, but make sure to give them different names.
And then you're going to in the CSS replace the element selectors with class selectors. So that is the img selector
here and the input selector here. And obviously the CSS class selectors you're going to replace them with is the ones
you have added to the elements right here. So go ahead and do this right now. Okay. Hopefully that went well. Let's
now do it together. So for the image tag, I'm simply going to do class equals. Then I'll call this logo dash
img. So here I'm using a convention where I'm first giving my class a descriptive name and then using a dash
and then specifying the element as well. This is an img element, but it could have been for example an SVG or
something else. Now I don't expect you to have followed the same convention. There are plenty of CSS conventions and
it doesn't matter at all what you used in your example. You can call your classes whatever you want. Okay, for the
input we'll do class equals search dash input like that. Okay, let's move through the CSS. Then I'll replace this
with dot. Now you can see it broke the layout because this styling now is not applied to any element. So we need to do
logo-ash img like that. And here do dot search dash input. And there we have the exact same example. Didn't change at
all, but we now have a more flexible solution that scales better. So great job solving this challenge. Let's move
on. Okay, now it's time to take a closer look at margins. And you've already
dipped your toes into this as you have used margin top. So, you might have some intuition about what margins do.
However, now you're going to learn it properly through creating flags with CSS because flags are just awesome. I mean,
take a look at this flag here, for example, from the Republic of Venice, a state which existed for over a thousand
years in Europe. And it contains, of course, a flying lion holding a book. I mean, what's more natural than that? Or
this one right here for the aisle of man. I mean, have you ever seen a more creepy creature than this three-legged
thing right here? Imagine having that thing running after you? That would not be fun. And this flag
would be really hard to create in CSS, actually. So, we're not going to create this one. We're going to start off at a
much easier level with just some very simple shapes. So, let's have a look at those. Actually, here is what we're
going to work with. As you can see, there are simply three divs inside of the body tag. And each div has a class
red, blue or green. If we check out the styles.css, you can see that these three classes apply a background color to each
of the elements and sets the height to 100 pixels. And here we have the result. Three rectangular boxes that are stacked
on top of each other. And that tells us that these are display block because display block stacks on top. There's one
thing that bothers me here, and that is that we have a little bit of white space around the three items. Why is that?
Well, actually, it's because our browser is trying to help us here. It's assuming that we want a little bit of space
around the body tag so that these three don't touch the edges of the browser. So what's actually going on here in code is
that the browser targets the body and sets a margin of 8 pixels. If you notice when I added this,
nothing changed. So if I remove this, it's still the same. Meaning that this style here is applied automatically. So
that means that margin is actually the space around an element because now if we change this to zero, boom, there you
can see suddenly our divs touch the edges of the browser. Now here at the bottom, they stop after 300 pixels since
we've told them to. So this margin zero here seemingly didn't change anything at the bottom because the bottom contains
white space anyway if we make our browser tall enough. But anyway, that's a digression. Let's get it back so that
the browser is completely filled up with these three items. And now let's play a little bit around with margins. So what
do you think will happen if I add a margin top of 10 pixels on the red hair? Take a guess.
Okay. Margin top 10 pixels. Boom. It added 10 pixels on the top. What do you think will happen if I add margin left
10 pixels as well? Let's try it. Okay, so it added 10 pixels on the left hand side, but it's only on the red
rectangle, not the blue or green rectangle. Likewise, if I do margin width 10 pixels, it adds 10 pixels to
the right hand side as well. If I do 100, it eats up almost a third of our red rectangle. Okay, so now it's your
turn. I want you to add 100 pixels of margin on the bottom of the red box. So, go
ahead and give that a shot right now. Okay, if you did margin bottom 100 px like that, I want to congratulate you
because you just created the flag of Monaco. Really good job creating your first CSS flag. And now, let's do that
yet again. Here is your challenge. You are going to create the flag of the Gambia. And here we have that flag.
However, there's a catch. You can only do this by applying styles to the blue box. So, by adding margin to this CSS
rule right here. So, go ahead and give that a shot right now. Okay. Hopefully that went well. The way
to do it is by doing margin top. Let's try 10 pixels and see. Actually, I think we want our white space to be a little
bit more than 10 pixels. So, let's do 20 like that. And then margin bottom as well. 20 pixels. And there. I think we
have a pretty good flag for the Gambia. Now, before we move on to our Google project, there's one little weird thing
I want to tell you about margin top and bottom. Because what do you think happens if I add for example margin
bottom of 15 to this red element here? Well, according to my logic, the margin right here would be 35 pixels because we
added 20 pixels on top of the blue. And if we add 15 at the bottom of the red one, that should be 35 pixels in total.
However, now that I added this, nothing happened. And that is because margin top and margin bottom will in many
situations collapse into each other. So that as long as this margin is smaller than this, this will take precedence.
And it's only when this one becomes larger, for example, 25, that it will kick in. So let's take it back to 15.
And to make things even worse, there's actually scenarios where this doesn't happen. However, digging into that is
outside of the scope of this lecture. I just want you to be aware of it because if you're suddenly in a situation where
your margins don't seem to add up, it is probably because of so-called collapsing margins. Okay, with that, let's move on.
Okay, we're back at our Google project. I want to give you a quick challenge. I want you to add some space between the
logo and the search field because as you can see here, there's some spacing in between the elements in our design.
However, in our project now, they are crammed together. There are two ways you can do this using margins and I want you
to think about which two ways that is and choose one of them. Go ahead and do this right now.
Okay, hopefully that went well. Let's do it. So, you can either add a margin bottom to the logo or you can add a
margin top to the search field. I'm going to go with adding margin bottom to the logo as I think either way is as
good as the other at this stage. Margin bottom. And how much do we want to add? Well, let's try 20 px. And yeah, as you
can see, we've got some spacing. The bottom of the G is not touching the top of the input field. And if we compare
that to the example, I think it looks more or less the same. So, great job. Let's move on.
Okay. Now you are going to learn about centering elements in CSS and that is a scary topic for a lot of developers. So
scary that this stack overflow question about how to horizontally center an element has been viewed 4.5 million
times. So if you think this is a little bit confusing, you are in very good company. So don't worry about it. So
with that in mind, let's move over to our example. You are going to center this dinosaur poo. As you can see in the
CSS, it has just one property set at this point which is a width of 200 pixels. That is because the image is so
wide originally that if I don't set that width, it'll just take up more space than we have available. And setting the
width of it is actually an important thing in order to center it because there are three things that need to be
in place when we are to center elements with the technique you are about to learn aka centering with margins. And
these three components are first the element needs to be display blocked because how is an element supposed to
center itself if it doesn't command full control over all the horizontal space. If it's display inline and allows other
elements to stack themselves besides the element, well then it won't be able to center itself because that space now is
busy with other things. So in order to center this poo, it needs to control all the horizontal space.
So it needs this block like that. Now that didn't change anything, but under the hood, the poo
now controls the full horizontal space. Okay, the second part is that it must have a width
and that is what we've done here already because how is this item supposed to be centered inside the browser if it is
wider than the browser itself? That's often what happens with either large elements or with some HTML elements who
just naturally actually expand to take up all the available space in the block. So we have to make sure that our element
has a width. And finally we set the margin on the left hand side and the right hand side to the value auto. Let's
just do that. Margin left auto. Oh wow. Now it pushed the pool all the way to the right hand side because auto here
means take up all the available space. And since this is a block element, the available space is all the space that's
left after the pooh has taken up its 200 pixels. So it just ate up all of the space and turned it into margin.
However, at this point, margin right enters the party. Margin right and says I want the available space as well. And
at that point, the margin left and margin right goes into discussion and decides, well, actually, since there are
two of us here pushing on each of the side of the element, trying to get all of the available white space, let's just
divide it evenly amongst both of us. And the result, well, it is that the item is centered. So, that was a long
explanation of centering with margins. If you feel confused, don't worry about it right now. All you need to do is
remember these three conditions and just be aware of the 4.5 million other developers who are in or have been in
the same boat as you. Let's move on to the next scrim. Okay, we are back at our Google project.
Now your challenge is to center the logo and the search field using the technique you just learned. So go ahead and give
that a shot right now and then I will of course show you the solution afterwards as well.
Okay, as you hopefully remembered, the way to center an element which is display block and has a width is by
adding margin left auto and margin right auto. So let's do that. Margin left auto. And as you can see, that
pushes the logo all the way to the right hand side because the margin left is set to auto and it takes up as much space as
it can. We do the same thing with the right hand side. Do margin right auto. Then the right hand side starts pushing
back again. And when they're both taking up equally as much space, the margin left and margin right kind of decides,
yeah, let's not argue anymore. Now we have a nice balance. And woo, lo and behold, our element is centered. So now
what we can do is be super lazy and copy that code and paste it in down here. And boom, our input field is centered as
well. And our project is starting to look a little bit like our finished design. So this is super cool. Let's
just keep up the pace and move on. we need to take a little step back and learn a new CSS concept which is the
close relative of margins called padding. And we're of course going to learn that through the lens of an
example. So here I have just a simple div which contains a little bit of text or specifically the two first sentences
in the white paper behind Bitcoin. And let's say we want to turn this into a nice looking card that people can read.
If so, we'd probably create a class call it card. Then of course in the style CSS, we'd select that card and apply the
styling. As for now, it just has one property set, which is the color that we've set to a shade of black that isn't
pure black, but a little bit softer, so to speak. That is because by default, the browser uses pure black as the text
color and pure white as the background color. And as a rule of thumb, you never want to have pure black on pure white.
That's not a pleasant experience for the eyes. So instead, we went for this. But that was a digression. Let's move on
with turning this into a nicel looking card. So a card needs a background color. So let's just do background light
gray for example, like that. And we also don't want our card to be full width because as you remember divs are block
by default and take up the full width if you don't specify any width on it. So we're going to do width for example 300
pixels like that. And then we also want some space above the card. That is of course margin top. Let's push it 50
pixels down from the top. And finally it should be centered. So, let's do margin left, auto, and margin right like that.
Okay. So, now we have something that looks at least a little bit like a card. But there's one problem here. You can
see the text is crammed all the way into the edges of the div, which doesn't look particularly good. And that is where
padding comes into play. So now I'm just going to apply the padding by doing padding and for example 20 pixels like
that. And as you can see, that created a little bit of space. Basically, some breathing room in between the text and
the edge of our div container here. And if I do 50, you can see it's even more breathing room. So, where's margin adds
space on the outside of our div, the card which we've selected here, padding will add space on the inside in between
the content and the edges of the container or the div. So margin kind of lives up here and down here if we are to
visualize this in our HTML whereas padding lives on the inside of our element that is here and here.
And now you might wonder well why did I just write padding whereas for margin we're specifying each of the sides. And
well you can do exactly that on padding as well. this padding 20 pixels right here is the exact same thing as writing
the following padding top 20, bottom 20, left 20, and right 20. So with these four lines, we can actually delete this
one up here. And then we have the same convention as we're using with margins. It's just that you can use padding 20
pixels like that if all of the values are the same. It's basically a shortand. And now that we have all of them written
out, we can play around a little bit with it. perhaps add a 100 pixels on the left hand side looks really weird and
100 pixels on the top as well. And suddenly our card does not look very good. But let's get it back. And now I
want to give you a challenge. I want you to add padding to make our card look like the provided design. And the
provided design is right here. You can see it's a completely broken card as we've been ruthless about our padding.
And I've actually removed all of the padding rules from the CSS as I want you to build some muscle memory writing
padding. So go ahead and make this card look like it does in the slide. And then return back to me once you've done it.
Okay, hopefully that went well. If not, no worries. Let's do it together. As you can see here, it's completely crammed
into the bottom left corner, which means that it doesn't have any padding on the left hand side or any padding on the
bottom, but a ton of padding on the top and a ton of padding on the right. So, I'm just going to do padding top 100
pixels, something like that. Yeah, seems pretty much what we have in the design as well. And then do the same padding
right 100 pixels like that. And to me that looks actually pretty much like our design. I don't need to write padding
bottom or padding left now. Though I could do it. I could do padding bottom zero pixels or just zero and padding
left zero as well. Though that didn't change anything. So it's actually not needed because by default the padding of
a div is zero. So however you solved this, great job. Let's move on. So now you've learned about controlling
the space on the outside of the element with the margin and on the inside of the element with the padding. But wouldn't
it be nice if we could also control the border in between the margin and the padding? And it turns out we can through
you guessed it the border property cuz if I write border here and then specify for example two pixels thickness solid
in shape and then color red you can see then we get a border which is on the outside of the padding but on the inside
of the margin. And if we change any of these three values here it'll update accordingly. So let's try 8 pixels width
instead. You can see it's much thicker now. Instead of solid, we can do a like that. Pretty weird. And instead of red,
we can do, for example, fff white in hexodimal or just write white like that or just blue so it's a little bit
clearer. Now, there are many types of borders, but in 99.9% of the cases, you want to use solid like that. And also,
very often, you'd want to soften up these corners. And you can do that with the border
radius property. And here you specify a pixel value, for example, 30 pixels. And boom, there you can see we have this
much softer corners. If we crank this up to 100 or a,000, it stops at some point because then the edges have simply
turned into half circles. So at some point, there's no use going any higher. Now, this looks pretty bad. So, what I
want you to do now is fix it up so that it looks like this. And I'm not going to give you any of the values I've used
here. Just a little hint. I took an already existing color in our box and used it for the border. That's a common
web design trick to reuse colors and not have too many different colors. So, if you think this is pure black, mm- you
are wrong. So, go ahead and change the values of the border and border radius so that our example here matches the
design. I've provided in the slide. Good luck. Okay. Hopefully that went well. So,
let's start with the border. 8 pixels here. Looks a bit too thick for me. So, let's try four instead. Like that. I
think that matches better. Yes. And the color I gave you a hint was just the blackish color we have for our text.
Like that. And the border radius is much smaller. Let's try 10. It's This still looks a little bit
rounder. So, let's try 20. Yes, there. I think we got it. Great job. Now, a cool thing to do in order to inspect the
margin, border, padding, and size of the element in general is to open up the dev tools, which can be done by
right-clicking on the navbar here and then clicking inspect and then this dev tools panel will open here, clicking on
the select icon on the left hand side and then hovering over the element. Finally clicking at it. There you will
see that we have selected the element in the elements tab and under the styles tab you can see the styling we have
applied using CSS. So here you can actually modify them if you want but we're not going to do that right now.
We're going to scroll down and verify that our margin border and padding are correct. So if I hover over the margin
here you can see up here in the mini browser it is marked in orange and the values are provided down in the box
here. If I move over to the border, we can see that border is now selected in the browser and it is indeed four pixels
as we coded up a minute ago. If I move over to the padding, you can see that is also indeed 20 on each side, just as we
want it to be. And finally, if I hover over the center here, the content is highlighted. And the content of this div
is just the text. And as you can see, it is 300 pixels wide, just as we set it as. So, it's working as expected. And
the height is dictated by how many lines of text are two sentences required. So using this technique of inspecting an
element and its sizing properties like this is a really good way of debugging if something for example looks wrong
because it gives you an ability to verify if the numbers here match up with what you've tried to write in your CSS.
So now that you've learned all of that, I want to tell you the name of this and it's actually called the box model. And
to be honest, I've never really liked this word. It sounds more complex than it is in my opinion. It's just spacing
around the element, a border, spacing on the inside of an element and the content itself, but in web development, we call
this the box model. So, you'll probably hear this name come up from time to time, but you shouldn't fear it. You
know exactly what it is, and you've used all of the properties in the box model. So, don't worry about it. Actually,
let's give you a new box model practice in the next scrim. I'll see you there. Okay. And now you are going to create a
really neat looking button, namely the following button on Twitter. Let's zoom in a little bit. And here you can see
it. This is the button you see if you already are following someone. And we zoom out again. This is the Scribba
Twitter profile. You should definitely just click this image and follow us because we share a ton of useful tips
and tricks and career advice for aspiring coders here. So, it's definitely worthwhile. Anyway, now you
are going to use the things you've learned about padding, border, border radius, and so forth in order to make
this button right here with the ugly default styling look exactly like this. Or not exactly, as we're not going to
worry about the font. It is a little bit different, but other than that, you should try to make it look identical.
I've given you some hints here. For example, the border color is this hex color right here. And the text color is
this one right here. And also, you need to remember to adjust the font weight. And I don't think you've done that ever
since the very first scrim where you wrote your first lines of CSS. So, you might have to look back so that you
figure out how to adjust the font weight. Or you can Google it. Up to you. Anyway, just go ahead and give this your
best shot. And if you at some point get stuck or don't know how to do it, no worries. We are going to do it together
afterwards as well. Good luck. Okay, hopefully that went well. Let's do it together. I'm going to target the
button just using an element selector like this. And now let's pick the lowhanging fruit, namely the ones we've
gotten here already. For example, by doing color and then copying this color right here. Okay, that didn't change
much, at least not visibly. Then let's do border. And I'm going to start with one pixel solid. And then the border
color right here. Like that. Okay. So it looks a little bit different now, but not quite this. One thing we can clearly
see is that this image has a white background whereas ours is still a little bit gray. So let's do that as
well. Background white. Okay. Yes. But our button is much more crammed. There's too little padding. Whereas here you can
see we have a little bit of padding on the top and the bottom and actually quite a lot of padding on the left and
right hand side. And that's actually a little design tip right there. What you'll often see is that buttons have
more padding on the left hand side and the right hand side and they have above and below. So let's try padding top five
pixels for example. Padding bottom five pixels. And then we'll try left 10 pixels. and right 10 pixels as well. How
does that look? Not too bad. But actually, it looks like this button has even more. So, we've added half as much
on the top and bottom as we have on the sides. So, let's crank up both of these a little bit. I'm going to select both
of these and do eight top and below. And select both of these and do 16 left and right. Yeah, I think that's more like
it. Now, one thing that definitely is remaining is the rounded edges here. So that is the border radius and add it up
here with the border. Let's try 10 pixels. It's a little bit round now, but not as round as the Twitter button. So
let's do 16. Yeah, more like it. Can we go higher? Yeah, I think we can go to 18. That looks quite good to me if we
compare to this one. And then finally, we needed to remember the font weight, which I can do font weight
bold like that. That looks a lot better. I think the final adjustment I want to make is adding even a little bit more
padding around it because now that I look at it, it feels like this is a bit more spacious. So, here we are really in
the nitpicking area. But let's try 10 on both of the top and bottom. And let's try 20 on the left and right. And what's
interesting now is that since the box now has grown in size because it's affected by the padding, the border
radius can also be cranked up a little bit. I think actually we can do 20 now. Yes, because the bigger a box is, the
more pixels you need to add in order to get this fully soft looking button which essentially has two half circles on each
of its sides. So looking at the example and comparing it with ours, I think we have reached our goal. And if your
values are different than mine, that does not matter at all. You're actually creating the button of a huge public
company here. You are just learning basic CSS. So, it's totally not expected that you create buttons as neatly as
Twitter does, as they probably have a team of developers and designers working just on this profile page. So, however
it went, be proud of yourself and get ready to move on with our Google project. I'll see you in the next
scrimm. Okay, we are back at our Google project and now you are going to fix the design
of our search field and you're actually going to get a design spec and a proper walkthrough of how I want it to look. So
here I've opened up the dev tools actually on the right hand side as I want to inspect the box model of this
element with you. And if you wonder how I managed to stick the dev tools to the right hand side here, just click these
three icons if you're in Chrome. Then you can choose the doc side. So let's move on down here to the box model of
the input field. And if I hover over the content in the box model here, you can see that it says 400 pixels * 24 pixels.
And you can see the content is marked in blue in the mini browser here. So that means that our width is 400 pixels. We
know that because we set it ourselves here. And the height of the content should be 24 pixels. Okay, let's move on
to the padding. If I hover over that, you can see it is green and it's highlighted in green in the mini
browser. The padding at the top and the bottom are 10 pixels as you can see down here. And the left hand side and right
hand side have 30 pixels each. And then if we move over to the border, you can see that it's simply one pixel all
around. So here is your design spec given to you by your hipster designer down in the bottom right corner here.
Height of content 24 pixels. But do remember that that is actually the height of the inner box here not the
height of the total input field as that also contains the padding and the border. But the height property should
be 24 pixels. The padding above and beyond as said 10 pixels right and left hand side 30 pixels. Thickness of border
1 pixel. The color of border is this. And then finally also the border radius is also a value that our designer has
been kind enough to give to you. So take this design spec and implement it using CSS.
Okay. Hopefully that went well. If not, no worries. We'll do this together right now. So starting with the height of 24
there. I'm going to just write height 24 pixels like that. Okay. So it became a little bit taller. Now next step is the
padding top and bottom was 10 pixels. So padding top 10 px bottom was also mpx like that. Okay. The
padding left and right hand side were 30 pixels according to the spec. So let's implement that like that. And then we'll
move on to the border. One pixel and this hex code right here. So I'll do border and here we have to provide it
with three values. So one pixel it is going to be solid and the color is d15 like that. Looking pretty good. The
final thing then is the border radius. And that should be 24 pixels according to the design. And look at this. It is
starting to look really professional. So really good job if you did this challenge. And if you did a couple of
mistakes, no worries at all. Actually, I also did a little mistake here according to best practices when setting heights
for input fields. Because actually, I want to show you that this height of 24 pixels here is actually not the way we
want to do it. Because if I Google set height of input field CSS and then click the first link, that is a Stack Overflow
question. And here you can see someone who's been having problems with this. So, they've asked a question about it.
If we scroll a little bit down, you can see that people are saying try with padding and line height. Hm. Line
height. That's not something we've used. If we scroll a little bit down, you can see that some browsers will honor a CSS
height rule, some not. So, it seems to be a little bit difficult to use height for the input field. And this person as
well suggests line height. And likewise with this third person here. So, I'm going to trust the wisdom of the crowds
here and use line height instead. like that. It didn't change anything, but we are using a property that more
browsers apparently will honor. And line height is actually just the height of one line of text. And since that is
everything we have inside of an input field, it's just one line of text. That'll be the exact same thing as
setting the height of the inner content of the input field. So, if that was a little bit confusing and you prefer to
just use height, that's totally fine as well. It's more important that you are using what you are comfortable with than
that you are doing it the 100% correct way according to conventions. So just use whatever you want. I just wanted you
to be aware of the fact that this is the recommended way according to Stack Overflow. With that, let's move on.
Okay, now we're going to add the first button to our Google project. So, I'm going to head over to the HTML and here
beneath the input field, I'm just going to type button like that. And this will be the Google search button. So, there
we have it. Doesn't exactly look good, but don't worry about that. Now, I want to give this a class as well. And a
class name you'll often see used for buttons is simply btn. Like that. Okay. Now that we have that, I want you to
center the button and add some space above it. So go ahead and use the class selector to select this button and solve
this challenge. Good luck. Okay. So what I'll do is do btn to select the button here. You might have
been tempted to simply do margin left auto and then margin right auto. However, that doesn't seem to do
anything. Why is that? Well, if you remember the criteria you needed in order to use this technique to center
elements, one of them was that you need your element to be display block. Whereas buttons are actually display
inline by default. So if we do display block, boom, there we go. The button is centered. And now you might ask, well,
what about the width? We also set the width on the input field and the logo. Well, we could do that as well with this
one. Let's do width 200 pixels for example. However, it's not needed because if we remove the width, you can
see that it still has a width which is certainly not full width across the entire page. So, it kind of has an
implicit width without us setting the width. So, even though it is a criteria that your element needs a width in order
to use this technique here in order to center it, you don't necessarily have to set the width yourself if the element
already has some kind of width. So it works perfectly fine just doing display block and margin left right auto in this
example. Finally we are going to add some space above it. So let's do that. I'll do
margin top and do for example 30 pixels. Yeah looking pretty good. Great job solving this challenge. Let's move on.
Now we are going to style the button in our Google project because as you can see this is how our button currently
looks. But this is how we want it to look. So, we got to do a bunch of changes. However, there's one thing I
want to change actually on this google.com homepage because notice how low the contrast is between the
background color of the button and the background color of the entire website. It's hardly possible to see that there's
any difference. And that's not good because it reduces the accessibility of the site and makes it hard for people
who are visually impaired to use it. And actually to prove this, let's take these two colors, the light gray here and the
white, and put them into a contrast checker online. For example, this one right here on userway.org.
They have this nice little contrast checker where you can paste in the foreground color and the background
color and then get a contrast ratio. And this F8 F9 F8 hex color is the one that Google is using. And if we scroll a bit
down, you'll see that Google indeed fails miserably on this test. Complete failure. The ratio is 1.05, though it
should have been 4.5 or more. So, not good Google. So, what we will do instead is change the background from this to
something like this. Here you can see it's much easier to see that it is indeed a button. So even though the real
background color is this one right here, we are going to use this one right here. So with that in mind, I want you to
style the button according to the provided design you now have. And the only hint I'll give you is that these
are the properties you are going to use. However, I'm not giving you the values of any of them because I want you to
practice looking at an example and making your best guess as to what the values for the CSS properties should be
as that's how you'll work out in the real world when a designer, for example, gives you a design file. So, go ahead
and do this right now and then I will show you the solution afterwards as well.
Okay, let's do this. I'm going to bring up the example here. Have it on the side so that we can see how it develops and
then start with the background color as we have the value for that one down here.
Round like that. Okay. Next, I would try to see what is the most apparent difference between this button and this
one right here. Well, the border is certainly different. This button does not have a border at all, whereas this
one has got has a border. So, let's just remove it. Border none. Like that. Okay, good. Now, we can see that the text is
much more crammed into this box than it is on this one right here. So, that is the padding. And also, you can notice
that there's more padding on the left and right hand side than on the top and bottom. So, I'm going to try to add, for
example, padding top five pixels. Uh, it actually looks like this one here has more than five pixels because this
space is still pretty crammed. So, I'm going to do, for example, eight. Yeah, I think that is more like it. I'm
going to give that on the bottom as well. Like that. On the sides, I'm just going
to try the double padding left 16 pixels. Padding right 16 pixels. And you know what? I think that button and our
button looks pretty similar in size. So, next up is the border radius because you can see this one is totally
rectangular whereas this one has softer corners. So, I'm going to do border radius something like 4 pixels. So, that
is pretty good. The final minor adjustments I'm going to make is reduce the font size ever so little from what
it is here down to what it is here. I mean, it's almost identical, but I happen to know that this one is indeed
14 pixels. So, I'm going to do font size 14 pixels like that. And there we actually have the buttons, this one and
this one identical. Now, if you chose any other values than the ones I've chosen, don't worry about it at all. The
point was not for you to reach the exact same values as me, but just in the same range, basically. So regardless of how
your example ended up, good job reaching this far. Let's just keep up the pace and move on.
Now we are going to add the second button to our Google project. This I'm feeling lucky button right here. And I
want you to do that on your own first. So that's your challenge. Add the next button. And do remember to give that
button a btn class so that it's styled as our search button. And once you've done that and executed the code, I want
you to take a look in the mini browser and ask yourself, why aren't our buttons behaving as we want them to? Because, as
you'll see, there's something wrong with the layout, at least when comparing it to this layout right here. So, go ahead
and do that right now and try to think of why our layout is wrong. And then I will do it as well when you return back
to me and explain what's going on. Okay, let's do this. So, I'm lazy, so I'm just going to copy this one like
that and write um feeling lucky. Run the code. And as you can see, the buttons are now stacked on top of
each other. Hm. What we can do in order to figure out what's going on here is actually use the built-in dev tools in
the browser, which you've seen a few times now. So, let me show you this debug session using slides. I'm going to
rightclick in the navbar and then choose inspect. Open up the elements tab and then click on the selector icon here so
that I can select this button by hovering over it and then down in the styles tab, I can scroll down until I
see the box model for our button. And what you'll notice is that our button is taking up all the available space on the
left hand side and the right hand side. And if we move down to the second button, you can see that that button is
also doing that. That is because they are display block. Exactly this line right here. If you
remember from previous lectures, display block kind of takes up all of the available space on the horizontal axis.
So as we said earlier, display block stacks on top. We aren't able to get the layout we want if our buttons are
display block. And then you might be tempted to do well let's just remove the display block. However, if we do they
will be on the same line. Yes, they are now inline elements but they will just be crammed all the way to the left hand
side because margin left right auto doesn't work. If you remember from the lecture about centering, you learned
that display block and margin left right auto works together in order to center something. You can't have just one of
them. Which means that in order to go from this layout to this layout, we have to use a different technique for
centering the elements. And there's actually two ways we could do this. There's the simple and inflexible way
using text align. And then there's the slightly harder but super flexible way using flexbox. And since you're going to
use flexbox several times throughout this course, I want you to get familiar with it right away. So in the next
scrim, we're going to talk about flexbox. But before we do that, I just want to show you the simple way as well
so that you've seen it. Because as you might remember from one of the very first scrims in this section, we used
something called text align in order to align our text either to the left, right, or center. Now the text align
property actually works on all inline elements, not just on text. So what we can do is remove the display block from
our buttons. As you know that turns them into inline elements and they are crammed to the left and as inline
elements only take up the available space they need according to their content. There is no available margin to
use. So auto here which basically means take up whatever available margin there is serves no purpose. So we can remove
both of these two as well. As you can see it made no difference. And then we can move up to the main the parent. So
we'll do text align center like that and boom both buttons are now centered. So here we have told
the container the main element all inline elements inside of it should align to the center. So that was the
easy but inflexible way of doing this. Let's instead of using this technique move on to do it how the pros do it
using flexbox. Flexbox is everywhere. Let's just have a look at Twitter for example. Here the
menu on the lefth hand side is created with flexbox as with the tweet options menu and the timeline itself. And guess
what these trends for you and who to follow is created with? You guessed it, flexbox. So this is something you need
to learn. Let's imagine then that you have a e-commerce website which you can see here that sells shoes, hoodies, and
t-shirts. Well, then you'd probably have a navigation menu like this one where users can click and then probably open
up a submen or something like that. As you can see, the items stack on top of each other. That is to be expected as
these are divs and divs are display block. They want to take up all the available space in the width. And if
you're wondering how I styled these, we can head over to the styles.css and just have a quick look at that. You can see
I've aligned the text to the center inside of all the items. Hadn't I done that, it would have been aligned to the
left. Also, there's a border. As you can see, there's some padding on the inside, and there's some margin in between the
elements. Now, the question is, what if I instead of this vertical layout wanted a horizontal layout, which is more
common for so-called navigation bars? So, something that looks like this. Well, this is where flexbox comes to the
rescue. And in order to turn this into a flexbox layout, I would first have to wrap these three items in a container
because a flexbox layout always consists of a container and its direct children. So let's wrap it in a div and give this
a class of for example nav dash wrapper like that. If I run this now, nothing happens because divs as you know are
invisible unless you give them any styling or content. So let's head over to the styles.css
and now target the nav wrapper like that in order to turn this into a flexbox container. All I have to do is write
display flex and boom. Suddenly we have forced our three divs into one row. Now this layout flows from left to right
along the horizontal axis and that is pretty significant given that these items were display block by default. But
flexbox, as powerful as it is, overrides that and forces them onto one line. However, we haven't got quite the layout
we want yet. As you can see, it's centered and there's also some space in between the items. Now, let's start with
the centering because flexbox now has control over these items and can decide where along the main axis they should be
positioned. So, we can do justify content. That is a little bit of a weird name for a property, but that's just how
it is. and then set that to center. Like that. Now all of the items are centered. And the final step is just to get some
spacing in between these items. And that is done with our good old friend margin. So we'll do margin left. Let's do 10
pixels. And let's add the same thing on the margin right like that. And there we have the layout
we wanted. Now a final cool thing I want to show you is that we can do for example end here as well. That'll push
it all the way to the right hand side or start at the beginning or alternatively do space dash around. That's pretty
cool. Now we've distributed all the white space around each of the items. And another one is space between. Now
all of the available space is between the items. So they're spread out like this. Now we are getting ahead of
ourselves here. I just wanted to demonstrate this to show how powerful flexbox is. What you are going to work
with is the center here. So with that, let's return back to our Google clone. Okay, we are back at our Google project.
And now your job is to center these two buttons besides each other. Meaning getting to this layout right here. And
the way to do that is of course using flexbox. So you'll wrap the two buttons in a flexbox div and then center them.
And then also I want you to give the div a class of btn-wrapper. So you'll need to modify both the HTML
and the CSS here. Now before you start, I'm going to remove these three lines here because they are solely there in
order to center our buttons using this display block and margin left right auto technique. However, now we're going to
use the flexbox technique. And we don't want to use both techniques at the same time because that'll just be confusing
as they will affect each other. So I will remove these lines. And now you're left with this left aligned layout here.
So please take over here, do this challenge, and then return back to me when you've done it or when you feel you
need some guidance. Good luck. Okay, hopefully that went well. If not, no worries. We'll do it now together. So
I'm going to start with this flexbox div that we want in our HTML. It should wrap our buttons and only our buttons. So we
want to start it up here. If class of btn dash wrapper at I'm going to indent my buttons and then end the div down
here. So now it is simply wrapping our two buttons. If I run this code, seemingly nothing has happened. But
under the hood, we have the button wrapper which we can target using btn-wrapper
like that. And then we can do display flex. That's turned our div into a flexbox. And now we can use the justify
content and do center like that. There you can see both our buttons are centered. However, they are totally
crammed into each other now. There's no margin in between them. So, in order to fix that, we want to add a little bit of
margin left and right to these buttons. So, I'm going to do margin left, perhaps four pixels, and margin right four
pixels as well. Like that. That's looking pretty good to me. So, if you didn't do this, no worries at all.
And also, if you are a little bit confused about flexbox, that is totally okay as well. We're going to work with
that several times throughout this course, so you'll get more opportunities to practice this. Just feel proud that
you've at least dipped your toes into Flexbox as that is a super important tool for any front-end developer. So,
great job. Let's move on. Now, there's one final thing I want you to know, and that is that you are
amazing because you have taken your very first step into the world of CSS, and that is more than most people ever do.
So, take this moment to feel great about yourself. And also, let's take this moment to recap what you've learned.
Starting out, you learned about the CSS syntax. That is how you select elements and also use properties and values. And
then you learned the key concept about inline elements versus block elements. So block elements stacking on top of
each other like these two and inline elements standing kind of in a horizontal line like the buttons here.
Moving on, you learned about margins, which is how you create white space outside of elements, for example, above
the Google logo here. And you learned about its close cousin, the padding, which is how you create space on the
inside of elements, for example, in between the text and the edges of these buttons. Also borders is what is between
padding and margin and we use that on the input field here. We decided its thickness, its type and color and also
the radius of the corners. So we didn't want sharp edges but rather soft circular edges which we achieved with
this border radius property. What we also did was take a closer look at the div tag which you saw briefly in the
HTML section. This time around though you actually created two divs. one to wrap the entire project and another to
wrap the buttons. And we had to separate those from each other. So you had to learn about classes. That is the
attribute you set like this. And you select by using the dot notation in the CSS. Also a big thing is centering in
CSS. You learned three different ways of doing this. And the final way you centered elements was through the use of
flexbox. a super powerful tool that all front-end developers need to be comfortable with. So, you have learned a
lot. Now, I think you should take a little break. You have to digest these things, recharge, and then I will see
you back here when you are ready in the next section. Welcome to the second CSS section of
this course where you are going to build a business card for yourself. And it's going to look more or less like this.
Though you're going to personalize it, make it your own, not only with your own information, but also with a beautiful
color palette of your choice and a font that you like. So you are going to level up your design skills as well as your
CSS skills, meaning that this is going to be a lot of fun. So let's just get started with it right away.
Okay, let's start out by having a quick look at the basic skeleton for our app. As you can see in the file system here,
we have an index html file, also a styles.css file, and finally we have an images folder which contains my avatar.
It's a png file called pair.png. Now, starting with the HTML, it's just a very simple setup with the HTML tag and
then the head tag which links to the styles.css. As for the body, it has one direct child
which is a div which will work like kind of the container for our business card. And inside of that div, we have an image
tag. We have an H3 with my name. We have a paragraph with the title and an H4 with the location.
Moving over to the CSS, we only have one rule here. We're setting the margin to 20 pixels on the body. And if you
remember how this works, when we're not specifying either margin top, margin bottom, left, or right, just setting the
margin in general, these 20 pixels will be added on all four sides. on the top, on the left, bottom, and right. And
that's simply because I want to avoid that these elements touch the edges of the mini browser. So, there's a problem
though. As you can see, the image isn't rendering properly. It's just an icon. That is, as far as I can remember, not
how my face looks like. And the problem is in the image tag. So, I want you to try to fix that. And I'm not going to
give you any more hints. Rather than if you are stuck, try to Google HTML file paths. That should help you. So go ahead
and give this one a shot and then I will show you how to solve it as well when you return back to me.
Okay, let's do this. Let's take this string right here and paste it into Google. There you can see that the top
result is a W3 schools article. Let's head into that one. Here you can see file path examples. Let's zoom in on
this one. And if we have image source equals picture.jpeg, JPEG, which will be the same as we have here, although our
image is called pair.png. That means that the file is located in the same folder as the current page. Well, is
that the case? Now, looking at our current page, index.html, you can see that the image is not located in the
same folder as the index html because the image lives inside of the images folder. So, what we then might need is
something like this where we do images slash and then the picture name. here. It means that the picture is located in
the images folder in the current folder. And that looks correct. The images folder is in the same folder as
index.html. And the headshot of me is located inside of that images folder. That means that we can try to do images
like that. Slash run the code. Oh, there we go. We have my avatar imported and are ready to move on to the next trim.
I'll see you there. Hi there, my name is Bob Zroll. I'm another teacher here at Scribba and I
wanted to expound a little bit on the lesson that you just learned with pair. This is a very similar example to what
you just saw with the Google homepage. In this example, we have an image that is referencing cat.jpeg, but as it turns
out, relative to where our index.html file is, that cat.jpeg file is only inside of the images folder. So, as you
just saw in the example with pair, I will need to prefix this with images slash. When I begin my string this way,
it's saying look in the directory that the current file or the index.html file is in for another directory called
images. The directory that the index.html file is in is called the project root folder. And that's
everything that you see here under this explorer title here in Scribba. And by correctly referencing the path to where
this cat.jpeg JPEG image is found. I can hit save and our image of this cat is giant because our CSS file is commented
out, but we'll fix that in just a minute. Okay, so this is simple enough to understand, but there are some other
points of syntax that I think are really helpful to know. First of all, and probably the easiest one to understand
is that if you prefix the path with a dot slash, it's a way to tell in your code that you are going to be starting
from the current directory. That's exactly what we're doing here already. So adding a dot slash does exactly the
same thing. As far as I know, there's functionally no difference. Now on its face, it might seem like it's just
extraneous information. However, personally, I do prefer to include the dot slash at the beginning. I think it's
a little bit more explicit and kind of a visual reminder that I'm referencing a local file inside of my project. But
that's going to change from one person to the next and one team to the next. So I mostly wanted to include it here so
that when you saw it, it wasn't confusing. We can see I can hit save and we're still getting our cat image
showing up correctly. This leads us into another way that you can use relative path syntax to reference other files in
your tree and that's by prefixing your path with a dot dot slash. Using the two dots is a way to start looking at the
parent directory first. Okay, when would this be useful? Well, let's go into our source directory and then inside of our
CSS directory and open up our index.css. And here you'll notice that we're selecting an image div class and giving
it a background image with this URL. This URL has a relative path that goes up two directories first before going
down into the images directory. Because our index.css CSS file lives inside of the CSS folder, which is inside of this
source folder, which is a sibling, I guess you could say, folder to the images folder. We need to go up two
levels from CSS to source and from source to the project route before we can then drill back down into the images
directory. Now, why isn't this dog.jpeg showing up in our mini browser over here? That's because in our index.html,
HTML. We commented out this stylesheet and we don't have the correct href here. So, take a quick second as a mini
challenge. Pause now and fix this href so that first of all, our cat image will be more reasonably sized and second of
all, the dog image will show up. Pause now and see if you can get that to work. To do this, we can start with a dot
slash if we want. go into the source folder, then into the CSS folder, and then into index.css.
We'll hit save. And there we go. Everything is working. Really quickly, we can also see an example of this dot
dot slash. If I were to move my index.html inside of, let's say, my source folder, I'll need to make a quick
change to the mini browser here to begin it with /source.index.html. But you can see that my sleeping cat is
broken and so is the link to my CSS page. Because my index.html page is now nested inside of my source folder, I'll
need to make a change both to my link here and to my image here. And by I'll need to make that change, I mean you
need to make that change. Let's make this into a quick challenge. Pause now and fix both of these paths so that
everything goes back to the way it was. Okay. Well, relative to the index page, which is now inside of the source
directory, I no longer need to reference /source. Instead, I can just simply go into the CSS directory because the
current directory is the source directory. With our cat image, I need to go up a directory first in order to get
to the project route where I can then drill down into the images directory. So, I'll hit save. And sure enough,
everything's working the way it was. not feeling great about putting the index page inside of my source directory. So,
I'm going to move that out. I'm gonna change these back and fix my mini browser so that it's not looking at the
source anymore. Okay, perfect. The last syntax that I'll talk about is just using a slash at the beginning. Having a
slash as the very first character of your relative path is a way to start directly from the project's root
directory. For example, if I didn't want to do this whole thing where I'm going up two directories before then going
down to my images directory, it's a little bit more concise for me to begin this with a slash that says just start
at the top root directory of this project rather than worrying about going up so many levels and then back down so
many levels. So that's what the slash at the beginning of your path does. Now, I have one more challenge for you and
that's to fix our script source. We haven't talked too much about JavaScript, so don't be too concerned
about anything dealing with JavaScript. All we need to do is make sure that the source to the JavaScript file is
correct. And when it is correct, you should see a message pop up in the console. That's all I'm going to say
about that for now. I want you to figure out the rest. So, pause here and fix the source for our script.
Our index.html is at the root of our project. So, I have a bunch of different ways that I could do this. I could just
start with a slash to indicate start from the root. Then I would go into source scripts. Let's open this up.
Scripts and then main.js. So, slashmain.js. We'll hit save. And we get that I'm the
main.js file console log just like we would expect when it's working. Because this file is at the root, I don't
necessarily need to specify a slash at the beginning. I could just say src or as I mentioned my preference would be to
start with a dot / src and hitting save shows that log coming up again and everything also working that way. I know
this is a really simple topic but I'm hoping this can eliminate any confusion that you might have as you're looking at
other people's code other code here on Scribba or maybe help you avoid a really tricky bug sometime about having a path
that's incorrect somewhere. Okay, thanks for letting me talk about relative paths for just a little bit. I'm going to pass
you on back to P. Okay, now we're going to do a little bit of housekeeping here because this image
element actually has a serious flaw because it lacks an important ingredient that all image tags should have which is
called the alt text or the alternative text and that is simply an attribute that is written like this alt equals and
then inside of quotes you are to write a description of the image. So here it could be for example Pier Borggan
smiling like that. However, if we run this code now, you can see that seemingly nothing has changed. So why do
we at all write these old texts? Well, first of all, it makes your site accessible because imagine that a person
who is visually impaired or who is blind is trying to visit your website. In that case, they would use a screen reader
which goes through the HTML and reads it out loud to the user. And as for the H3 tag, it would be simple for the screen
reader to read out loud what that says because that is text. However, for an image like this one, you need to add an
alt tag to describe the image so that the screen reader has something to read out loud. And secondly, this also works
as a fallback if your image doesn't render properly cuz let's say you have a spelling mistake in the sorts attribute,
for example, an extra R. Well, in that case, the image won't render, but the alt tag provides as a backup so that the
user seeing this can kind of understand what was at least supposed to be there. And finally, writing alt text will help
your site rank higher on Google, meaning you get more search traffic. And that is because the alt tag most likely provide
important metadata about the image so that Google knows how to use it in a search results page. And if your site is
not accessible, it might be punished in the form of ranking lower. So with that in mind, let's look at how to write
these alt texts. And the first thing you need to know is that you should not include for example image of because
that's simply not necessary. The screen reader knows that it is an image because it is an image tag.
Secondly, should be concise meaning less than 125 characters because a lot of screen readers will cut off after this
limit has been reached. And finally, a trick you should use in order to come up with a good old text is imagine that you
are describing this image to a person over the phone. So let's try to do that with an example. Here we have an iconic
image of Muhammad Ali in a boxing match. And one way to write an old text for this could be just a boxing match, but
it would actually be a pretty poor way of describing it because there's so much more going on here. You have plenty more
characters you can use in order to describe it. So, a better one would be two boxers in the ring, one lying down
and the other standing up. That's a good factual explanation, but we're not quite there yet because it isn't actually
describing this iconic moment when Muhammad Ali knocked out Sunonny Listen. So, if you were to describe this over
the phone, you would probably understand that this description is pretty shallow. So what I would rather write as an old
text for this image would be Muhammad Ali in the boxing ring screaming at Sunonni listen after knocking him out.
That in my opinion properly describes the intent of this image. What the person who has decided to show this
image on a website is trying to convey. So with that example in mind, I want you to write what you think is an
appropriate alt text for this image. go ahead and do that right now and then I will show you what I would write when
you return back to me. Okay, let's do this. We'll do alt equals quotes and here I would use my name pair
Harold Borggan. And you can see I'm smiling and I'm looking at the camera. I think that's important. So I'd write
smiling at the camera. Finally, the background is really playful and colorful.
So, I want to include, for example, with a colorful background like that. So, if yours was a
bit simpler or shorter, don't worry about it. The most important thing is that you add an alt text and do as best
as you can. And actually, plenty of developers never add this. So, just by adding it, you are actually separating
yourself from most other beginners. So, with that, let's just move on. The next thing we're going to do is
shrink this image to a suitable size for our business card because as it is now it is far too big. So I want you to head
over to the styles.css and solve this challenge. You are to set the width of the image to 150 pixels and you need to
use a class to select the image element. So go ahead and give this a shot right now.
Okay, hopefully that went well. Let's now do it together. So, first we need to actually create the class that we are
going to select from the CSS. So, let's head over to the HTML file here. We'll just do class equals. And I'm going to
call this one an avatar like that. Actually, now that we have three of these on the image element, I think for
readability purposes, it works well to break them into three lines. I think this is a little bit easier to
read. Then I'll head over to the styles.css and target the class avatar and just set the width to 150 pixels.
Now rerun the code. There we go. So great job solving this challenge. Let's move on.
Okay, now you're soon going to start building the layout of this card. However, right now the card kind of
blends into the background. There's no separation between the card and the background. So, I want to add a little
helper style in order for us to more clearly separate the card from the background. And for that, we need to
grab hold of the outer element of the card. And can you take a guess what kind of HTML element do you think should wrap
the entire card? If you guessed a div, that is correct. And heading over to the HTML, you can
see we are actually already wrapping the entire thing in a div. So here we have our container div or card div or
whatever we want to call it. So what I want you to do now is to first give that div a class and actually I think you
should call it card and then I want you to select the card class in CSS and give it a dotted blue border. This is our
helper styles. It'll give us a little blue border around the element so that we can see how our card div kind of
behaves. And also, as you can see from the design here, none of the elements touch the edge of the border. So, it
seems like there's some padding in play here. Let's just add 20 pixels of padding on all sides of the card as
well. So, go ahead, solve these three challenges, and then I'll of course show you the solution as well.
Okay, let's do this. So, first we need to give the card div a class. I'll head over here and do class equals
card. I'll run this code so that we have this class in the DOM.
The next step is to select the class by doing card and then adding a border. If you
remember from previously that is done through the border property which takes three values. The first one being the
thickness of the border. I'm just going to set it to one pixel. The second being the quality for example solid or dotted
or dashed or a few others. We're going to use the dotted one and the color will be blue. And there you can see boom we
have a border around our entire card. And this will make it a lot easier for us to work with the card now that we can
see it clearly on the page. Finally, we want to add 20 pixels of padding because as you can see here, the elements touch
the border on these sides and we don't want that. We want some space. So, we'll do padding
20 pixels like that. And there we go. We have solved the challenge. With this in place, I think we're ready to start
moving on with fixing the layout. And as you can see on the finished design here, there's a big difference between this
one and our current one. And that is that the current one is vertical whereas this one is more horizontal. So they
stack up differently. We want the image on the left hand side and the text on the right hand side, not everything on
top of each other. So basically we want two columns, one for the image and one for the text. And as you might remember
from previously, flexbox helps us create columns. So let's now just experiment by adding display flex to the card and
let's see what happens. Oh wow. Okay. So what happened there? It actually turned every single element into a column in
itself. That's not exactly what we want here. So display flex isn't the entire solution. So, what we're going to do now
is go out on a tangent, learn a little bit more about this flexbox concept in CSS, and then return back to this
business card project once we're ready to build a layout like this. So, let's move on and learn more about flexbox.
Okay, so let's say that you've built some kind of software as a service and now you want to sell it. Then you might
have a page like this where people can upgrade to pro and they can choose the individual plan which gives them 1 GB
and no support or the enterprise plan which gives them 10 GB and priority support. Now I've purposely not given
any design to this example as I wanted to make it as easy as possible to grasp. But hopefully if you are to create a
pricing page you make it look a lot better than what we have here. So you can see the HTML right here for the
entire pricing layout. I've wrapped it in a div and I'm using an H2 unordered list, a button and so on. Now let's say
that you instead of having this one column layout here where everything stacks on top of each other, you want
this two column layout where you have the individual plan at the left hand side and the enterprise plan at the
right hand side. Well, if so, we know that flexbox will help us create columns. But if we try turning our
container is the div with a class of pricing into a flexbox, you'll see that
it'll break the layout just as we saw in our business card example. Because what's going on here is that flexbox
takes every single item that is every single direct child and turns it into a column in itself. So we get a column for
the H2, for the unordered list, for the buy button, for the H2 again, and so on. And this is obviously not what we want.
It's far from this two column layout right here. However, there's one hint to be drawn from this example. And that is
that if you check out the unordered list here, you see that it has two children of itself, LII elements. And those two
are not their own columns. they are in the same column stacking on top of each other. So it seems as if flexbox only
turns the direct children into their own columns. So the direct children are the h2 here, the ul, the button, but not the
list items. And once we know that, we can use that knowledge in order to get to this layout. Because this layout has
two columns, that means that our flexbox container should have two direct children, not six as it has now. And how
can we achieve that? Well, we want this group to be inside of a direct child of this container. And we want this group
of HTML elements to also be inside of another direct child of the flexbox container. So what we'll simply do is
we'll wrap both of these inside of a div like that. And we'll indent it for readability purposes. Let's try to run
this code having wrapped one of the two groups into its own div. And there you can see the four individuals plan now
stacks up just how we want it. But the rest of the layout is still broken. So we need to do the same thing down here
like that. Run the code and there we go. Now our flexbox container actually only contains two items. this div and this
div as it doesn't care about what's inside of both of those children. It only cares about its direct children.
And the result is that we get the layout we wanted here, at least in terms of having two columns. There's still a
problem with lacking space in between these two children, but we're not going to deal about that right now. For now,
I'm going to send you back to the business card example so that you can use this to improve our layout.
Okay, we are back at our business card example and now I want you to use what you've just learned in order to fix our
cards broken column layout cuz you are going to make this card into a two column instead of a four column which it
is now it has the image name title and location at four different columns but instead we want two columns one for the
image and another one for the text elements. So this challenge is solved in the HTML. As you know, we already have a
display flex on the card and the only thing you need to do is one change inside of our flexbox. So hopefully
you're able to do that. Go give it a shot and then I will show you the solution as well.
Okay, hopefully that went well. Let's do it together. So the problem is that flexbox treats each of these elements as
a single child and thus each of them get its own column. However, we only want two columns. So we want these three to
be governed by one flex child. So we need to wrap them inside of a div. We'll do like this. Open the div and then
close the div down here. And we'll indent these so that we get some better readability. Now you can see the flexbox
only has two direct children. This one and this one. That means that we should get two columns in our layout. And yes,
we do. Brilliant. Of course, there's still a long way from this design to this design. But we are making great
progress here. So, let's just keep up the pace and move on to the next scrim. Okay. I think looking at this example
now, I got to admit that I'm pretty pleased with this border, one pixel dotted blue here, I think it serves a
very nice purpose, which is to highlight for us how our card is being laid out on the page. So, wouldn't it be nice if we
could use that exact technique on other elements on the page as well? For example, the children of the flexbox
container, that is this image right here and the div tag. That would have been really neat. And we can do that by for
example just copying this one and adding it for example to the avatar. See there the avatar is got that blue border as
well. However, wouldn't it be neat if we in our HTML could just quickly apply a class to any element for example this
one and it would get the same thing as well. So basically the argument I'm making is that we should create a
dedicated class for this blue border. And what that is is a utility class, aka a class that only sets a single CSS
property. So let me show you how this would work. Let's say that we for example want a class to make our text
italic. Then we'll simply do class equals itallic like that. If we run this code, nothing has happened because the
class hasn't been created yet. But here we can create the italic class and do font style italic like that. And now you
can see the name is in italic. Now if we want to reuse this, we can just do class italic here as well. Run the code and
the location is also italic. And if we want the entire card itallic, we can even add the class here up on the
container element itself. Run the code. And now this has been inherited down to all of these elements. And if you're a
bit confused about what I'm doing here, it is simply adding two CSS classes to a single element. Do that simply by adding
a space in between the two classes. Okay, let's get rid of these like that and delete this one as well. Now, what I
want you to do is create a utility class for the dotted blue border. This is the styling we have here. And then give the
class to both flexbox children in the HTML. that is the flexbox items you can see here and here. And also I think you
should give the same class to the card as well so that you can remove this line 10 here. So go ahead and give this one a
shot and then I will show you how to do it afterwards as well. Okay, hopefully that went well. Let's
start out by creating the class. I'll write border blue here. And then inside of it, I'll just cut
this away and paste it in here instead. Now we have a utility class for blue borders. I'll copy it and add it to this
flex item. And as a second class to the image element, we run this code. You can see now both of these have the blue
border around them. Let's also add the border blue class to the flexbox container. run the code and boom, there
we go. Now we have an even better overview over how our elements are laid out.
Okay, with these blue borders around the flexbox children, it's pretty easy to see that our layout is pretty far from
how we want it to be. Cuz here you can see in the card that there's some space in between the two elements. Whereas in
our example, they're completely crammed together and also pushed all the way to the left hand side. Whereas here they're
kind of spaced out. There's some space on the left hand side in between the element and also some space on the right
hand side. So they're kind of spaced out in a nice way. And now I want you to add that horizontal space around the flex
children. There's a flexbox property that does this. And you've seen that property before. However, you might have
forgotten it. If so, then Google justify content and you might find the answer. I'm not going to give you any more hints
than that because if you have forgotten about it, it is a great practice to Google it. Then once you figure out the
answer, go ahead and add the horizontal space so that our example becomes a little bit more like this layout. And
just so you know, you only need to add one property for this, not multiple. So give it your best shot and then I will
show you the solution afterwards as well. Okay, let's do this. So the property is
called justify content. A little bit of a weird name, I agree, but that's how it is. And here we can use a range of
different values. And the one we're looking for is called space around like that. And now you can see both elements
now have some space around them. And also we could do space between then all of the available space will be between
the two items. Or we could even do center as you've seen before. then there's no space in between them but
both of them are centered and end pushes it all the way to the end and start keeps it at the start. So this is a
super powerful property and we want the space round value for it. As you can see it's at least getting closer to the
layout we have in our finished design. So great job. Let's move on. Okay, time for a new challenge. You are
going to set a fixed width on the card and then center it on the page because its behavior is a little bit weird right
now. As you can see, if we enlarge the screen, the card gets enlarged as well and that makes the spacing between the
elements look super weird. The aspect ratio becomes very different from a business card. So, we don't want that.
Instead, we want the width to be 400 pixels. So, it should be a fixed width. And then we also want the card to be
centered on the page. Now, one thing I want you to notice when I enlarge this is that the card is a display block even
though we've set it to display flex. So that means that flexbox containers by default are display block. And hopefully
you remember from previously that display block takes up all the available space in the horizontal axis. And it is
also one of the three ingredients you need in order to center an element using margins. So hopefully you remember from
the Google project how to center block elements. So go ahead and give this one your best shot and then I will show you
the solution as well when you return back to me. Okay, let's do this. I'll start by
setting the width to 400 pixels like that. Now you can see if we enlarge the screen, the card is stuck to the left
hand side of the website. So, in order to fix that and instead center it, we'll use margins. And hopefully you remember
that we'll do margin left and set that to auto. That pushes it all the way to the right hand side because all of the
margin is now on the left hand side. But then in order to even it out and center it, we'll do margin right as well and
set that to auto. And the result of having an equal margin on the left hand side and the right hand side is that the
card is centered. So, great job on solving this challenge. Let's move on. >> All right, let's take a minute to talk
about CSS inheritance. And you're probably thinking, wait a minute, this isn't the singongy Nordic accent of
Perorgan. And you'd be right. My name is Bob Zurroll. I'm another teacher here at Scribba. And I'm interjecting myself
here to make a small accessibility update just in the way that the HTML was written in the original version of the
screencast, but also as a way to introduce myself. If you're here as part of the front-end career path, you will
be taking another one of my courses, either the APIs and asynchronous JavaScript course or the React course
that's later on in the path. Okay, back to the topic at hand. Let's learn about inheritance and why it's important to
learn about inheritance in the first place. First of all, it will help you write, you could say, drier code. Dry
stands for don't repeat yourself. In other words, you can take advantage of this concept of CSS inheritance so that
you don't have to keep writing the same CSS code over and over, but instead can define it in one place and have that
change cascade throughout the rest of your CSS. Inheritance is also something that can help you avoid bugs in your
code and generally be more efficient. To demonstrate this, we've pulled in an article from Wikipedia here about the
dancing plague of 1518. This is a really strange phenomenon that happened in modern-day France where somewhere
between 50 and up to 400 people inexplicably took to the streets and started dancing as it would appear
against their will. It's a fascinating story. Feel free to read through the events. There's even an illustration
here. I have no idea what could cause this, but there's some pretty good theories here that include food
poisoning and so forth. So, feel free to look through this article, but that's just for fun. Let's not go too far down
this rabbit hole. Instead, let's talk about inheritance in the context of this article. Since we've pulled this into
our own page, maybe we've decided that we would like to center all of the text on this page. And so, I could go to my
styles.css and start centering each one of these elements by itself. For example, we have an H1, a paragraph, an
H2, more paragraphs. So, sure, I could start by saying I want to select the H1 and do text align center. Okay, I've
centered my text there for the H1. Now, let's go to our H2 and do the exact same thing. So, we'll go ahead and center the
H2. Great. We're partway there. Then, we have to also select the paragraphs. And hopefully, you can see the point I'm
trying to make here. In this case, we would not consider our code very dry because we are repeating oursel instead
of following DRY. Don't repeat yourself. So, what does this have to do with inheritance? Well, let's look at our
HTML and we can see that our entire article is conveniently placed inside of an article element. The idea of an
article element in HTML is self-contained content that if you were to remove it and put it somewhere else,
it would still make sense. Of course, the dancing plague of 1518 is hard to make any sense of, but I think you get
my gist. In this case, if we really do want everything in our article to be text align center, we can take advantage
of CSS inheritance by instead of repeating all of our rules here, we can say everything inside of the article
should be text align center. And as you can see, this single rule has been inherited by all of its children
elements where text align center makes sense. Now, I could have chosen to put text align center up on the body
instead. And you can see we get the same effect. Essentially, we can know that this inheritance doesn't just happen
with the direct children of the element that we're selecting in CSS, but will work any number of layers down the
descendant tree of the element that we're selecting. I personally prefer to have it on the article because maybe
there's other elements that we don't want to have text align center that are outside of the article tag. So, let's
leave it here on our article. Now to refine our understanding of inheritance, it's important to know that text align
is an example of a CSS property that does get inherited down the tree. However, not all CSS properties will get
inherited. I have found that it's pretty intuitive which ones will and which ones won't. But like we should do anytime we
have a question as we're learning something new, we can Google it. Here you can see we've Googled which CSS
properties are inherited. And there's a Stack Overflow question exactly about this. If we click into it, we can see
down here somebody has answered it and begun a list. If we scroll down, we get all the way down to 41 different CSS
properties that are inherited. Now, let me be honest, most of these are not CSS properties that you're going to really
have to care too much about. In fact, when I was looking at this, I think probably over 50% of these properties
I've never even heard of before. Some of them, however, like the text align that we just used and some of these other
font related ones, like font family, font size, font style, and so forth, are really good ones to know. All right,
let's get your hands on the keyboard with a challenge. I want you to navigate to this Stack Overflow question to pick
a few of the inherited properties on this list. You can just click the screenshot here to go directly to the
article and try applying them directly to the article element that we've selected here and just see this working
in practice. I know it might seem a little bit frivolous, but this kind of hands-on work is what really will engage
your brain and help you remember the stuff that we're learning. Now, as a fair warning, some of these properties
are going to affect things like screen readers more than anything you might see visually. Properties like volume or
speech rate, but other ones should be readily apparent in the visible output that you see here. Then, once you're
done, I'm going to hand you back to pair to continue on with the next scrim. Okay. Now it's time for a challenge in
the business card project because you are going to center the text inside of the paragraph and the H4 elements and
that is the paragraph right here which says frontend developer and the H4 right here. Because as you can see, both of
those elements are now crammed all the way to the left hand side. Whereas in our finished design, they are aligned at
the center of this flex children directly underneath the name Pier Harold Borgen. And if you're wondering why
we're not caring about centering this one, it's because it takes up the full width of the container. So you can't
center or left or right align it because it takes up the full width anyway. it is the element that actually decides how
wide this container should be. So you will only see the paragraph and the age for change when you fix this. And the
way you should do it is by only adding one property and then have inheritance take care of applying that property to
both elements. So you're only going to write one line of code. And I'm not going to tell you where you should add
that line of code. You have to figure that out on your own. And I'm also not going to tell you what the property is
called or the value you'll give it, but you have seen it before. So hopefully it's not that foreign to you. So jump
into the code and try to solve this challenge now. Then of course revert back to me when you want to see my
solution. Okay, hopefully that went well. Now we're going to use the text align
property and set it to center. But before we do that, we need to decide which element we should target with that
property. Should we add it to the entire body, for example? If so, it'll inherit down from the body into the card and
then into our flex children right here. And then finally to these elements as well. That works perfectly fine. We can
actually try it. Text align center. And boom. These two are now centered. However, imagine that this card is a
part of a bigger website. If so, we've now centered all text inside of the body,
which is where all of the HTML, both now and in the future, will live. Though, this might have second order
consequences. Perhaps we want to have a navbar with a title that isn't text align center, but rather text aligned
right or left. So, actually, I think it's better to scope this to, for example, our card. We at least know now
that all of the text we currently have in our card should be aligned to the center. So, let's do that instead. Let's
just remove it from the body and paste it in here. And now we're not causing any unwanted second order effects
outside of the card. So this is in my opinion a better solution. But if you added it to the body, that is a
perfectly valid solution as well. So don't feel that you did a mistake. In coding, there's always plenty of ways to
solve things. And there's rarely one right answer. There's just consequences for whatever choice you make. So really
good job doing this. Let's move on. All right. Now, the fun stuff remains, which is adding colors according to the
specified design here. So, this is a really rewarding little challenge that'll make a ton of difference as
you'll go from this boring white layout here to a nice colorful layout. So, you're going to add these three colors.
As you can see, I've added the hexadimal values for each of the colors, the black, the blue, and the purple. The
purple is the border at the bottom here. The blue is the background color, of course. And then finally, you might
wonder, well, what's the black? Well, that is actually the text color, as the text here isn't pure black, as it uses
this shade of black instead. Now, you might wonder, well, how do I create this border at the bottom here? I've only
learned how to create borders around an entire element previously. Well, the way to solve any problem when coding is to
Google it. So, let's just write border bottom CSS in Google. There you can see a W3 schools article. Click in on it.
And here it has some code examples which we can zoom in on set the style of the bottom border for different elements.
And here it shows us how to set the border bottom. So we do border dashbottom and then for example 5px
solid red. Well that's exactly how we'd set the border itself except that we would omit this dashbottom in the
property name. So you'll use the exact same technique you've used for the entire border just with this extra word
added to the end. So hopefully you'll be able to do that. So here is the design. And a final thing I'm going to do before
I'll leave it to you is to remove these blue borders here because we don't need them anymore. So let's head into the
HTML. I'm going to mark the border blue utility class we've added. Do command plus D. That enables you to select
multiple instances of whatever you've highlighted. And then boom. I'm going to remove it like that. Then also we don't
need any class in the div for this flex children anymore. The code our borders are gone. I'll leave this for now in
case you want to add it back again. But now it's your turn. Go ahead and try to solve this challenge and then of course
I will show you the solution when you return back to me. Okay, hopefully that went well. Let's
now do it together. I'm going to start with the blue background as that'll make the biggest difference. So I'll do
background then copy this hex value like that. Very good. Then I'll do the text color that is color and copy the one
right here. Yes, not as visible as the previous change, but something surely happened. We're now using that shade of
black for the text. And finally, the purple border bottom will be added by doing border dash bottom. And then let's
try two pixels. And we want to use solid than the purple color. Okay, we can see a thin border at the bottom. Let's have
a look at the design. It looks like it is definitely thicker here. So, let's crank it up a little bit. For example, 6
pixels. Yes, that looks pretty good to me, actually. So, really good job reaching this far. You are very close to
the end right now. So, let's just keep up this great pace and finish up this project over the next few scrims.
Okay, now I want to talk a little bit about fonts because fonts are actually really important. Let's say that you for
example have created a computer specialists company called Click Lovers. Well, you might want to think about
which font you choose in that case. Or if you're the owner of the Megaflex shop, you should also think carefully
about which font you choose. Finally, if you are the head of the wig and pen association, make sure that your font
spaces out words correctly. Now, these are of course extreme cases and they're all on prints. You'll rarely see cases
as bad as this on the web, but fonts really matter online as well. Let's take Wikipedia for example. Here is a random
article about people who have died from laughter. As you can see, Wikipedia has this very serious nice font. But if we
change that to something like Comic Sandance, you can see the text gives a whole different type of association. It
went from being very serious like this to being more like a comic book. So when you are building projects, it is
important that you choose a font that kind of suits your project. So let's move on to look at how it works
technically under the hood. Because when you visit a website, for example, scribble.com, you visit it via a client.
That could be your mobile, tablet, desktop, or whatever. What happens is that when you type www.scrimble.com
scrimba.com into the URL bar. It sends off a request to Scribba's server and then the server says, "Yeah, okay. You
want to visit our website? Yeah, of course. Here you go." And it takes everything you need in order to run the
Scribby in the browser. That is the HTML, the CSS, the JavaScript, the assets, which can be images and videos
and so forth. Then also the recipe for the font and then it sends that back to the client. However, for some websites,
they won't send you the recipe for the font over the network because they will instead on their website use a font that
most likely is already pre-installed in your client. That is also called a web safe font, meaning that the recipe for
rendering that font exists in most clients. Now, of course, there might be some clients that don't have that
specific font, but in almost all cases, it's safe to use one of the web fonts without sending the recipe for it over
the network. So, what are these websafe fonts? Well, here is an article on V3 schools where you can see all of the web
fonts for HTML and CSS. So, when you're using these, you don't have to send the recipe for the font over the network.
Now, for our digital business card, we're only going to use Web Safe fonts, but later down the line, you'll also
learn how to pull in external fonts so that you can go outside of these 10 fonts as they don't really give you a
lot of flexibility. So, with that in place, let's look at how you actually use a font in CSS. So, in order to set a
font, you first target normally the body and then type out font family and then the name of the font. And here you can
see we've typed V and that triggers VS Code which is the editor powering Scribba to come up with suggestions for
you. You can see it doesn't only suggest Verdonna which is the font we want. It also adds a bunch of other fonts after
it all separated by a comma. So if we hit enter now, boom, then we've added what's called a font stack. And what
this means is that if the browser finds the Verdonna font installed, it finds the recipe for that font, well then it
will use it. However, if it can't find it, if Verdonna isn't installed in the client's computer, then it'll try to
find Geneva, which is a pretty similar font. If it can't find Geneva, it'll jump on and try to. And if it can't even
find Tacoma, it says, well, give me any Sans serif font. And sans serif is a category of fonts. So, here it's just
saying, give me any font from this category. And there are mainly two categories, sans serif and serif. Here
you can see an example of both of them. Serif fonts contain these decorative strokes at the end of the letters. You
can see it here, here, here. Whereas sans serif is without those decorative endings. So sans then means without or
not or something like that. You get the point. Okay, that was a lot of theory. Now it is your turn. You are going to
set the font here to Verdonna. And also make sure to remember to get the entire font stack so that we have backups in
case the client doesn't include the Verdonna font. So go ahead and do that right now.
Okay. Hopefully that went well. What you'd want to do is font family colon start typing and then the editor
suggests the entire font stack. Though you won't see that now because the scrimbot DOM recorder doesn't record it.
However, I can see it. So, I'm just going to hit enter and boom, the editor suggested this entire font stack with
me. We have changed the font. Let's verify that by removing it. Boom. Yeah, that's different from this. So, really
good job. We've actually now completed the design for our business card. However, there's a little issue with our
code because this is how noobs write their margins. And I want to teach you how the pros do it. So, let's move on to
the next scrim where you'll learn exactly that. Okay, now it's time to learn about the
shorthands for margin and padding. And you've actually been exposed to one of them already, which is that if you have
the same value on the margin top, right, bottom, and left, you can reduce those four lines into one margin 10px. Then
the browser will take this 10px and apply them to all sides. So these four lines are identical to this one down
here. Now the question becomes what happens when you have four different values for example 10 px 20 px 30 and
40. Well if so you have to do like this margin and then 10 px 20 30 40. So the first one is margin top the second one
is right the third one is bottom and the fourth one is left. So now you're probably thinking well how can I
possibly remember this order? And the trick is to think of the clock. It starts at the top then goes to the right
then goes to the bottom and then goes to the left. So with that in mind, I want you to improve this code here which
creates the Japanese flag in CSS because as you can see this red circle here which is a div has a few styles applied
up here but down here we've used the nonshorthand way to set the margins. Setting some margin on the top so that
the circle is pushed down. nothing on the right and the bottom but 100 pixels on the left so that it's pushed to more
or less the center of a screen given that the screen is as wide as it is right now. So I want you to translate
this into using the margin shortand instead. Go ahead and do that right now. Okay, hopefully that went well. I'm
going to actually comment these lines out. Now you can see the red circle is up in the left corner. And then I'm
going to do margin starting at the top should be 40 pixels. Then the right side 0 pixels. Then the bottom should also
have zero pixels. And then the left side which should have 100 pixels. And there we go. We are back at the exact same
layout. So great job if you manage to solve this. Now there's another scenario I want to teach you about as well which
is if we have top and bottom as one value and right and left as another value. If so you can actually reduce it
to margin and then only two values. Here you do 10px and auto because 10px is top and bottom. Auto is left and right. So
the way to think about this is that the first value controls the vertical line, the yaxis, and the second value controls
the horizontal line, also known as the x-axis. So with that in mind, let me change this a little bit. I'm going to
go back to the funky way of writing this. And I'm actually going to improve it a little bit because if we want to
center the circle, we shouldn't hardcode a margin left because that'll only work on this screen size. When we do like
this, it's not centered anymore. So let's instead use the better technique of using auto on the left hand side and
the right hand side. And also just to make sure that no elements are allowed to appear directly underneath our
circle, I want to add 40 pixels to the margin bottom. So now I'll make it a little bit easier for you and separate
these two. With this in mind, can you reduce these four lines into two? Go ahead and give that a shot right now.
Okay, let's do this. I'll comment out these. And if you wondered what shortcut I used for that, I'm using command + K +
C, but that is on a Mac keyboard. I'll comment this out. Then I'll do margin first. We'll set the vertical axis. I
should have 40 pixels at the top and the bottom. So that is 40 px. And then we'll set the horizontal axis, which is auto
like that. And boom, there we go. We have it centered. at least horizontally regardless of how wide the screen is and
we have reduced four lines into one. So great job. Let's move on. Okay. Now you're going to take what
you've learned about the margin shortorthhand and use that in order to reduce these two lines into one. So
you're going to replace the two margin properties with a single margin shortand. And of course after you've
done that the card should still be centered as it is now. So go ahead and give this one your best shot.
Okay, let's do this. So I'm going to start by removing both of these. Now you can see the card is aligned on the left
side. So in order to fix this, we'll do margin. And then the first property we'll set will be the vertical line,
meaning margin top and margin bottom because we're only going to set two values. And when we do that, each of the
value dictates two sides either top bottom or left right. So we'll set zero as the first value. That means margin
top zero and margin bottom zero. And then for the second value which dictates the horizontal margin meaning left hand
side and right hand side we'll set of course auto. And there you see now the card is still centered and we have
reduced two lines into one. So great job solving this challenge. You have reached the final step of the
business card project. That is phenomenally well done. Give yourself a pat on the back. And now only the fun
stuff remains because now you're going to personalize this card. So first I want you to add your own information to
this card. As for the image, you can just drag and drop an image over the file system here and then link to it
from the source. And once you've done that, head over to the CSS because here you're going to do a few cool
challenges. First off, I want you to find a color palette you like on coolers.co. And this is coolers. It's a
super neat site for finding nicel lookinging colors and color combinations. So what you can do is
simply click this explore trending palettes. Then you'll come to this overview which has a ton of different
palettes. And you can also search up in the right corner here. Let's say you're a big fan of roses. Well, then you can
write that and then boom, you'll find a ton of pallets with rose looking colors. And when you hover over one of the
colors, you'll see the hex value of that color. And also, if you have an account on coolers, you can click on these three
dots here and then choose save palette. Then you can give it a name and save it. When you then later visit your profile,
which you can do by clicking up here in the top right corner, then you'll see all of your saved pallets. So go ahead
and find a palette you like on coolers and then change these values here so that your business card becomes
completely unique. Also once that's done I want you to find a web save font you like and add it to your card as well
because you shouldn't use Verdana. You should pick one of the other web fonts and if you have to Google a little bit
to find the web save fonts well that is just important practice as well. And then if you want to go above and beyond
go crazy I've created some stretch goals for you here. I want you to simply find other ways to personalize the design of
your business card. For example, you can change the border or borders. You can add a border radius. You can also
shuffle the layout like should the image be here or maybe centered at the top or at the right hand side or just in a
corner. I don't know. And if you want to do something mind-blowing, you can add shadows. For example, I've not taught
you anything about shadows, so that's far outside the scope of this course. Or if you want to go even more crazy,
double mind blown, create some hover effects so that when you hover with a cursor over some of the elements, they
change. That is business card 2.0 in my opinion. And if you want to go triple mind blown, create some CSS animations.
Now, please don't stress about doing any of these. It is not expected that you do any of them. I just wanted to add it
there for those of you who can't help going above and beyond. Now, once you're done personalizing your business card, I
have one more task for you, and that is to download the code to your local computer and then place it in a folder
called business card because we're going to use this folder when we deploy your business card in the next scrim. So, go
ahead and do all of this and I will see you when you're done. Last time we deployed a project, we
first added our code to Netlfy, which then again took care of deploying our project to the web. Now, while this
works perfectly fine, the way the pros do it is to go via an intermediate service and step called GitHub and then
let GitHub take care of sending off the code to Netlifi so that it's deployed to the web. And the reason you want this
kind of architecture is because GitHub allows you to collaborate on your code with other developers. So now we are
going to deploy your business card using this technique. The first thing you need to do is head over to GitHub. If you're
watching this course on Scribba, you can just click on this slide right here. But if you're following us on YouTube, just
head over to github.com and you'll get to the exact same page. Once you're there, I want you to click at the sign
up button. That'll open up a form where you have to add your email, create a password, and also choose a username.
Once you've done all of that, click the continue button, which then sends you to this onboarding screen where you can add
a little bit of information about yourself or just click on the skip personalization option if you are
impatient. Once you've done this, you'll see a dashboard. Yours is probably not as filled with information as mine,
though that doesn't matter. What we're going to do now is click on the plus icon in the top right corner. There it
opens up a menu where you are to choose new repository. The repository is the backbone of any software project. This
is where you'll find all the project files and GitHub along with the git protocol takes care of tracking all the
changes that has been done to the repository from its birth. Though we're getting ahead of ourselves right now. We
are just going to give it a name which you type in here in the repository name field like that. I'm going to call it
business card. And then I'm not going to touch any of the options here. I'm just going to scroll down and click create
repository. And there we go. Now, we have to upload our files. We can do that in many different ways. Right now, we're
just going to do the very simplest one. So, what I want you to do is click on the uploading an existing file link
right here as that'll take you to a drag and drop field quite similar to what we saw at Netlefi earlier. Here, I want you
to open up the business card folder which you created on your local computer in the previous scrim. Mark all of the
files and then just drag and drop them into the rectangle at GitHub. Once you've done that, you'll see all of your
files listed. Just scroll a little bit down and then we have to do something called commit changes, which might seem
a little bit weird and complicated, but don't worry about that right now. I'm just going to go with the recommended
text, add files via upload, and then hit commit changes. And boom, there we go. We have a repository on GitHub which
includes all the code we need for our business card. Now, if you were to collaborate with other developers on
this project, they would push their code up to this specific repository. And you would also probably create issues for
tasks you want to do and work with something called pull requests, which is when you want to merge someone's changes
into the codebase. And there's also a ton of other things you can do here, but we're not going to worry about any of
that right now because the only thing we want to use this repository for right now is as an intermediate step before
our deployment. So let's head over to Netlefi and make sure you're logged in so that you see the previous project we
deployed. And right besides it, you can see this button called add new site. Click on it and choose import an
existing project. Here you're able to choose GitHub. Click on that and it'll open this pop-up menu where GitHub asks
where you want to install Netlefi because that's what you're doing now. We're installing Netlefi on our GitHub
profile. Click on your GitHub username. In my case, Pier Borgan. And here I'm just going to leave all the settings as
they are. Scroll down and hit install. And there we go. Now you can see that Netlefi has pulled in your GitHub
profile and has your repositories listed. I have a bunch of repositories, so I'll have to search for the business
card. I'll write business. And there we can see it. When I click on this repository, it is imported into Netlefi.
And here I can adjust some settings, but I'm not going to do any of that as usual. Just scroll down to the bottom
and hit deploy site. And there we go. The deployment is now in progress. So we'll have to wait a little bit. And
then once this image turns into a screenshot of your site, it is deployed. So clicking on this link will open up
our business card. Really good job though. I hope your business card looks a lot cooler than this as you were to
personalize it in the previous scrim. Actually, to prove to me that you did personalize this, I want you to head
over to Twitter and share your deployed business card. Do as Michael the Rocket does here and mention me if you want to
alongside a link to your project and perhaps even a screenshot of it. That would be super cool. So, go ahead and do
that right now and then I'll see you in the next scrimm. Hi there, my name is Bob Zerroll and I'm
another teacher here at Scribba. You just learned a little bit about how to use GitHub to deploy your project to
Netlefi. I thought this might be a good opportunity for us to dive a little bit deeper into the differences between Git
and GitHub. This is going to be a little bit more surface level just so that we have a solid understanding of the
difference between the two. So, we're not going to be really diving into the weeds with either of these things quite
yet. To better understand them, let's look at the differences between the two. First, we'll start with Git. Git is
what's called a version control system. We'll talk pretty soon about what exactly that means, but it's important
to know that Git is something that runs locally on your own machine. If your machine didn't come with Git already
pre-installed, then it is something that you would have to download and install on your machine in order to use. And its
main task is to help us keep a history of the changes that we've made to our projects. In contrast, GitHub is an
online platform that stores something called Git repositories. The term repository is just kind of a fancy way
to say a folder of your code that you have been tracking the changes of in Git. In contrast with Git, which runs
locally on your own machine, GitHub runs online in the cloud. And where Git's main task is to keep track of a history
of the changes you've made to your project, GitHub is a way for one to share your code and that history of the
changes from Git with other people. Maybe an imperfect but illustrative analogy is Git is kind of like taking
photos on your phone or your camera, which happens locally on your own device. And GitHub is kind of like an
online photo sharing platform like Instagram. It's not a perfect example, but it does highlight some of the main
differences between Git and GitHub. Okay, we talked about version control. So, what exactly is version control? The
main thing that version control provides for us is a way for us to create save points, which in Git are called commits
of your code so that you can revert back to them if needed. These save points or commits aren't something that actually
alters the content of your code itself. This information is saved in kind of a separate hidden folder inside of your
project that is using git, but it provides you a way that if let's say you were to write some kind of bug into your
code or accidentally delete everything and then close your editor that you couldn't just undo those changes with a
git commit, we can revert back to that commit and have everything restored the way that it was at that save point. This
reminds me of the most difficult level of any video game I've ever played in my life. If you know, you know. And I
probably would have enjoyed this game a lot more if I had the ability to create safe points along the way that I could
go to every time I died or failed. Another major benefit of version control is that it manages changes made by other
people that are also working on the same codebase by giving us a means to merge multiple different versions of the same
codebase together and fix any of the resulting conflicts. If you've ever worked on a group paper and well, you're
old enough, you might be familiar with this phenomenon. As different people are working on their own parts of the paper,
you would end up emailing the paper back and forth and you had to come up with unique names. And then you'd have to
have someone in the group who was an editor and could take all of these different versions and merge them
together into one version that became the final paper the group would turn in. In the end, it just becomes a huge pain.
And this is something that version control helps us mitigate. Now, this isn't to say that you won't have two
people that make, let's say, a change to the same line of code, but in different ways, but rather git as a version
control system gives us a way to highlight those changes and decide which one of those changes we want to include
in the final codebase. In the end, version control generally allows us to be less worried about making any
mistakes or having our code conflict with other people that are working on our same project. Okay, so this is
version control with Git. Let's now switch over and start talking about GitHub. GitHub is a cloud-based SAS
product. As a SAS product, a few years ago, it was purchased by Microsoft. And its main feature is that it gives us a
way to share our code and the changes that were made to our code with those commits in Git with other people. As the
name would imply, it assumes that we're using Git as our version control system. As a side note, there are other version
control systems, but you'll see Git used far far more commonly than any other version control system out there. As a
feature of GitHub, they have integrated a number of Git-based capabilities right into the website. Things like
committing, merging, branching, and so forth. You don't need to know what those operations are per se, but it does
contribute a little bit to the blurring of lines between Git, the version control system, and GitHub, the
cloud-based SAS product, which contains Git repositories. Personally, I think it's really important for beginners to
become familiar with and start using Git and GitHub from an early point in their learning. But I do think there is a more
approachable way to do this and that's by using a product from GitHub called GitHub Desktop. This is a native desktop
application that you can download from the GitHub website and it allows you to perform git operations on Git
repositories on your local machine and in a pretty seamless way push those changes up to GitHub where they can be
shared with other people. If you're interested in learning more now about GitHub Desktop, you can click the
screenshot you see here. That will take you to another scrim that's in a future module here on Scribba, which is taught
by Treasure. Using GitHub Desktop might not be as hardcore as a senior developer who's using Git from the command line.
But with how powerful and therefore complex Git is, the learning curve can be a little bit steep. And I think
GitHub Desktop is a great approachable way to begin using and understanding Git. Either way, congratulations on
deploying your business card. That really is a huge feat and as P said, it's something that should be shared
with the world. All right, that's it from me for now, but I'm sure we'll run into each other in another lesson here
on Scribba. Bye for now. No matter how much you ended up personalizing your business card, I want
to say well done. You reached the end of this section, so give yourself a pat on the back. You deserve it. And let's now
have a look at what you learned at the beginning of this section. You learned about alt text on images, which is
really important for accessibility. And then you learned about child containers in flexbox because we created this card
as a flexbox container and made sure that it only had two direct childrens. So that these two got their own columns
and then inside of the second column you could add things on rows again, which is what we did here. That concept of only
the direct children being the flex items and then turning these children into containers again is a critical thing to
understand in order to create sophisticated flexbox layouts. Moving on, you learned more about inheritance.
This is something you had been exposed to before. But hopefully you have a more conscious relationship to this right now
as you understand how setting the text align on the card div that is this one right here makes that property applied
to these elements as well as they inherited the text align center from the grandparent that is the div up here. You
also learned about shorthands and more specifically the margin and padding shorthands. Here we're setting the
margin to zero at the top and bottom and auto at left rightight. And it is a lot more compact than writing out margin
top, left, right, and bottom all on their own lines. Another thing you learned about was web safe fonts, which
we used up here in the body where we used Verdonna, which is one of those fonts you can use without worrying about
whether or not it's installed on your users computers because most likely it is. And then a really important concept
in web design is color palettes. We took a look at that and hopefully you found your own palette so that you
personalized your business card because colors really do make or break a design. So that was quite a lot of concepts. You
should be really proud of yourself reaching this far. Now it's time for you to take a break so that these concepts
mature in your mind and do whatever you need to recharge your batteries and then I'll see you back here in the next
section. Welcome to the section where you are going to build a space exploration site.
Here is the example you're going to build. As you can see, it has this super neat background image that animates and
that really breathes life into the site. We're also using Google Fonts to pull in this custom spaceish font right here.
And we're doing a lot of interesting things with some subtle text shadows, this underline, and more. So, there will
be plenty of new things to learn in addition to reinforcing HTML and CSS concepts you've previously learned. So,
let's launch into this section. Okay, let's get started building our space exploration site. As you can see,
I've set up a basic HTML structure for you here. It is very simple as the body simply contains an H1 title and a
button. As for the CSS, there is no as we are going to add that now. So, the first thing we're going to do is fix the
background here because we don't want the white background. We want to have an image of the universe in the background.
Later down the line, we're going to change that to an animated image so that it looks like a video playing in the
background, which is even cooler. But, as for now, we're just going to do a standard background image as we're going
to work on this for a while and I don't want to have an animated image looping in the background as we work as I think
that's a little bit annoying. So, let's start out with just a static background image. And just so you know, background
images is something different than how you've used the images up until now where you've done img, src, some kind of
JPEG like that. Instead, background images are not in the HTML. They are added in the CSS file. Enough talk about
that. Let's just find a cool background image and then deal with how to implement it into our app. And the
service I prefer to use for finding cool images for your web design is Unsplash because the quality of images here are
really good. So they will take your web design to new heights and you can use them freely however you want. So if I
search here for universe, we'll get a ton of nice images. Let's scroll a bit down. As you can see, there's plenty of
good candidates here, but I think this one is particularly nice. So I'm going to click in on it. It is created by
Gilmo Furla and you can see it's really popular have over 12 million views already. Now if we want to download this
you can click on the icon up here and download it range of different sizes and I've actually done that and placed it
here in the images folder. So here you can see universe.jpeg. So let's see how we can add this to our
app. What I'm going to do is target the body because we want the image to span across the entirety of our page. So we
need to add the background image to the body. We'll use the background image property. And here we'll utilize
something called a CSS function. Don't worry about why it's called a CSS function. Just remember that the way to
do it is by writing URL open parenthesis and then inside of the parenthesis you refer to the image source just as you do
in the image with the img tag. It is using quotes. So inside of the quotes, we'll write the path to this exact
image. And the way we do that is first by navigating to the images folder. So images then slash going into the folder
choosing the universe JPEG. And boom, there we go. Suddenly our background changed. However, there's
a couple of problems here. Our H1 is now almost invisible since by default the text is black and the background is very
black as well. So I'm going to change the color to white. Like that. Much better. Also, this image is thousands of
pixels wide, whereas our browser is not that wide. So, notice that if we make it super wide, we still only see the edge
of the galaxy more or less the center of the image. So, what we need to do is shrink our browser down to like a couple
of hundred pixels wide, which is what we want. And then make our background image shrink so that it's squeezed into the
width of this browser. The way we do that is background size and the value cover. Boom. There we go.
Now the width of the background image is exactly as the width of its container which again is exactly as wide as the
browser itself. Meaning that the browser and the background image has the exact same width. And it looks pretty good.
I'm not going to give you a challenge on how to do this right now as you'll get plenty of practice using background
images later in this course. So, with that, let's just move on to the next scrim.
Okay. In this two-part challenge, you're going to improve the design of our app. First, I want you to center the text and
button and then style the button according to the provided design. And that is found here in the slide. As you
can see, the button is slightly different from how it is right now. Not too different, but certainly it has some
CSS properties applied. And I'm not going to tell you which because this is a good way for you to train your design
eye. When you design the button, I want you to use a class in order to select it. So, not just using an element
selector like we do here. So, go ahead and give this a shot and then I will show you the solution as well when you
return back to me. Okay, let's do this. First, we got to center the text on the button. And here
you can use a range of different options, either using margins or flexbox or text align. You've learned plenty of
ways to center elements. Now I'm going to choose the easiest one which is to apply a text align center in the body
element because as you know this centers not only the H1 but also buttons. Okay, with that out of the way, let's move on
to the button. First I want to give it a class and I think btn is a good class name. So let's add it to the HTML as
well like that and run the code. So we have it applied in the DOM. Now let's have a look at this design. The first
thing that is apparent to me is that this button has more space around the text. As you can see here, it's a bit
more crammed. So that is the padding property. Let's try 10 pixels just on all four
sides of the padding. Having a look at this button right now, you can see that this one is a bit more rectangular
whereas this one is a bit more squared. Now, cuz in this design here, there's more space on the left and right hand
side than the top and bottom. And if you remember the short hand, we can do this by, for example, starting with five
pixels on the top and bottom and 10 pixels on the left and right. And that looks much better. Maybe it's a little
bit higher. So, let's do six and 12. That looks pretty good to me. Now, the next thing I want to change is the
background color. It's not totally apparent, but actually, this one has a white background color, whereas this one
has the default button background color, which is a bit grayer. It's not that easy to see because of the background
here. It looks pretty white compared to the black background, but it is actually not entirely white. something you'd know
if you've worked with buttons in HTML for a while as they always have a default grayish background color
background white like that. Okay, now it suddenly became apparent that it also has a border in this default styling
whereas that's not the case in our provided design. So let's do border. We can do none like that. And with that, it
looks like we have completed our design as these two look identical as far as I can see. So, really good job. Let's move
on. Okay. Now, you're going to get a new superpower in your tool belt called
Google Fonts. And that is a service that gives you access to over a thousand different highquality fonts that you can
use in your projects. And the reason you need to learn about this now is because the font we have here isn't good enough
in my opinion. It is a little bit boring for a space project. What we want instead is something like this, which
looks a lot more sci-fiish. However, this font isn't one of the so-called websafe fonts you learned about earlier,
which is already installed in most operating systems. This is a very custom font. So, we have to use Google fonts in
order to bring it into our project. And here you can see the Google fonts interface. It's located at
fonts.google.com. And if we scroll a bit down, you can see it contains a range of very different
fonts. Now, it has a search feature up in the top left corner, but it's actually not that good to be honest.
It's better to just use regular Google search when searching for Google fonts. So, let's do that instead. The way I
found the font we're going to use now is just by googling sci-fi and then Google font. And then Google suggested this
Orbitron font. So if we click into it, you can see here it is. If we scroll a bit down, you can see we have to choose
specifically which styles we want. So I'm going to choose this 400 regular style by clicking on select this style
like that. And you can see the panel on the right hand side. And it is clear that we have chosen the orbitron font
and the regular 400 font weight. Also, let's click on this extra bold in case we want to bold some text on our site.
And there we have that one as well. Now, if we want to use this on the web, we can embed it by simply copying a piece
of code into the head of our HTML. And that is the code you want to copy and then paste it in exactly here. Next up,
we also have to specify it in our CSS. That's done by pasting this line into our CSS, for example, in the body tag.
I'm not going to do this for you, though. Scribba is all about you doing things on your own, getting your hands
on the keyboard. So, now I want you to head over to Google Fonts, fetch the Orbitron font in these two styles, and
then do whatever you need to do in order to make the Orbitron font render properly on our site. I'm going to leave
you here with this screenshot because make sure to compare this design with what you get in the mini browser because
there might be something you need to do down in the btn selector. And hopefully you're able to spot that. If not, no
worries cuz I'll be here showing you the solution when you return back to me. Good luck.
Okay, let's do this. So, first we're going to take this snippet of code right here and then paste it into our HTML
like that. Then need to run the code so that it is imported into our project. And then next up, it is the styles which
we're going to set here. Let's copy that line of code. And then simply paste it in right here. And boom. Join the
exploration now looks like our project right here. However, this one also has the Orbitron font applied to the button,
but we don't have that. We still use that boring old font that we had previously. Why is that? Well, that's
actually because buttons don't inherit font families. So, here the H1 has inherited the font property from body,
but the button has not. So, what we need to do here is specifically tell the button to have this font family. And we
can do that in two ways. One way is through using a CSS value you haven't learned yet, and that is the inherit
keyword. As you can see, now it does inherit from the body, but only because we've specifically told the button to do
exactly that. What I'm assuming you did instead, which works perfectly fine as well, is simply to paste in the font
family orbitron on the btn class. As you can see, that also works well. So, hopefully you were able to spot this. If
not, no worries. It was just a little gotcha I left here. Let's move on to the next scrim.
Before we move on from the subject of fonts, there's one more technique I want to teach you. Because in some cases,
Google fonts might actually not be enough. And that's typically the case if you want very specific fonts. For
example, let's say that you are building a Godfather website in honor of the classic film. Well, in that case, you'd
probably want to get a hold of the real Godfather font. though Google Fonts doesn't host that one because it is
simply too specific for them to care about. So you'd most likely have to find this font somewhere on the worldwide
web. And there are great services for this. For example, a 101font.com there. If you search for Godfather, they
actually have it. So you can click into it, scroll a little bit down and click download. So what you then did is kind
of downloaded the recipe for the font. And if you open up the folder you got, you'll see a TTF file. That's a file
format for fonts. What you then can do is simply drag and drop that file into your file system like I have done right
here. You can see I have the cordoneion.ttf file. Now what I can do is use the at
font face rule in CSS. So simply writing an at and then font-face and then open up the curly brackets and write two
properties. The source which should use the URL technique pointing to the TTF file which I'm doing right here. And
also I need to tell CSS what name I want to give this font in my stylesheets. And I'm just going to choose Corleona for
now. But I could have chosen whatever name I wanted. Now I'm able to target the H1 and use this font family. So I'll
do font family or Leona. And there you can see I have the Godfather font. So I'm off to a
great start on my tribute page. So now what I think you should do is actually try and do this yourself. Find a random
font online, download it so that you get a hold of the TTF file, drag and drop that TTF file into the file system here
on Scribba and use the add font face property to make that font available in your stylesheets. Once you've done that,
I will see you in the next scrim. Now you are going to learn about the span tag because in the next scrim you
are going to create an underline under the exploration word and in order to achieve that you need the span tag. So
let's take a little step back from our space exploration site and learn all about this awesome tag. The example
we're going to use in order to learn the span tag is of banner ads. You've probably seen these before. You've
browsed the web, for example, on news sites. And many of these are actually so-called HTML 5 ads where they are
built using HTML and CSS. And it's actually a little bit sad how many clever developers in this world who are
spending all of their time in their best years and getting more people to click on these ads through making them more
invasive, more eye-catching, and more targeted. But that's the name of the game. So, we just have to accept it. And
you are now going to do exactly that. you are going to make this ad more eye-catching so that hopefully more
people click on it and visit our scammy casino. So, how do we do this? Well, looking at the HTML, you can see the div
wrapper has a class of ad which sets the background color, border, and the text alignment inside of this green
rectangle. And there are two elements inside of the ad. It is the H1 and the H3. And it says click here. So, what we
want to do is make this hair word pop out more. So how do we do that? We can't target the H3 itself because that'll
style the entire sentence. We only want to style this word. And this is where spans come in. Here we can write span
like that. Open the tag before the word and close it directly afterward. If we now run this code, seemingly nothing has
happened because spans are invisible unless you give them styling. So they're kind of like the div as divs neither
provide any styling unless you give it to it specifically. Although the difference is that spans are in line
whereas divs are block based. So to demonstrate that if we change this to a div. What would happen if we run the
code is that it would break the hairword onto a new line because divs are display block. They take up all the available
space in the width. Where spans do not do that. Only take up the space they need in order to make room for this
content. What we now can do is give this span a class. I'm going to call it CTA. That's short for call to action as
that's normally what these kinds of elements are called. And in the CSS, we'll do CTA. Let's just see that it
works by doing color red. Yes, there we can see we have now only targeted the here word. This doesn't look
particularly good though. So, let's instead do something that makes it look a bit more like a button. For that, we'd
need a border in my opinion. For example, 2 pixels. And we want it to be solid. And here, let's steal the color
from the border around the ad so that we reuse it a little bit. I think that can look nice. Yeah. Okay. Here you can see
that it it's added a border around the word. It is very crammed on the left and right hand side. So, let's try to add
some padding. Let's just do five pixels or something. Actually, I think we can do five pixels on the top and 10 pixels
on the left and right. Yeah, that looks much better. and then to make it pop out even more so that it doesn't blend into
the overall background we have on the ad itself. So I'm going to do background. Now I happen to have a nice brown color
here which I think looks decent with the other colors here. So now it is a lot more easier to see that you are going to
click here on this thing that looks like a button as it stands out more. And hopefully we have increased the
click-through rate with 0.02% 02% and thus made our boss really happy. So, great job. Now that you've learned this,
let's return back to the space exploration site and put your new skills to the test.
Okay, now you're going to create this neat little underline under the expiration word. And I want you to do
that using a span and a class. as for the specific design of the underline and what kind of CSS property you are to
use, that is something you'll have to figure out on your own. So, go ahead and give this a shot. Good luck and I'll see
you on the other side. Okay, hopefully that went well. Let's do it. I'm going to start with adding this
span to the HTML. It should wrap the exploration word. So, span like that. And then I'm going to give it a class.
I'm going to call this class underline because it'll only have one job and that is to give the expiration word the
underline. So this class is something we've talked about earlier. It's a utility class. It only has one job and
that is setting a single CSS property. So if we run the code now, nothing has seemingly happened. But we do have this
in our DOM, meaning we can select it in the CSS. We'll do dot underline like that. Let's just try and set the color
to red to see that it works. And yes, it does indeed work. But that's not the effect we want. We want to set the
underline. And what is this underline? Well, it's actually just a border bottom. We do border bottom like that. 2
pixels solid white. You can see yes, we indeed get a border under it. However, this border
looks a little bit thicker. So, I don't think 2 pixels is the correct thickness. I think we want to have something like
four. Yes, that looks pretty good to me. So, we have solved this challenge and we are ready to move on.
Okay, now we are going to add this SpaceX logo at the top here. And while you're adding it, you're going to learn
a whole new concept in HTML and CSS, namely a close cousin of the class attribute, which is called the ID
attribute. And the way to use it is simply by writing ID instead of class. But now you're probably wondering why
would we use this ID? If we now try to rerun this code, you can see that our underline is gone. And that is because
when you are using an ID like this, you have to refer to it in the CSS not by using a dot but instead by using a
hashtag. There you can see now our border bottom is again applied to our example. So now you're probably
wondering, well, why would we want to use this? It just further complicates things by having both ids and classes to
worry about. And the thing is they serve two different scenarios. You should use an ID if you know that your element is
unique and you'll only use it once. So ID of underline should only be be applied once in this entire document.
Whereas class is something you can reuse again and again. It's meant for reusage. So if you for example wanted a button
here that also said for example FAQ's then a class is what you use in order to make sure that this button has the same
styling as this button. But if you did that with IDs and turned the btn here into an ID, this would be invalid HTML.
Browsers are very forgiving. So it probably would work technically. The styling would be applied but you just
shouldn't do it. Now, as for this idea of underline here, I actually don't think it makes sense to use an ID
because this underline here could perfectly fine be a part of our design system and also be applied at multiple
other sections and paragraphs throughout our entire page as we build out this space exploration site. So, I want to
have the freedom to be able to reuse this later as well, even though I'm only using it once now. So, I'm going to turn
this into a class again. Rerun the example. Now, it's not applied. and then go from the ID selector to the
class selector in CSS by replacing the hashtag with a dot. And there it is applied.
So that was a long intro. The reason for that was that I want you to render this SpaceX logo. You can see I've added the
SpaceX.png image file up here. And then I want you to give it ID because this SpaceX logo
at the top here is most likely unique. We probably don't want to have multiple centered SpaceX logos at this size. So
this is kind of our main logo and you can give it that ID main logo. Then in the CSS you need to select the
logo using whatever ID you have given it. Then as you'll see you'll have to reduce its size. That's why you need
this CSS rule right here because it is far too big this image. Finally I'm going to remove this FAQ button so that
we're back to our original design. Now it's your turn. Take over and try to solve this challenge.
Okay, hopefully that went well. Let's do it. We're going to render it using an img tag and the source will be first
images and then slash spacex.png like that. If we run this, you can see,
oh wow, that is not exactly what we were looking for. It's far too big this image. So we
have to reduce its size. And to target it, we're going to use an ID. And I'm going to call this main logo like that.
Now if we head to the styles.css, we'll do hashtag main- logo. And here we have to reduce its width. So let's try
with for example h perhaps this is 200 pixels. I don't know. Let's try 200 px like that. That
was a bit too large in my opinion. So, let's reduce it further to 100 pixels. And yes, that is much more like our
design in my opinion. Looking pretty good. So, with that, we have solved the challenge. Great job.
Now, we're going to breathe some more life into our example here because it works fine with this static JPEG as the
background image, but wouldn't it be a lot cooler if it was animated? So, you could see the stars flying around. And
in our images folder, we now just happen to have a file called galaxy.webp. Hm. What's that? Let's just try to
replace this universe JPEG here with the galaxy webp file. So I'll do galaxy.
Webp and boom. The galaxy webp is an animated image in which you see a bunch of stars around the galaxy. And to me
this looks a lot cooler than what we just had. Now you might wonder what this web p
here is. And that is just an image format pretty similar to so-called GIFs, GIF. And GIF is what you recognize from
all over the web in animated images like this one right here, which you've probably seen before. So WEBP is used
exactly as GIFs are on the web. However, it has a better compression. So it's more compact and doesn't use as much
data as GIFs use when they're sent from a server to a client. So we want to use WEBP where we can. And now you might
wonder, well, where did you find this galaxy.p image? That is on a site called Gy. Giphy. That is a search engine for
GIFs. So, I just navigated to it, searched for galaxy, scrolled a little bit down, and found this neat looking
galaxy GIF here, created by the European Space Agency. Now, this is a slideshow, so you can't see that this GIF is now
being animated, but it actually is because I just saved this image to my local computer and then uploaded it to
the images folder right here. Now, if you want, you can also click on the share button here and click copy GIF
link. And then you can simply paste that link into this URL. And then that'll give, as you see, the exact same result.
But I prefer to rather use the version which we've imported into our project right here in case the gy file might
change at some point or something. However, for experimentation purposes, I think you should head over to GY, search
for a few images, and just paste them in right here and see how that affects our example. Just so you've got familiar
with using gy and pasting external URLs into the background image property in CSS. So, go ahead and do that and then I
will see you in the next scrim. One thing I like to do when working with images as backgrounds is to fetch colors
from the image and use it in the design because that can often look pretty cool. So, let me show you exactly how to do
that. We can use coolers, the service you're already familiar with because if you click on the more option in the
navbar, you can choose pick plet from photo. That'll take you to this image picker where you can choose an image by
clicking on the browse an image and either upload the image or paste a URL to it. Once you've done that, you're
taken to this nice tool where you can either drag and drop this picker around on the image until you find a color you
like or you can use this range input here as that'll automatically try to find interesting colors in the image for
you. And then it generates a palette as you can see right here. Now let's say we like this pette. Then we'll click export
and save PLET. And we have it in our dashboard. Now, it only has three colors, but that doesn't matter. I'm
only going to use one of these. That is the blue one cuz I think it would be cool to use this blue color as the text
color on our site. So, I want the H1 and the button text to have that bluish color. And the way I'm going to do that
is change the color of the body here because that is where the H1 gets its color from. It is the only element
inheriting from the body at this point. So I'm going to do like that. This is the hexodimal value I got from coolers.
And as you can see, I think it looks pretty cool. And also let's keep the underline white because I think it makes
sense to have that in a different color. Now moving on to the button. We'll do color
and paste it in again. And there we go. Now here I think actually this apply text could be a bit clearer because the
contrast with the background is just okay at this point because with this blue color I think the thin letters
became a bit too thin. Now a final thing I want to do with this apply text here is make it a little bit bolder make it
stand out a bit more. And luckily we imported not only the regular font weight with the Orbitron font family but
also the 800 font weight the extra bold. So what we can do now is actually do font weight
and then just bold. And there you can see it actually bolded the text. Or we could use the value directly which is
800. that'll give us the exact same result as the font weight property can both take numerical values and named
values. So the numerical values range from 100, 200, 300, 400 and so forth up until 900. And the named values are for
example normal, bold and so on. So we imported 800. So let's just write 800 here. With that I think our example
looks pretty good. So let's move on. Going to space is definitely a risky affair. So, I want to add this terms and
conditions apply text underneath the main section of our site. However, I don't want to add this. This is Scrimba,
so you're going to do it, of course. But, I'm going to give you a set of detailed instructions so that you know
how to go about doing this. So, you're going to start with wrapping the hero section in a div. And the hero section
is the one you can see on top here. It's very often called a hero section in web design and it's probably called that
because kind of serves as the user's first glimpse of the company and the offering and has this kind of prominent
place towards the top and it usually extends full width. So it is kind of the hero of the website. So in our case it
is these three elements right here the logo title and the call to action button and those should all be wrapped inside
of a div. And then I want you to move the background image that is the animated galaxy image from the body and
over into this div. Now as you do that you'll notice that you'll have to add some padding to this hero div as it'll
look really crammed if you don't add that. Then I want you to add the terms and conditions apply in an H3 below the
hero section. And then finally, a problem you'll probably come across is that the body tag has some default
margins, which right now doesn't bother us, but which will become apparent once you change this layout. So, go ahead and
give this one your best shot, and when you return back to me, I'll show you how to do it as well.
Okay, let's go. I'm going to start with the hero section div. I'm going to add it right here. I'll give it an ID of
hero because it is unique. So it's okay to use ID and then I'm going to indent this in and
run the code. And seemingly nothing has happened because as you remember from previously divs don't have any default
styling to them. So what we need to do is target the hero and then move the background properties from the body to
the hero. And there we go. And as you can see, it doesn't look particularly good. Now, as I said, we will be forced
to deal with the padding in the hero because you can see here the logo is really crammed all the way up to the top
and there's no space underneath the button. So, let's add padding. And on the top, maybe we want 10 pixels like
that. Yes. On the right hand side, we don't need anything for now. But on the bottom, we want a lot of padding. Maybe
we'll do 40 pixels like that. Then on the left hand side, don't need anything either. So here we have the padding.
Now let's add the terms and conditions. Apply H3 below the hero. That's just like this. Adding an H3. Terms and
conditions. Apply like that. Run the code. And there we go. It has already the color we want since we have set the
blue color as the text color on the body. So, it inherits the color property from the body. However, as you can see,
are still not quite done because something has happened with the margins on the site or or at least the margins
of the body has become more apparent because now the entire body isn't filled with the background image anymore. So,
we're suddenly noticing that the body has some default margins on all sides. We don't want that. So, we're going to
neutralize that by doing margin zero. And boom, there we go. We have completed the challenge. Now there is one more
thing which is a little bit problematic which is that if you watch this on a mobile for example so that the
exploration word is located directly over the galaxy the readability sinks quite a bit because the text color
blends in with the background and the way we'll fix that is by using a shadow technique on this text. So now you are
going to learn exactly that. Text shadow is a really nice tool to have in your web design toolkit as it
can make your designs much better. So here I've created a very simple imitation of the Netflix logo with the
red background and white text. As you can see, I've pulled in a font which kind of looks like the Netflix font.
It's not really the same, but it's close enough. And it is an H1, and I've set the font size to 80 pixels. Now, what if
I want to have a black shadow like this? as that makes it look even more like the classical Netflix logo. I can achieve
that by on the H1 which is the element that includes the Netflix text as you can see here. I can add a property
called text dash shadow which must contain three values. So just bear with me here as I'll write all three of them
out and then I'll explain it. I'll do 0 pixels 0 pixels black and seemingly nothing happened. That's because I first
wanted to show you the third value here, black. That's pretty simple. That's just the color of the shadow. And as you can
see here, it is black. The two other values dictate the offset of the shadow on the horizontal line and the vertical
line. So if I add, for example, 5px here, you can see that now the shadow appeared. It's as if it's sticking out
to the right of the letters 5 pixels. If I do the opposite, minus 5 pixels, it'll stick out five pixels on the left hand
side. As you can see, there's no shadow below and above because that's dictated by the second value. So, if I turn this
back to five and on the vertical one, do for example 30, then you can see that the shadow got pushed far too much
downwards. If I do minus 30, it's pushed upwards. If I do five pixels, it's pushed only five pixels downwards, which
looks pretty good actually. It is indeed the design we were looking for. So summarize here, the first value is how
many pixels you want to push the shadow to the right. The second value is how many pixels you want to push the shadow
downwards. And the third is the color. So what I want you to do now is try to make the shadow look like this. As you
can see, now it's on the left hand side and below like as if the sun is shining from the top right corner. So take a
guess at how you need to change this line 11 here in order to get that effect. Go ahead and do that right now.
Okay, hopefully that went well. What you need to do is basically put a minus in front of the first value like that. That
shifted the shadow from being on the right hand side of the letters to the left hand side. Okay, changing it back
again. Now I want to teach you about a fourth value you can add to the text shadow property and that is the third
pixel value. So here you can also write for example 5 px. And what happened now? If we compare what we have here right
now with how it was before we added that value, you can see that previously the edges of the shadow were sharp. There
was no blur. Whereas here, they're kind of fading over into the red color behind it. And this is called blur. And if we
reduce this one to zero again, the edge is sharp again. Now, if we do something crazy like 50, you can see that it is so
blurry that it just looks a little bit like background is a little bit dirty. So, let's get it back to zero again
here. What I want you to do now is try to achieve this shadow. Go ahead and give that a shot right now.
Okay, hopefully that went well. Let's have a look. You can see the shadow is above and to the right of the letters.
Let's fix that first. To have it on the right of the letters, we need plus value on the first one. We want to push it to
the right and we want to have it above. We don't want to push it downwards as we're doing with this value. So we want
to minus it pushing it upwards like that. Now the only difference is that this is a lot more blurry whereas this
is completely sharp. So let's try five pixels here as well. And boom, there we go. That looks pretty correct to me. So
great job doing this challenge. Before we move on, I have just a final trick I want to show you, which is a little bit
of a hack, but super useful because let's say that, for example, the background here was white smoke instead
of the red color. And white smoke is a very white color with just a little bit of gray in it. As you can see, it looks
really bad. Now, we can hardly see the letters, but we can clearly see the shadows. If we now set zero pixels on
the two first values, but keep the blur, well, then suddenly there's no shadow, but there's just a glowing effect around
the letters, making them visible, even though they are in almost the same color as the background. And if we make this
smaller, for example, one, you can see the line around the letters look a little bit sharper since it's very
little blur now. And if you do like 20, each letter gets a lot of blur around it and thus making them visible. So that is
a little trick to use normally with small values on the blur in order to make your text stand out a little bit
more in the situation where your text color and your background color is a little bit too similar. And this is very
relevant if you have a background image in which the contrast between that image and the text color is a little bit too
weak. So then you'd use this hack to make your text stand out despite the similarities between your text color and
the background image. So that was quite a lot about text shadows, but now you know it. So we are ready to move on to
the next scrim. Okay, now we are going to fix this problem of the text blending too much
into the background when it is broken into two lines and thus are located exactly over the galaxy in the
background image here because the readability is a bit too low. Now, in my opinion, I want you to fix that by
adding a blurred border around the H1 tag using the technique you just learned. You should set the blur to four
pixels and the color to black. So go ahead and do this right now. Then I will show you the solution as well when you
return back to me. Okay, let's do this. So first we need to select the H1. And we've been really
good at using IDs and classes here. So instead of just selecting the element, I'm actually going to give this one an
ID of title because we probably only have one title on the page. So running this and navigating back into the CSS
file, I can select the title and then I need to use the text shadow property. We want both the horizontal offset and
vertical offset to be zero pixels. We're not actually doing creating a shadow here, the effect we want is more of an
outline. So then without any offset, but four pixels blur, it'll blur a black shadowish effect around the entirety of
all the characters. So if you look at it now and look closely, there is a slight blurred black border around the letters.
It's not that easy to see, but if you now look at this while I comment out that CSS rule, you'll see the
difference. So keep looking at the exploration word and I will comment it out now. Now I'll comment it back again
there. Comment it out. Comment it back in again. So, so hopefully you saw that it
changed here a little bit. So, now the readability is a little bit better. Great job.
Hey, it's Gil. I'm a teacher at Scribba. Before we wrap up this section, I want to drop in and teach you about a small
yet important part of your HTML document, and that is setting the document language using the HTML lang
attribute. And this is important for several reasons. First, screen readers use the lang attribute to determine
which language to use when reading the content. And this is essential for users who rely on assisted technologies.
Search engines also use the lang attribute to understand the language of your content. And it also ensures
consistency in language specific features like date formats and specific character sets. Setting the language is
quite straightforward. In your HTML file, you'll use the lang attribute like this in your opening HTML tag. And the
value of this attribute should be a standard language code. For example, to set the language of your document to
English, you would use en. And for Spanish, it would be E S for espanol. These language codes are standardized
and usually consist of two or three letters. You can easily find the correct code for your language with a quick
online search. Sometimes your page might contain content in multiple language. In that case, you'll set the primary
language in the HTML tag and use the lang attribute on elements with different languages. For example, in the
H3 tag, add a lang attribute and set it to Spanish. Setting the language of your page might seem like a small step, but
it does play a big role in accessibility and helps your website reach the right audience. To learn more about the ling
attribute and all the different language codes, be sure to review the MDN docs reference listed here.
Now, I'm not sure if you're aware of this, but you're the best because you've completed this section and that is very
well done. Plenty of people who have started this section has never completed it. You're not like them. So, I am
really proud of you. And let's take a quick look at what you've learned. Starting out, you learned about
background images. More specifically, you learned about the background image property and the URL function and also
the background size property in CSS and setting that to cover. We also then used a webp format in order to get this
animated image in our hero section, which is super cool and really breathes life into our website. And then you
learned about Google fonts. We imported them up here in the head section and then you set the font family like this.
Fonts do so much for the design of websites. So, this is an important thing to know as a web developer. And you also
learned a new HTML tag, which is the span tag, which you can see right here. It is what allowed us to create this
underline under the exploration word, which it did in combination with a utility class. The underline class,
which only has one job, and that is to set the underline whatever element it's applied to. And then also we learned
about ids which is another attribute in HTML that you target in the CSS using a hashtag. And at the very end we did a
really cool trick with the text shadow property in order to make the readability of our title here a little
bit better. So you've learned some key concepts in this section. Now is the time for you to get up, stretch, maybe
get a cup of coffee or whatever you prefer to recharge because be sure to do exactly that. And then I will see you in
the next section. Welcome to this section where you are going to build a birthday gift site. And
it is just so cool because this site is something you can use for whenever a friend or family member of yours has a
birthday. So what you do is basically add their information to the header here. And then we have these gifts. So
for example, this one saying here's how happy I am for you today. And when the birthday boy or girl hovers over the
image, they will see a nice gift that makes them feel truly appreciated. Going down, we have other gifts. How people
react when you enter the room. Ooh, this is meant to make them feel really good-looking. And here, if I had to
describe you with one word, genius, so that you make them feel really smart. Next up, the only person as badass as
you is, of course, James Bond. And then rounding it up with a little toast. So hopefully you have someone special to
send this site to like Nick Air for example who despite being a computerenerated image created by an AI
also is one of my best friends. So I am looking forward to make Nick happy on his birthday. Let's just get started
with this section. Okay, it's time for your first challenge. What you're going to do is
create this basic design here for the header of our app. and it's pretty far from what we got right now. As you can
see in the styles.css, we have no styling at the moment. So, our site looks pretty dull. You can see
everything is left aligned and the image of Nick is far too large. Plus, we're lacking the appropriate font. Taking a
look at the HTML here. It's just a very simple structure with an H1, an image tag, an H2, and an H4 inside of the
body. So, nothing special there. The font that you will use is called Happy Monkey and it is a Google font. So
you're going to have to head over to Google Font, fetch it, and then embed it into our project. As you can see in the
provided design, the image of Nick should be rounded and not squared as it is right now. So you will have to figure
out how to make an image round. And yet again, you'll find the answer if you Google it. Finally, I want you to
consider how you should select the image. So, should you use a class selector, an ID selector, or an element
selector? You can use any of them, but I want you to think about it and try to figure out what you think makes most
sense. Go ahead and do this right now, and then I of course will show you the solution when you return back to me.
Okay, hopefully that went well. Let's do it together. I want to start with centering everything. And for that, I'm
going to do body and then set the text align to center like that. As you can see, that
indeed centered our elements. Next up, I want to fix the image. It is here. And I think it makes sense to use an ID
selector here because this is kind of the main image of our birthday boy. And I don't think we'll duplicate it across
the page. So, it is unique, meaning we can use an ID. So, I'll do ID equals and then BFF for best friend forever because
Nick is my BFF. Please don't make fun of me because my BFF is a computerenerated image. But that is just how it is. And
then I'll do dash img just to make it a little bit easier to understand what it is based upon the ID name. Then I'll run
the code so that that is applied to the DOM. And heading over to the styles, I'll do #bfff-
img like that. And first I want to fix the width of it. It's far too wide. This looks more like 100 200 pixels. So,
let's try width of 150 pixels. Like that. Yes, that is pretty much what we're looking for. And hopefully you
figured out how to make an image round. And the way to do it is to use the border radius property, which you've
seen a couple of times by now. And the maximum border radius an element can have is 50%. And boom, there it is
completely round. All right. The final part is to add the Google font, the happy monkey font. That is a very
birthdayish font. Actually, I found it just by googling Google fonts birthday. Then happy monkey was the top result.
Clicking into that, we'll select it by clicking select this style and then we'll copy the links here so that we can
embed it into our project. I'll paste that into the head of our project. Then copy the font family rule so that I can
paste that directly in as well. Now I'll have to rerun so that the font is embedded. And yes, there we go. That is,
as far as I can see, exactly the design we were looking for. So great job. Let's move on.
Okay, your next challenge is to colorize the app because I want it to look like this with a nice blue background, pink
border, and white text. And as you can see, I've provided the hexadesimal values for the pink, blue, and white
colors here. So your job is simply to figure out where you need to add these and what kind of CSS properties you're
going to use. Go ahead and do this right now. Okay, hopefully that went well. Let's do
it together. I'm going to start here in the body taking the blue hexodimal value and setting it as the background of the
body. Boom. There we go. Next up, we want to set the color property here to white. Just six Fs after each other
like that. Now that is inherited down from the body into all of these. Okay. Final step is the image. As you can see,
it should have a border around Nick and it should be pink. So here we'll use the border property and let's try six pixels
because it looks pretty thick. It should be solid. And then we'll copy the hex value from pink and paste in right
there. And actually that looks about right to me. So great job. Let's move on.
There is one problem with our site at the moment, which is that if we run these two colors through a contrast
checker, for example, userway.org, you'll see that our accessibility actually fails because the contrast
ratio is too small. So, what can we do to improve this? Given that we want to keep the colors we have, what we can do
is use the trick you learned in the space exploration section. Because pay attention to what happens to this text
if we add a thin black border around the text using the text shadow property. So this is without the text shadow property
and this is with it. As you can see the text now stands out more as the black contrasts well with both the white and
the blue background. And it is also pretty subtle. So the text still looks white but it's just a little bit more
visible. And in my opinion I think the readability here is pretty good. So what I want you to do now is write the CSS
for this exact technique. So add a thin blurred border around the H1, H2, and H4 elements using the text shadow technique
you learned in the space exploration section. You're going to set the blur to one pixel and the color to black. Okay,
hopefully you remember how to do that. Give it your best shot and then I will of course show you the solution as well
when you return back to me. Okay, let's do this. So, let's start with the H1 here. And here I'm just
going to use an element selector as we'll have a lot of H2s and H4s throughout the site. And I think we want
all of them to have this style. So, there's no point separating it into a class. So, text shadow
setting the first two values to 0 pixels as we don't want any offset vertically or horizontally. But the third value,
the blur should be set to one pixel. And then the color is black. And boom, there we go. We have that thin outline which
improves the readability. And now you probably did something like this. Added a whole new rule for the H2 and yet
another one for the H4. And if you did, that is completely fine. That is how I expected you to solve this
challenge. But I do want to show you a little trick which allows us to reduce all of these into one line. And that is
simply by using a group CSS selector where you simply add multiple selectors on one line. So what you do is instead
of just writing H1, you write H1, H2. Now we can delete the H2 because this rule is applied to both the H1 and
the H2. And likewise we can just add the H4 here as well. Like that. Now we can remove all of this. As you can see, the
thin border is applied to all of the elements. Now, it is really important that you actually use a comma here and
not just add it like this. This means something entirely different and we're not going to learn about that right now
as it's outside of the scope of this section. So, make sure you have the commas and then you can use this
technique. And I happen to know that we also want this text shadow to be applied to our H3 elements down the line and
also our paragraphs down the line. So, I'm just going to add them here so that we don't have to think about this as we
add new elements to our site later down the line. So, great job. Let's move on. Now, we want to take this pink
background that we have around the image and apply it behind the H2 and the H4 element so that it looks like this. So,
let's try the most intuitive approach and see how that works. That would be to target the H2 and the H4. I'm going to
use this comma selector here to target both simultaneously as we've done up here. And then we'll set the background
to this pink color right here. However, as you can see, that did not give us what we wanted because heading elements
like H2 and H4 are by default display block. So they take up all the available horizontal space. So let's then try to
turn them into display inline and see what happens then. Ah, that did not work well either
because when they're in line, they're actually narrow enough to be on the same line and actually jump up to the line
above with the image, which also is display inline. So, let's remove the display inline as well. And the way to
actually solve this is to use a technique you haven't learned yet. Now, I'm just going to show it to you fast,
and then we're going to take a closer look at how it works in the next script. Because what we can do is head into the
body, which is the container element for these two and for all of our elements actually, and do bisplay flex. That
stacks things up on a horizontal line, turning every element into its own column. But we can change that by doing
flex direction, which now is set to row by default. And that might sound a little bit confusing since I've always
said that flexbox turns every element into its own column. And yes, it does that. However, what it also does is make
sure that all of the elements are in the same row. So that is why it's called flex direction row because rows go from
left to right. And you can see there's only one row from left to right here, which becomes even clearer if you do
like this. And all the elements are inside of the same row. Now, in order to flip this, we can simply change row from
column like that. Now all of the elements are stacked on top of each other again in one column because a
column goes from top to bottom. So this is just one column. Now with that in place, we can use another CSS property
in that flexbox gave us which is called align as items and set that to center. And boom, there we go. Now, this was
probably pretty confusing and you were not meant to to understand this right now, which is why we're going to take a
little digression here and look closer at how flexbox works and then return back to this example where you will code
it up yourself and properly understand it. If you are to become a flexbox master,
you will need to know align items. Luckily though, it's not that hard to learn because it is a close cousin of a
property you already know, which is justify content. So, let's pretend that the two of us, for example, work in a
lab together. Well, if so, we'd have our lab equipment, which you can see here, inside of our lab, which is this green
rectangle right here. And what we're going to do now is use flexbox along with the justify content and line items
in order to organize our lab equipment in different ways in our lab. So let's have a look at the code. The HTML is
very simple. It's just a container which has three divs and each div hold exactly one piece of lab equipment visualized
via an emoji. If we head over to the CSS, you can see that the container has a border and a fixed height. So that is
why we get this green rectangle. The items have a width and a height. There's some margin in between them and some
padding on the inside. I've set the font size and also added a border. And finally, something you haven't learned
yet, but I've added a gradient background so that the color slightly fades from a darker shade of green to a
lighter shade of green in the background. Now, you are going to learn about the linear gradient later on. So,
don't worry a second about this right now. Just accept that it is how it is. And let's get going with the organizing.
So as you can see by default the lab equipment the divs that is are stacked on top of each other because as you
remember divs are display block. However if we turn it into a flexbox layout each of the item gets its own column and
as a consequence they stack up on the horizontal line. So far so good. And if we set the justify content property
it'll arrange these in different ways along this horizontal axis. So if we do center for example they are centered. If
we do end they are pushed all the way to the end and yeah you know the deal. So what align items does is instead of
controlling the horizontal line which I from now will call the main axis it controls the crossaxis which is the
vertical one going from top to bottom. So let's turn this back to start and do align items.
Enter. And boom, there you can see now it pushed all of the three items down to the center so that they are centered
vertically meaning they are centered along the crossaxis. And then I can combine this with the main axis which is
justify content that controls the horizontal one going from left to right. For example, do end here and boom then
we are still vertically aligned. So we're in the middle but we are pushed all the way to the right hand side along
the main horizontal axis. So the values you are going to use for line items to begin with are start, center and end.
Whereas with justify content as you know you can use start, center and end but also these space around space evenly and
space between properties. Okay, let's move on to the challenge. What I want you to do is follow my orders on where
we should leave our lab equipment because I want you to do it in very specific ways. Starting with this
position here where they're all squeezed down in the bottom left corner. So go ahead and modify justify content and
align items to achieve that layout right now. So to achieve this layout you can see it
is at the bottom of the crossaxis the vertical one. So we'll do end on align items but it is at the start of the main
axis because it is pushed all the way to the left meaning that we should do start up here. And there we go. We have solved
it. Okay. New challenge. I want you to achieve this layout. Go ahead and do this right now.
So here we can see we are actually centered both along the main axis horizontally and the crossaxis
vertically. So I'll try center. Yes. And center again. And there we go. Okay. Final one. I want you to organize the
equipment like this. Go ahead and do it right now. Okay, hopefully that went well. The
first thing I'll notice here is that all of the items are squeezed to the top. So, align items should be start. And
there's some space around the elements. So, we need to try one of these. For example, space around, space evenly, or
space between. So, let's try for example space between. Hm, that didn't exactly achieve what we
wanted because there should be some white space on the left side and the right hand side here where these two are
squeezed all the way to the end. So maybe we can do space around instead. Yes, that looks exactly like what we
want. So really good job solving these three challenges. Before we move on, there's just a small thing I want to
tell you. And that is something you might see from time to time, which is that if I now remove the height of our
items, see, then they just became a little bit higher because the content inside of it wants a little more height.
But that was besides the point. What I wanted to do is also remove the align items. Let's see what happens. Oh wow.
It turns out that flexbox in the crossaxis actually stretches the content like this. And the reason it didn't
happen previously was because our height property overrode that stretching. So what this means is that align items by
default has the value stretch. When we do for example start, it's no longer stretched and it's pushed to the start.
So this might feel very confusing and the only reason I wanted to tell you about it now is that when you are in a
flexbox layout and you notice that something is stretching in a way you don't want it to stretch, the prime
suspect you should look at is align items and experiment with that. So be aware of that. But don't worry too much
if you found this a little bit confusing. It's totally okay. Let's just keep up the pace and move on to the next
scrim. Now you're going to learn about flex direction because there is one problem
with our lab system now and that is that regardless of how we change around on the align items and justify content.
Let's center and end for example our lab equipment will always stack up besides each other. They'll be on the same row
and there's no way to get them to stack on top of each other. But maybe that's how I prefer to leave my lab equipment
for the night. But regardless of how we change to justify content and align items, that is now impossible. Now we
could of course remove the display flex and then these divs will stack on top of each other by default. So by doing this
now they stack on top of each other. However, justify content and line items no longer work. So if I try changing
these, nothing happens because these properties work inside of a flexbox, not inside of
a random div that by default is display block. So we need the display flex like that in
order to make these work. However, what we can do is change the flex direction. So first let me just both of these two
back to start and then I'll do flex dash direction and it by default is a row because as I
said these stack up alongside of each other on a row but if we change this to column boom there you can see now they
suddenly stack on top of each other as if they are in the same column as columns go from top to bottom. So now we
are back to the original layout we had before we made this into a flex container. But justify content and align
items now work. However, they work in a little bit of a different way than you might expect because as you remember I
previously talked about the main axis going from left to right and being the one controlled by justify content
whereas the crossaxis going from top to bottom and also being controlled by align items. Well, when we change the
flex direction and our items stack up differently on top of each other, we also change the main axis. So, this is
no longer the crossaxis, it is the main axis and it's controlled by justify content. Whereas the horizontal one is
no longer the main, it is the cross and it's controlled by align items. So, we basically flipped align items and
justify content. So if I now do justify content end, they'll jump downwards whereas previously they would have
jumped to the right. And if I now do align items and they'll jump to the right whereas previously align items
control the vertical position. So this is probably a little bit confusing now. You should not feel bad if this feels
overwhelming. This will take time to mature in your mind and it's totally okay that in the beginning now you're
just experimenting with these values in order to get the layout you want and not really remembering exactly why it works
as it works. So let's now give you some practice. I want to clean up my lab equipment and I want it to be like this.
So go ahead and change around on these two values in order to achieve that layout.
Okay. What we need to do is on justify content I want to center it so that it's vertically centered but then we want to
align it to the start on the left hand side. Yes, that is correct. Okay, new one. Achieve this layout.
Okay, here we can see some space in between the items. So I think we need to use space between on justify compent.
Yes, looking good. But we are aligning to the left. We want to align it to the right instead. So align items should
probably be end instead of start. And boom, that is correct. Final layout. This one right here. Give it a shot
right now. Okay, we can see that they are all squeezed towards the top. So I think
we'll do justify content start like that. Yes, this is good. But we want to center it as well. So, we'll do align
items center. And there we go. So, great job doing this. Let's just move on. Okay. Now, we're going to put your
freshly acquired flexbox skills to the test because you are going to turn this layout here into this layout. So first I
want you to wrap the HTML elements in a div with an ID called header. So that is all of these items right here. And then
you are to select this header and then use flexbox to achieve the layout from the design slide. And as you might have
guessed, you will need to use flex direction and align items to solve this. So go ahead and give this your best
shot. Okay. So, we'll start in the HTML. Create that div opening tag and close it
off down here. Indent this, run it. No change seen in the mini browser. That is to be expected because we'll have to
target it and style it. So, I'm going to do header and then first display flex. that forces all of the elements into one
row because it is flex direction row by default. However, we don't want that. We want everything in one column. So, we'll
do flex direction column like that. Now, they stack on top of each other, which is just what we want. But there's a
problem. The two elements here are stretching and the image of Nick is left aligned. It's not centered. So, I think
we need to change the align items. align items into center like that. And there we have the layout we wanted. So great
job. Let's move on. Okay. Now you're going to fix up the design for this 24 years old element and
the date element right here because I want it to look like this. Here you can see that there's some space between the
content of the element and the edge of the element. And there's not as much space between the elements. And also the
edges of the rectangles are a bit softer. But before you start doing this, there's a couple of things I want to do.
Because here the H2 and the H4 have no IDs or classes. They are just selected using the element selector and also
using a selector list separated by commas. And I don't think we should do either of those. First of all, we
probably don't want all of our H2 and H4s on the page to be styled according to how it looks here up in the header.
So, we actually want to give these two ids. I'm going to call this one Bday age and this one Bday date. Running this
code so that we got it applied. And then in the CSS, instead of using element selectors, we'll use ID selectors. Eday
age and e day date. And then finally, let's avoid applying styles to both of these simultaneously. Let's work with
one or the other because this is really an optimization and writing code which is so-called dry, short for don't repeat
yourself. And while that is a good thing, I want you to focus on the core CSS now because this will introduce a
little bit more complexity. So let us instead just keep it simple. So I'll break this into a new line. So, we got
the birthday date rule here and then copy the exact same thing to the bday age like that. Okay, now it's time for
your challenge. You are going to make the bday elements look like the provided design slide like this. So, go ahead and
do this right now. Okay, hopefully that went well. Let's start with the age element. As you can
see, there is some space around it. That is padding most likely. So, let's add padding, for example, 10 pixels, and see
how that works. If we compare that with what we have in the design, it looks pretty good, but I think we shouldn't
have 10 pixels on each side. I think the padding on the left and right side is meant to be slightly larger than the top
and bottom, as we've often seen with buttons and layouts in general. So, for the top and bottom, we'll do 5 pixels
and and left and right 10 pixels. That is what we are looking for as far as I can see. Okay, next up there is some
border radius here as well. Not that easy to see, but it definitely is there. So, we'll do border radius 5 pixels for
example. That looks pretty good to me. And now let's just try to copy this down to our birthday date and see how that
works. Here you can see except for the fact that there's much less space between the elements here. They look
pretty similar as far as I can see. So, we need to move on to the margin. Let's try first and remove all the margin from
the birthday date. Margin zero like that. Now it's quite a lot closer and whatever margin comes from the age two
element and it probably has a bit too much margin bottom. So let's rather control that by doing margin bottom. For
example, 10 pixels and yes that looks pretty good to me. Let's also look at the margin top here. It is too much
space between the age element and the image. So if we do margin top by 10 pixels there, that looks pretty good,
but it's perhaps still a little bit too much. Let's do five instead. Yeah, actually I think we got it. So the final
step then is to convert this into a shorthand because we know how to use short hands, don't we? We want five on
the top and 10 at the bottom. Then we'll do margin 5 px for the top, zero for the right hand side, 10 px for the bottom,
and zero for the left hand side. And there we go. Now, if your solution is slightly different from mine, perhaps
you used slightly different margins, border radius, padding, that doesn't really matter. Give yourself a pat on
the back regardless of how you solve this and let's move on. Okay. Now, you are going to create the
first gift section of our site. So, as you can see, it contains a title, a little hint about hovering over the
gift, and then there's the image itself. Now, the hover effect is not a part of this challenge. You're only going to
work with this hard-coded gift cover at this point. And that gift cover has been added up here in a images folder, which
I've just created. As we now have two images, so I wanted to gather them together in this images folder. That
means that I've also changed the image of Nick or the source that is referring to the image of Nick in the HTML. It now
contains the correct path into the images folder. So, the challenge is described in detail here. I want you to
start by creating a gift section div that will wrap all of the elements for the first gift. And then I want you to
add the H2, H3, and img elements. So that is the title which is an H2, the hint which is an H3 and finally the
image itself. And I want you to give them all their own classes so that you can use the classes to select the
elements when you are to style them according to the design. And as a final hint, the image should be 400 pixels
wide. So go ahead and do this right now. Okay, hopefully that went well. So I'll start by heading over to the HTML and
create the markup. So we wanted a div to begin with. I'm going to create that and then give it a class of gift section
like that. And inside of it, we wanted first an H2 for the title, which should contain the following text. Let's run
this. And yeah. Ah, nice. We can see that the text already has the correct font and also the slight shadow around
it. Okay, very nice. Let's then give it a class as that was something we should do with all elements.
I'll call this gift a title like that. And there was the H3 with the following text. And I'll give that a class of gift
hint. So you can see I'm using gift and then a description. I think that makes it easy to understand that these are all
somewhat related to each other. Finally, the image element to have a source of images/gift
cover.jpeg and also a class of gift img. All right, let's run this code. And as you can see,
everything is being rendered, though the image is far too large. So we need to get going with the styling. All right,
I'll start with the image. So, dot imgd and give it a width of 400 pixels. Yes, that is much better. And it is
centered because of our text align center up here. Very nice. Okay, let's just carry on with this one. You can see
it has a white border. So, let's do border. Looks to be something like 6 pixels or something. And solid white.
Yep, pretty good. And finally, a border radius because the corners here are a little bit rounded off. So, let's try
border radius at 10 pixels for example. And yeah, that looks pretty much like the design for the image. Nice. Okay,
next up is the spacing. As you can see, we have far too little space from the gift section itself to the header
section above. And I could add that to the top element here to the title for example, but it makes a lot more sense
to add it to the container element itself because it should control how far it is between this container and the
container above. So let's do div section margin top and for example 50 pixels. That is much better and looks pretty
much like what we have here. Now you can see that the space between the title and the hint is very limited. It's not that
much space. Whereas here the default margins for the H2 and H3 elements create quite a lot of space in between
them. So now we probably have to work with both the default margin that the H2 has at its bottom and the default margin
which the H3 has at its top. It doesn't really matter what we start with. Let's for example just start with the gift
hint and see what happens if we set the margin top. Actually let's bring it up on the side here. Now we've not done
anything with the margin top at all. Let's set it to zero. You can see, hm, nothing happened. Okay, that must be
because the margin top here and the margin bottom under the H2 collapsed into each other. And the margin bottom
for the H2 was probably larger than the margin top for the H3. So removing it served no purpose. That means that we
also need to try and remove the gift titles margin at its bottom. Set it to zero, for example. And there we go. Now
they're really crammed into each other. Actually too much. They should have a little bit of spacing in between them.
So let's try to instead of reducing that to zero, we would set it to, for example, 10 pixels. That looks much more
like the design we have here. Very good. So you probably had different names on your classes and different margins and
perhaps different borders and radiuses. That doesn't matter. The important thing is that you gave it a shot and got some
kind of result hopefully resembling this. So, no matter what you did, great job. Let's carry on with this course.
Okay. Now, we're going to prepare our project so that we later can add the hover feature. So, we're not going to
add the hover feature right now. We're just going to set the stage for it. And in order to do that, I'm going to first
mess up this project a little bit and then it'll be your job to fix it because we are not going to use the image tag
here in order to display this gift. Instead, we are going to use a div tag. So, I'm changing this into a div, which
means I also need to close it like that because divs are not self-closing as img tags are. And then next up, divs don't
have a source attribute. So we can't use this in order to display the image. If I now run this, you can see boom, suddenly
our image is gone. This src attribute has no place here because instead we are going to render this image through the
CSS background image property. So I'm going to remove this one. If we run the code again, you can see nothing else has
happened. And moving over to the CSS, now it is your job to turn this weird line here into something that looks like
this, which is exactly what we had before. I messed up the code here. So, you are to fix the gift img div because
I kept the class right here so that it looks like the provided design. And a little bit of a hint, it
needs a height. And if you wonder how much, I want it to be a square, so equal width and height. It also needs a
background image, which is how you'll render this gift cover. It also should be centered again because as you can see
here, this looks very much left aligned. So basically what's happened here is that the div has zero height because the
div has no content inside of it. So the only thing that's visible is the border which spans 400 pixels starting from the
left hand side and over towards the right hand side. So go ahead and give this a shot and then I will show you the
solution when you return back to me. Okay, let's do this. First, it needs a height, and it should be a square,
meaning equal width and height. So, let's just do eight and set it to 400 px like that. As you can see, we now have a
empty div on our page. Next up, we're going to set the background image. So, how do we do that? Well, you've seen
that one before. Background image URL and then point it to the images folder and the gift cover. Ape. And there you
go. But what is happening here? It seems like we only kind of see the top left corner of the image. That is because the
image itself is huge, much larger than this 400x 400 pixel container. So, we need to use our good old trend
background size and set that to cover. And that squeezes our large image into the current width we have available
here. Now, finally, why isn't this element centered anymore? Well, the centering of the image used to happen
because the text align is set to center. But text align will only center inline elements inside of its container. And as
you hopefully remember divs, they are not in line. They are display block. And and you might have tried to do display
inline like that. Then you can see that doesn't really work. Then our width property and height property gets this
weird underline underneath them because they are simply ignored by CSS because you can't force the width and height of
an inline element as they should only be as large as the content inside of them are. And this div doesn't have any
content. So we can't really use display inline. What we rather can use is the margin technique you learned earlier.
the one where you set the left and right margin to auto because that works on elements that are display block and
which have a set width. So let's do margin zero on the top and bottom and auto on the left and right. And there we
go. We have it centered. We are back to our original design and we've set the stage for our hover effect which Nick is
going to be so glad to experience. So, it's really cool that you've made it this far and let's just keep up the pace
and move on to the next scrim. Hey there, it's Bob Zroll again and I'm coming to you now with a quick update to
the lesson that used to be here. We're going to have a quick aside to learn about the hover pseudo class. To see
this, we're just going to use this simple little app that we have here where we have a restaurant menu. And the
user should be, of course, able to click on any of these, which would theoretically take you to a different
page. In the HTML, you can see we have this semantic nav element, which indicates that it will be a section of
navigation. And we kept it simple here with three anchor tags to link to other parts of our site. Now, currently, these
are just going to this hash mark, which is sort of a placeholder. It won't actually direct us anywhere different.
We can head over to the CSS and we can see there's just a few rules here to make these anchors look a little bit
more like buttons. We have the text aligned to the center. The color of the font is white. There's some margin to
separate it from other elements and some padding inside. The background is the red color that you see. We've increased
the font size. And because anchor elements are typically display inline, we changed that to block and then got
rid of the underline by using text decoration none. And that's referring to the underline that is typically there
when you have a link. Now, what would be really nice with this menu is if we gave some kind of visual feedback to the user
when they were hovering over the different menu items here. I'm sure you're not a stranger to this concept.
It's something that many websites do when you're hovering over the navigation. There's some kind of hover
effect that happens. And we can target our CSS specifically to an element that is currently being hovered by using the
hover pseudo class. The way we can do this is by selecting our anchor just like we did up above, but this time
putting a colon hover. This way any CSS properties that we include here will only be applied when the element is
currently being hovered. Or in other words, whenever the mouse has entered the perimeter of that element. So for
example, one thing we could do is when the element is being hovered, we could change the background color to this
hexodimal value here, which is a little bit cryptic. doesn't really tell you much about it, but just know that it's a
slightly darker shade of the red background that we have when the item is not being hovered. And you can see that
just by putting my mouse inside the perimeter of that element, we get our hover styles or this change in
background color applied and it's a much more interactive experience. So, what's happening here is we have added an
additional level of specificity or in other words, we are being more specific about this background color rule than we
were about the background that's up here. And actually maybe just to have an apples to apples, we could change this
to background color. That way we can see that our anchor colon hover is being more specific and therefore this
background color is being applied when we hover. To be clear, this isn't happening because we have written this
below our other anchor. I can move this up above and see that the styles will still apply just like they were before.
But rather it has to do with how specific our rules are and the way CSS is working under the hood, which we
don't have to dive into too deeply at this point. But it's enough to know that CSS is doing the intuitive thing just as
you would expect. Of course, background color is not the only thing that we could change here. We could change the
font size, for example, to let's call it 40 pixels and see that we can make as many different changes as we want. And
now the hovered menu item is really jumping out at you. I think that might be a little bit much. So, I'm going to
get rid of that rule. On that vein of being able to change other properties, one cool trick that we can do, and this
will help us in the challenge that's coming up in the next scrim is we could do something like changing the
background image and we could set this to a URL. We'll use this CSS URL function as you are familiar with and
let's just point it to eyes.jpg which we have inside of our files up here. All right, let's see what happens.
I'm going to go to my menu and we'll see that we get our friend Nick's eyes kind of creepily looking at us through the
background of these menu items. Again, this is a little creepy and probably the strangest menu items you've ever seen on
a website, but hopefully this is a perfect primer for the challenge that's coming up on our birthday gift site as
we are just about ready to help Nick unwrap his birthday presents. So, that's what we'll be jumping into next.
Okay, now we are getting into the fun stuff here because now we're going to create this epic feature where Nick when
he hovers over the gift paper gets revealed an underlying gift that makes him feel happy and appreciated on his
birthday. So the challenge is described here. You are to swap the gift paper image out with the happy gift when you
hover over the gift paper. So the happy gift is added here in the images folder. I'm not going to show it to you. I want
you to solve this challenge in order to see this gift. Now, the gift paper image you are to swap out is this div right
here. As you remember, we gave it a background image, which is the gift cover.jpeg file, which also is in our
images folder. So, go ahead and solve this challenge right now, and then I will show you the solution when you
return back to me. Okay, hopefully that went well. What we'll do is first target this gift img
here as we want to create a hover effect on it. So I'll do gift img colon hover. Now whatever CSS properties and values
we are setting inside of these curly brackets will be applied when the user hovers over this gift image. And what
kind of properties do we want to change? Well, it's actually only one, just the background image here. So, I'm going to
copy that one, paste it in, and we don't want it to be the gift cover.jpeg. We want it to be the happy.gif.
Like that. Let's see how this works. I'll move the cursor down towards the image. And when it crosses over, we see
Phoebe and Rachel from Friends being super happy for Nick on his birthday. And I don't know about you, but if
someone told me that they would be this happy for me on my birthday, it would make me feel so grateful and
appreciated. So, we are really doing a good deed creating this website. And you know what? You've done a great deed for
yourself in terms of getting this far in the course. You have crushed through so many difficult CSS concepts. So, Phoebe
and Rachel are also cheering for you. Take a moment to appreciate that and then I will see you again in the next
scrim. Okay, now that we've made sure that Nick feels appreciated on his birthday
through this Phoebe and Rachel gift, let's make sure he also feels really good-looking because now we're going to
create this gift right here, which says how people react when you enter the room. And the GIF will show when he
hovers over this element is this hot GIF up here. I'm not going to show it to you now. You're going to have to solve the
challenge to see it. And speaking of that, let's have a look at the challenge text. So you are to create the next gift
which uses the hot GIF and its HTML structure should be like the previous one but without the gift hint element
because as you can see here we have this hint written in parenthesis. However, that's not needed for this one. I think
Nick will probably get the point by the time he scroll down to this one. So let's just skip it. But other than that
you can simply copy paste this section and then of course change the text as well. However, you will need to do some
more things as well because now that you have multiple gifts on the page, you cannot use the gift image class to set
the background image on hover. That is this one right here. Because if you have multiple gift image elements on the
page, well then every single one of them will just show this happy gift. And that's obviously not what we want. So
instead, each of the gifts will need a unique ID that controls which background image that should be shown when the user
hovers over the element. Okay, that was probably a lot to parse for you. But if you didn't quite catch it, just go ahead
and try to solve the challenge because I think you will see this problem sooner or later anyway. You definitely will,
actually. So make it your best shot and then of course I will show you the solution when you return back to me.
Okay, let's do this. So, starting in the HTML by simply copying this one right here and pasting it in down here,
removing the gift hint because we don't need that. And then updating the title. Let's run the code now. And here we can
see the first element with Phoebe and Rachel. Let's scroll a bit down. And there we have our second element, though
it still shows Phoebe and Rachel. So that is a problem and that is because as I said this gift image class just sets
the background image on hover to the happy gift on both of these elements right now. So we can't use a class for
this. We need a unique ID. But we're not going to remove the class of gift img because it actually gives a lot of
styling actually all the styling to the element. So it's only the hover pseudo class that needs to be applied to
something else. So let's instead now on the first one here add an ID that we'll call gif- img-happy.
We'll run the code so that it's applied and then instead of referring to the generic class here refer to this gift
img happy ID. Now, if we run the code, you can see that it works on the first gift, though the second gift now lacks a
hover effect. And that is because the only hover effect we've applied now is on this specific ID here on the first
gift. Previously, we used the generic gift img class. So, it was applied to all gift images, but now the hover only
works on the first one. So, what we need to do is use this exact technique, but on this section as well. So I'll create
an ID on this section and call it gift bash img bash hot. I'll run the code so that it's applied.
And then since I'm lazy, I'll copy this. Gift img happy should be changed to gift img hot because that is our new ID that
targets that element. And we don't want to show the happy gift. We want to show the hot gift. So let's see if this
works. Here we are at the section. When we hover over the image, we see someone looking pretty interested in Nick. So, I
think he will feel really goodlooking and hot on his birthday when he sees this gift. So, great job solving this
challenge. Let's move on. As you can see over in the file system, I've added a genius GIF and a badass
GIF. So, your job is now to create the genius and badass gift sections. They should look exactly as the hot section.
So, I'm not going to give you any more instructions other than giving you the titles so that you can just copy them
from here instead of writing them out on your own. So, go ahead and create these two sections right now and then I will
show you the solution when you return back to me. Good luck. Okay, let's do this. So, I'm going to
start in the HTML file because we're simply going to copy paste this one two times.
Then I'm going to add the titles. I'll copy this one and paste it in here. And copy this one and paste it in here.
Okay, let's run this now. You can see we have the hot gif and then the genius section which still has
the hot gif underneath it. That's to be expected. And there we have the badass section which also still has the same
GIF. So now we have the sections rendered on the page at least. But we need to fix up the CSS. So lazy as I am,
I'll copy this one here. It says gift image hot. The first one will be the genius one. I'll do genius instead. That
should refer to the genius gif. Now that we have this in place, we can just give this class to the respective image like
that. Running the code. And we have the happy gif, we have the hot gif, and then the genius gift. That is pretty cool. I
surely think Nick will appreciate this compliment. Okay, the final one here. The keyword is badass. So I'll change
the ID to badass now that we are in the HTML and moving on to the CSS. Copy this and
change from genius to badass because that's the ID we just created. And the GIF we want to fetch out from our images
