HTML & CSS for Absolute Beginners: Nesting HTML elements

Kevin Powell · Beginner ·🌐 Frontend Engineering ·1y ago
Skills: HTML & CSS90%

Key Takeaways

The video covers the basics of HTML and CSS, specifically focusing on nesting HTML elements, indentation, and organization of code using VS Code.

Full Transcript

now before we start learning about new HTML elements I want to talk a little bit about nesting which is a really important topic with how we write our HTML and just how things work within HTML and we already have some nesting going on that we just didn't know about but as an example of nesting first of all I have my HTML element and then this head is inside of my HTML element so we would say that the head is nested inside of the HTML element then I have my title and my title is nested inside of the head right here and with nesting we also highlight this show it through the indentation that's going on right here so you can see I have my HTML then when we're one level nested we have this space that's coming and the head is right there and then we get to the title and we're going another space over to show just visually it makes it a lot easier to see when things are inside of other things and there's a few important things that happen when we are nesting things and to sort of highlight that idea I'm going to come in with a really simple example at the bottom of my page or simple I should say silly example at the bottom of my page here using fake Elements which are if we had a BLT sandwich and so if we were doing a BLT sandwich we'd have our bread and then inside of our bread we have our bacon our lettuce and our tomato with nesting and with what we're doing here the one thing that's important is not only are we nesting our elements so my bacon is inside of my bread but it wouldn't make any sense for my lettuce to be inside of my bacon right so this this doesn't make any sense right now and there are times where we have other elements nested in inside of other elements we're going to have deep nesting but when it comes to our content like we've been doing so far with say our paragraphs and our heading levels we can't start our paragraph here if our H2 isn't closed right so if I were to take my H2 and like say all of my paragraphs here are in my heading just logically that doesn't make very much sense and so we won't Nest something like that so it's really important that we open and close our elements before we bring in the next element that we want and again sometimes we're going to be making boxes around things to organize things so then we want them you know you have a whole bunch of stuff sort of like I did here with my bread I'm putting a whole bunch of things in my bread in that context it makes sense so you do need to think about what the elements are and how they're being used it's all very logical it makes sense so don't worry too much about that side of things the other thing that's really important here and something I want you to practice a little bit with your editor is when we're writing our code vs code helps us out through what we call indentation and that's that spacing that I was talking about along the way here and you can see when I'm highlighting that you'll see you getting two dots showing up within that highlight and then I have four dots here and that's because VSS codes actually adding spaces if you highlight an empty space or if you make a whole bunch of empty spaces and you highlight it you'll see those empty spaces appearing there and what I mean by that is let's say I delete all of this and so we have our doc type that we don't want to forget so doc type HTML at the top of the page and then if I came here and I do HTML when I push return on my keyboard now you'll notice that vs code is automatic ially indenting that inside of here I didn't do that it's going well I know that you're inside of another element so I'm going to put this indentation for you and then we can put my head and then if I go inside my head when I push return we get the indentation that happens and I can do my title right there and so you know another another website what's going to happen though sometimes when you're doing this is let's say I come on and I do my body and then maybe I forget to push return so I come in with my H1 and I say uh my site whatever it doesn't really matter too much on the content but I do this and first of all this is harder to read now because I have my body than my H1 it's just a little bit awkward if you don't have a lot of code it's not the end of the world I guess but it it will get harder and harder to read and HTML you tend to have a lot of it so it's really important that we organize it properly so I would come here and make sure that you know I push enter so it's doing the proper job of of nesting it and vs code is going to try and do this automatically and it's going to add this indentation all by itself but sometimes you might do something and it doesn't end up working the way you wanted it to or you paste in some code and the indentation of things might be a little bit broken or not working properly and so when you're pasting in things or something like it could you know say this happens when you paste it in h and the indentation is not proper there what you can do is you can go before your text and hit Tab and it's going to start indenta it for you so every time I hit tab it's going to jump it for spaces as a default and if I push back it's actually delet deleting all four of those spaces at once so I'm just pushing my delete button to go back one delete button again to go back one uh to where it was so we can Tab and go back through our tabs really easily and so let's just I'm going to undo all the changes I just did here to go back to what we had previously and so having all of my content here again uh another thing that we can do is you might want to do this with a large amount and you don't want to have to come on one of these and then tab and then tab and then tab if you do need to fix your indentation you can actually grab a a whole bunch of text just select everything you want and then push tab and it's going to move them all over in one go which is really convenient or now if I push delete because I have selected text it deleted everything so it doesn't remove that extra indentation that I wanted to do what we can actually do is a shift Tab and when you shift tab it will indent backwards so tab goes One Way shift tab goes the other way and right now we don't have anything too complicated going on so everything's probably okay but you know you might have a body that's over here for some reason or your body might even be over here here uh cuz for some reason VSS code keeps trying to put my body right there so I'm going to push tab there and I go oh actually my indentation is wrong everywhere so tab then I can grab all of this hit Tab and move all of them over and start cleaning this up a little bit and even on these you know grab all of that tab that over and now everything is good all of this indentation will not change anything in the browser everything here is exactly the same it just makes it a lot easier for us to read while we're looking at our documents especially as we start creating more complicated layouts and getting into more levels of nesting it just makes your life so much easier so from the very beginning make sure you're organizing things properly

