HTML & CSS Basics to Pro


HTML & CSS Basics to Pro

Michael
Alright Maria, today we're diving into a complete HTML and CSS course that takes you from absolute beginner to building something like YouTube. No prior coding needed—it's designed as a first step into software engineering.

Maria
Sounds perfect. So where do we start? The course says we need two pieces of software: a browser and a code editor.

Michael
Exactly. Google Chrome is the go‑to browser for web development, and VS Code, or Visual Studio Code, is the most popular code editor. You just download and install both, then create a folder for your project.

Maria
Got it. And once we have that, we jump straight into HTML. The course defines HTML as Hypertext Markup Language—basically giving instructions to a computer to create a webpage.

Michael
Right. The simplest instruction is a button element. You write <button>Hello</button>, save it as a .html file, then open it in Chrome. Boom, you have a button on your page. HTML is just a list of instructions the computer follows top to bottom.

Maria
I like that. And they also introduce paragraphs with <p> tags. The key is syntax: every element has an opening tag, content, and a closing tag with a slash. If you mess up the syntax—like forgetting a > —the button disappears.

Michael
Yep. And you can add attributes to modify elements. For a link, you use an anchor tag <a> with an href attribute pointing to the URL. You can also add a target attribute to open in a new tab. Attributes are always name=value pairs inside the opening tag.

Maria
There's also a quirk: multiple spaces and new lines in HTML are collapsed into a single space. That actually makes code formatting flexible—you can indent and add line breaks to keep things readable without affecting the page.

Michael
Then we move into CSS. The course uses a project copying buttons from YouTube and Twitter. CSS is about styling HTML elements. You need a <style> element, and inside you write a selector (like button) followed by curly braces with property: value pairs.

Maria
For the subscribe button they set background‑color to red, color to white, border to none. Then they adjust height, width, and use a color picker to get the exact red using RGB values. RGB is just red, green, blue—each from 0 to 255.

Michael
And to target only the subscribe button, they use a class attribute. In CSS, a dot before the class name selects that specific element. That way the join button can have different styles.

Maria
Once you have the basic styles, they add interactions: hover effects using the :hover pseudo‑class, and active effects with :active. For the subscribe button, hovering reduces opacity to 0.8, and clicking makes it even lighter.

Michael
Transitions smooth those changes. You add a transition property to the base style, specifying which property to transition and the duration—like transition: opacity 0.15s. If you put transition on the hover instead, it won't transition back when you unhover.

Maria
Shadows are another nice touch. The box‑shadow property takes horizontal offset, vertical offset, blur, and color. For a natural shadow, use RGBA with a low alpha value—like 0.15—so it's subtle.

Michael
And for perfect colors, the Chrome DevTools are a lifesaver. Right‑click, inspect, then click the pointer icon to select an element. You can see all its computed styles, copy the exact hex or RGB value, and paste it into your code.

Maria
The course also covers the box model: margin is space outside an element, padding is space inside. Instead of setting fixed height and width, use padding so the element grows with its content. They demonstrate this with the join button—adding padding‑top, padding‑bottom, etc.

Michael
And vertical‑align: top keeps inline‑block elements aligned at the top. But later they move to grid and flexbox for better layout control.

Maria
Before that, there's a whole lesson on styling text. Font‑family, font‑size, font‑weight, line‑height, text‑align—all the basics. They even load Google Fonts like Roboto by adding a link in the <head>.

Michael
And to style only part of a text, you use a <span> element. You can give it a class and apply CSS, like making it red or underlined on hover. That's how the Apple‑style text with a hover underline works.

Maria
Now for layout: the proper HTML structure is <!DOCTYPE html>, <html>, <head>, and <body>. The <head> contains meta info and CSS links; the <body> has everything visible. They also show how to link an external CSS file using <link rel='stylesheet' href='...'>.

Michael
Then comes the display property. Block elements (like <p>) take the full line; inline‑block (like <img>) only take needed space; and inline (like <strong>) stay within a line. You can change display with CSS to control whether elements stack or sit side by side.

Maria
The most important element is the <div>. It's just a box container. By nesting divs, you create complex layouts. The nested layouts technique breaks any design into vertical and horizontal layouts. For the YouTube video preview, they use a vertical layout for the thumbnail and text, then a horizontal layout for the channel picture and info.

Michael
They first used display: inline‑block for horizontal layouts, but it has alignment issues due to whitespace. CSS Grid solves that. You set display: grid on the container and define columns with grid‑template‑columns. Values can be px or fr (fraction of remaining space).

Maria
For the video grid, they used three columns of 1fr each, plus column‑gap and row‑gap for spacing. That's how the homepage gets three videos per row.

Michael
Flexbox is another layout tool, great for flexible content. You set display: flex on a container. The flex‑direction can be row (horizontal) or column (vertical). Properties like justify‑content (horizontal alignment) and align‑items (vertical alignment) position items. And flex: 1 makes an element grow to fill remaining space.

Maria
They used flexbox for the header: left section (fixed width), middle section (flex: 1 with max‑width), and right section (fixed width). Justify‑content: space‑between spreads them out. And to prevent shrinking on small screens, they added flex‑shrink: 0 to the right section.

Michael
CSS position adds another dimension. Position: fixed sticks an element to the viewport—like the header staying at top while scrolling. You use top, left, right, bottom to position it. For the header, they set top: 0, left: 0, right: 0, and a fixed height.

Maria
Then you need to offset content so it's not hidden under the fixed header—add padding‑top to the body. The sidebar uses position: fixed with left: 0, top: 55px (header height), bottom: 0, and a fixed width.

Michael
Position: absolute is similar but relative to the nearest positioned ancestor (not the viewport). When you put an absolute element inside a relative one, you can place it precisely—like the video time in the bottom‑right corner of the thumbnail. The key is setting the parent to position: relative.

Maria
They also created a tooltip for buttons using that technique. The tooltip is inside the button, set to position: absolute, with opacity: 0 by default. On hover (button:hover .tooltip), opacity becomes 1, and a transition smooths it in. They added pointer‑events: none so hovering the tooltip doesn't trigger the button's hover again.

Michael
For the final project, they built the entire YouTube clone step by step: the header with search bar and icons, the sidebar with navigation links, the video grid with thumbnails and text. They even added a notification badge using position: absolute with negative offsets to place it outside the icon.

Maria
And they covered responsive design with media queries. @media (max-width: 750px) changes the video grid to 2 columns, and @media (min-width: 1000px) makes it 4 columns. That way the layout adapts to any screen size.

Michael
They also touched on shorthand properties like padding, margin, and border, inheritance (text properties often pass down), semantic elements like <header>, <nav>, <main>, and comments in HTML (<!-- -->) and CSS (/* */).

Maria
The final advice: Google is your friend. If you need a specific CSS property, just search for it. And the next step after HTML/CSS is JavaScript to make pages interactive. The course offers a follow‑up JavaScript course.

Michael
That's a solid foundation. We've covered everything from the first HTML tag to a full responsive layout. Thanks for walking through it with me, Maria.

Maria
Always a pleasure, Michael. Now let's go practice!

Ask anything
We've read this whole study set, so questions about it get the best answers.