Original Description

🎓 Enroll in this course for FREE - get additional lessons, written content, interactive exercises, and more: learn.kevinpowell.co 📂 Get the course files here: https://www.dropbox.com/scl/fo/kusdjekuytcaa3of0vtd4/AChRHcF13pNi93JWusfLW9A?rlkey=tbrbxnabsi52u6onal9rh7fwm&st=iyo2wujq&dl=0 Learn to build websites from scratch - even if you've never written a line of code before. This hands-on course teaches you the fundamentals of HTML and CSS, the building blocks of the web. You'll start with the basics and progress step-by-step to creating your own responsive websites. Perfect for complete beginners who want to start their web development journey. #css -- Come hang out with other dev's in my Discord Community 💬 https://discord.gg/nTYCvrK Keep up to date with everything I'm up to ✉ https://www.kevinpowell.co/newsletter Come hang out with me live every Monday on Twitch! 📺 https://www.twitch.tv/kevinpowellcss --- Help support my channel 👨‍🎓 Get a course: https://www.kevinpowell.co/courses 👕 Buy a shirt: https://teespring.com/stores/making-the-internet-awesome 📽️ Join as a channel member: https://youtube.com/@KevinPowell/join 💖 Support me on Patreon: https://www.patreon.com/kevinpowell or through YT memberships: Join this channel to get access to perks: https://www.youtube.com/channel/UCJZv4d5rbIKd4QHMPkcABCw/join --- My editor: VS Code - https://code.visualstudio.com/ --- I'm on some other places on the internet too! If you'd like a behind the scenes and previews of what's coming up on my YouTube channel, make sure to follow me on Instagram and Twitter. Bluesky: https://bsky.app/profile/kevinpowell.co Codepen: https://codepen.io/kevinpowell/ Github: https://github.com/kevin-powell --- And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Kevin Powell · Kevin Powell · 0 of 60

← Previous Next →
1 How to create an awesome navigation bar with HTML & CSS
How to create an awesome navigation bar with HTML & CSS
Kevin Powell
2 Improve your CSS by Keepin' it DRY
Improve your CSS by Keepin' it DRY
Kevin Powell
3 HTML & CSS for Beginners Part 6: Images
HTML & CSS for Beginners Part 6: Images
Kevin Powell
4 HTML & CSS for Beginners Part 7: File Structure
HTML & CSS for Beginners Part 7: File Structure
Kevin Powell
5 HTML & CSS for Beginners Part 4: Bold and Italic text and HTML comments
HTML & CSS for Beginners Part 4: Bold and Italic text and HTML comments
Kevin Powell
6 HTML & CSS for Beginners Part 5: Links
HTML & CSS for Beginners Part 5: Links
Kevin Powell
7 HTML & CSS for Beginners Part 3: Paragraphs and Headings
HTML & CSS for Beginners Part 3: Paragraphs and Headings
Kevin Powell
8 HTML and CSS for Beginners Part 1: Introduction to HTML
HTML and CSS for Beginners Part 1: Introduction to HTML
Kevin Powell
9 HTML and CSS for Beginners Part 2: Building your first web page!
HTML and CSS for Beginners Part 2: Building your first web page!
Kevin Powell
10 HTML & CSS for Beginner Part 8: Introduction to CSS
HTML & CSS for Beginner Part 8: Introduction to CSS
Kevin Powell
11 HTML & CSS for Beginners Part 9: External CSS
HTML & CSS for Beginners Part 9: External CSS
Kevin Powell
12 HTML & CSS for Beginners Part 10: Divs & Spans
HTML & CSS for Beginners Part 10: Divs & Spans
Kevin Powell
13 HTML & CSS for Beginners Part 11: Classes & IDs
HTML & CSS for Beginners Part 11: Classes & IDs
Kevin Powell
14 HTML & CSS for Beginners Part 12: The CSS Box Model - Margin, Borders & Padding explained
HTML & CSS for Beginners Part 12: The CSS Box Model - Margin, Borders & Padding explained
Kevin Powell
15 HTML & CSS for Beginners Part 13: Background Images
HTML & CSS for Beginners Part 13: Background Images
Kevin Powell
16 HTML & CSS for Beginners Part 14: Style Text with CSS
HTML & CSS for Beginners Part 14: Style Text with CSS
Kevin Powell
17 HTML & CSS for Beginners Part 15: How to style links
HTML & CSS for Beginners Part 15: How to style links
Kevin Powell
18 HTML & CSS for Beginners Part 16: CSS selectors and Specificity
HTML & CSS for Beginners Part 16: CSS selectors and Specificity
Kevin Powell
19 HTML & CSS for Beginners Part 17: How to Create and Style HTML Lists
HTML & CSS for Beginners Part 17: How to Create and Style HTML Lists
Kevin Powell
20 HTML & CSS for Beginners Part 18: How Floats and Clears work
HTML & CSS for Beginners Part 18: How Floats and Clears work
Kevin Powell
21 HTML & CSS for Beginners Part 19: Colors with CSS - hex, rgba, and hsla
HTML & CSS for Beginners Part 19: Colors with CSS - hex, rgba, and hsla
Kevin Powell
22 HTML & CSS for Beginners Part 20: How to center a div
HTML & CSS for Beginners Part 20: How to center a div
Kevin Powell
23 HTML & CSS for Beginners Part 21: How to create a basic website layout - the HTML
HTML & CSS for Beginners Part 21: How to create a basic website layout - the HTML
Kevin Powell
24 HTML & CSS for Beginners Part 22: How to create a basic layout - the CSS
HTML & CSS for Beginners Part 22: How to create a basic layout - the CSS
Kevin Powell
25 How to Create a Responsive Website from Scratch - Part 1: The HTML #Responsive #HTML5
How to Create a Responsive Website from Scratch - Part 1: The HTML #Responsive #HTML5
Kevin Powell
26 How to Create a Responsive Website from Scratch - Part 2: The Header and Hero area #Responsive #CSS3
How to Create a Responsive Website from Scratch - Part 2: The Header and Hero area #Responsive #CSS3
Kevin Powell
27 How to Create a Responsive Website from Scratch - Part 3: The About Section #Responsive #CSS
How to Create a Responsive Website from Scratch - Part 3: The About Section #Responsive #CSS
Kevin Powell
28 How to Create a Responsive Website from Scratch - Part 4: Building a Responsive Portfolio Section
How to Create a Responsive Website from Scratch - Part 4: Building a Responsive Portfolio Section
Kevin Powell
29 How to Create a Responsive Website from Scratch - Part 5: Call To Action and Footer #CSS #Responsive
How to Create a Responsive Website from Scratch - Part 5: Call To Action and Footer #CSS #Responsive
Kevin Powell
30 Tutorial: Learn how to use CSS Media Queries in less than 5 minutes
Tutorial: Learn how to use CSS Media Queries in less than 5 minutes
Kevin Powell
31 End of the year upate and what's coming to my channel to start the new year
End of the year upate and what's coming to my channel to start the new year
Kevin Powell
32 Create a CSS only Mega Dropdown Menu
Create a CSS only Mega Dropdown Menu
Kevin Powell
33 CSS Tutorial: Outline and Outline Offset
CSS Tutorial: Outline and Outline Offset
Kevin Powell
34 CSS Blending Modes
CSS Blending Modes
Kevin Powell
35 Parallax effect | 2 different ways to add it with jQuery
Parallax effect | 2 different ways to add it with jQuery
Kevin Powell
36 CSS Units: vh, vw, vmin, vmax #css #responsive #design
CSS Units: vh, vw, vmin, vmax #css #responsive #design
Kevin Powell
37 How to Create a Website - Complete workflow | Part 01: Intro + Setting things up
How to Create a Website - Complete workflow | Part 01: Intro + Setting things up
Kevin Powell
38 100 Subscribers speed coding bonus video
100 Subscribers speed coding bonus video
Kevin Powell
39 How to Create a Website - Complete workflow | Part 02: The Markup #HTML
How to Create a Website - Complete workflow | Part 02: The Markup #HTML
Kevin Powell
40 How to Create a Website - Complete workflow | Part 03: Sass Variables and a Mixin #Sass
How to Create a Website - Complete workflow | Part 03: Sass Variables and a Mixin #Sass
Kevin Powell
41 How to Create a Website - Complete workflow | Part 04: Setting up the hero and header
How to Create a Website - Complete workflow | Part 04: Setting up the hero and header
Kevin Powell
42 How to Create a Website - Complete workflow | Part 05: Typography & Buttons
How to Create a Website - Complete workflow | Part 05: Typography & Buttons
Kevin Powell
43 How to Create a Website - Complete workflow | Part 06.1: Building the navigation with Flexbox
How to Create a Website - Complete workflow | Part 06.1: Building the navigation with Flexbox
Kevin Powell
44 How to Create a Website - Complete workflow | Part 06.2: Making the nav work with jQuery
How to Create a Website - Complete workflow | Part 06.2: Making the nav work with jQuery
Kevin Powell
45 Redesigning & Coding My Website #CreateICG
Redesigning & Coding My Website #CreateICG
Kevin Powell
46 How to Create a Website - Complete workflow | Part 07: Starting the flexbox grid
How to Create a Website - Complete workflow | Part 07: Starting the flexbox grid
Kevin Powell
47 How to Create a Website - Complete workflow | Part 08: Promo & Problem shooting!
How to Create a Website - Complete workflow | Part 08: Promo & Problem shooting!
Kevin Powell
48 How to Create a Website - Complete workflow | Part 09: The CTA and Footer
How to Create a Website - Complete workflow | Part 09: The CTA and Footer
Kevin Powell
49 How to Create a Website - Complete workflow | Part 10: Making it responsive
How to Create a Website - Complete workflow | Part 10: Making it responsive
Kevin Powell
50 How to Create a Website - Complete workflow | Part 11: Making it responsive con't
How to Create a Website - Complete workflow | Part 11: Making it responsive con't
Kevin Powell
51 How to Create a Website - Complete workflow | Part 12: Putting the site online
How to Create a Website - Complete workflow | Part 12: Putting the site online
Kevin Powell
52 Create a Custom Grid System with CSS Calc() and Sass
Create a Custom Grid System with CSS Calc() and Sass
Kevin Powell
53 CSS em and rem explained #CSS #responsive
CSS em and rem explained #CSS #responsive
Kevin Powell
54 Should you use Bootstrap?
Should you use Bootstrap?
Kevin Powell
55 How to add Smooth Scrolling to your one page website with jQuery
How to add Smooth Scrolling to your one page website with jQuery
Kevin Powell
56 Let's learn Bootstrap 4
Let's learn Bootstrap 4
Kevin Powell
57 How I approach designing a website - my thought process
How I approach designing a website - my thought process
Kevin Powell
58 Build a website with Bootstrap 4 - Part 1: The setup
Build a website with Bootstrap 4 - Part 1: The setup
Kevin Powell
59 Build a website with Bootstrap 4 - Introduction
Build a website with Bootstrap 4 - Introduction
Kevin Powell
60 Build a website with Bootstrap 4 - Part 2:  Customizing Variables
Build a website with Bootstrap 4 - Part 2: Customizing Variables
Kevin Powell

This video teaches the importance of nesting HTML elements and organizing code using indentation in VS Code, making it easier to read and maintain web development projects.

Key Takeaways
  1. Understand the concept of nesting in HTML
  2. Use indentation to organize code
  3. Practice using VS Code for indentation and code organization
  4. Apply nesting and indentation to HTML elements
  5. Use tab and shift-tab to adjust indentation
💡 Proper indentation and organization of code is crucial for maintaining readability and simplicity in web development projects, especially as they become more complex.

Related Reads

Up next
How to Speed Up Your WordPress Website with WP Rocket ⚡Tutorial 2026
Matt Tutorials
Watch →