02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

HTML5 Structure Example

Examples of usage of changes to structure in html5. In this video we continue the last few videos where we take a deeper look at changes form html4 to html5.

Video Transcript

00:00All right, so let's just look at,
00:03let's just see this in action.
00:04Obviously we talked about all the different things
00:07that were removed.
00:07So I'm just gonna look really quickly into,
00:10I have a little file here called index.html,
00:14which you could find in the source files.
00:16And let me just open that up in a browser,
00:18see if I could find it.
00:20Here we go.
00:21So it was a website that I created
00:22that never really went live.
00:23So there's a lot of text here
00:25and I might push it live at some point.
00:27So let's try to see thematically,
00:29we could figure out what type of things can we put in here.
00:31So first of all, we have a footer.
00:33Footer is a good place to start from.
00:35So let's add our footer
00:36and basically just mark our application to have a footer.
00:38So if I go into the source files,
00:40I could just go into my HTML,
00:42browse all the way to the bottom here,
00:44figure out what my footer is.
00:46And you could see that originally
00:48I created my footer this way.
00:49So I already set myself a div
00:51and I called my div footer
00:53and I set myself up that way.
00:55What I could do now is just go into my div,
00:57change it to be called footer,
01:01change my div to be called footer.
01:03Now, obviously my application is not going to work anymore
01:05because it was expecting to find
01:07that attribute in the bottom.
01:09So everything here is messed up.
01:10So what I have to do is I have to go in
01:12and fix all the places where I actually used
01:16the dot attribute.
01:17But if I wanted to,
01:18I could have even not done it this way.
01:20Let me first do it the kind of easy way.
01:23I could just wrap everything up with a footer attribute
01:26basically.
01:28And then I wouldn't have any issues.
01:29I probably could run it
01:30and I'd be able to see my footer just the way it was.
01:33But if I wanted to,
01:34and I wanted to be more pedantic,
01:35I could have gone and obviously then tweak my CSS
01:38and made sure that my CSS references were still correct.
01:41So if I'm just going to delete that, delete that.
01:43And I'm going to go to that side.
01:45I'm going to just grab the CSS,
01:47which is right here in my style.
01:48I'm just going to open it up in our editor
01:50and I'm just going to find my footer related thing.
01:53So I'm going to just,
01:54I just click on search to find my footer.
01:56And here I could see that I'm using the hash sign footer,
01:59which basically was my ID.
02:01So I could probably just go over all this hashtag footer.
02:05And let me just put that right there
02:07and just change that from hashtag to just a footer.
02:10And I'm going to replace all and save that.
02:15And let's try our browser again
02:16and see if our footer is now working.
02:18Done.
02:20We completed our task exactly the way we wanted it
02:22to be completed.
02:23And that's basically the idea of the visual elements.
02:27Even if I was running in a browser
02:28that didn't technically support that element,
02:31browsers don't ignore elements.
02:32If they had a CSS attribute that was usable,
02:35I could have used it.
02:36I want to show you an example of that
02:37because that's actually a really important differentiation
02:39or important note to put.
02:41So even if I put here an attribute
02:42that completely doesn't exist.
02:44So let's call it a me32.
02:46Me32 absolutely does not exist.
02:48There's no such thing as me32.
02:50If I refresh my screen,
02:52I could see obviously my me32 is not working anymore.
02:55But if I go into my CSS and I find every place
02:58I have footer and I change it to me32,
03:02so hopefully we'll have only 10 of them
03:04and there was, yep, just 10 of them.
03:06If I save that and I go right back into my browser
03:08and I refresh it, bam, suddenly me32 exists.
03:12And that's basically the whole purpose
03:13of this whole kind of, this has been true forever.
03:17So all these changes in HTML5 that says
03:19now you're using footer, footer existed, done.
03:22Now it exists.
03:23You don't have to worry about actually
03:25what browser is running because all browsers
03:26really support the dynamicness of different elements.
03:30So let me just make sure that it's back to footer
03:32because I actually prefer it being footer than me32
03:35because that's just a weird name.
03:38And that's really all I want to do about,
03:40that's all I want to talk about,
03:42about the visual elements
03:44because really the visual elements are so simple.
03:47They're so simple to follow
03:49and as long as you get the idea of them
03:51and you can just follow a simple,
03:52you know, like these documents are so short.
03:54If I find that document for a second,
03:59of different, of new attributes,
04:01and here we go, so new attributes,
04:04it's basically the W3C document.
04:06All you really have to do is just
04:07open up the W3C document.
04:09I'll send you a link obviously
04:11and you can see I was just in Bikram Yoga.
04:13No worries, I'm a person, I could do that.
04:16Oh, I forgot to close that window.
04:18So anyways, that's really the whole purpose
04:21of the whole purpose is just go to that document,
04:23read all of them, it'll take you 10 minutes,
04:25maybe 15 minutes.
04:26Now you know all the new elements
04:28and it's so easy to integrate it.
04:29If I would tell you what your homework
04:31should be for this week after you watch,
04:33just pause the video, don't continue watching
04:34and just run through everything.
04:36Stop, go to that link,
04:38go over all the different attributes
04:40and try to figure out what the project
04:41that you have already,
04:42or grab our project that we have down here.
04:44You could use it, play with it.
04:46Find all the different attributes
04:47and see if there's any thematic,
04:49logical place where you could use them.
04:50You don't have to use all of them obviously.
04:52Do five or six just to get a feel
04:53and see that you know how to get it to work
04:55with the CSS and how to get it to work in your HTML.
04:59All right, done with that topic.
05:00Carol, you got any questions in that?
05:02I have structural elements.
05:08I thought that they were basically
05:10to assist the us, the authors,
05:13in organizing the pages,
05:16but they do perform a function visually
05:20if they're assigned in the CSS, is that correct?
05:23Yeah, absolutely, because everything in HTML
05:26could be styled in CSS.
05:28Okay.
05:29So technically, when I put here a footer,
05:31it didn't have any style,
05:32so then our style got messed up.
05:34But I wanted it to have style,
05:36so then I went into my style
05:37and made sure that it's actually referencing
05:39to the right thing now that I changed it.
05:41But everything in HTML
05:43could have a visual representation,
05:46but that would be done in the CSS part
05:48and not inside of the HTML.
05:50So in theory, if I take out my CSS,
05:51all we would see is copy
05:53and we wouldn't really see any layout.
05:58It's not upkeeping, it's for visual as well.
06:04And I think I missed that part at the beginning.
06:07But you could still do it even without it,
06:08so the footer doesn't add any value
06:10to you from a visual perspective,
06:12because you could have kept just this div footer.
06:15You didn't need the footer attribute
06:17to do your visual elements.
06:19The whole idea behind it was to group it logically
06:22to say this is thematically a footer.
06:25Has nothing to do with how it looks like.
06:28Now it's your choice how you want it to look like.
06:30You could go into your style that CSS
06:32and make your footer look the way you want it to look.
06:34In my case, I wanted my footer to be orange,
06:37I wanted the layout to be this way,
06:38I wanted it out of a button there,
06:40and so on and so forth.
06:41Now an important differentiation,
06:43because there are two different types of new nodes,
06:46new elements, there are the thematic ideas,
06:49the grouping.
06:50Now, like you said, you could do visual things in it,
06:53because everything has visuals.
06:54Such as the B, the B still is something visual.
06:57Only when you put a B,
06:59you don't want to put a B in a place
07:00just because you want it to be bold.
07:02If your whole purpose is just to make it bold,
07:04then use a div tag.
07:06If your purpose in putting the B tag
07:08is to say this is a really important part of this article,
07:11then read it, then that's a reason to use B,
07:14because it's a thematic idea of saying
07:16this is an important section of the article.
07:19That's it.
07:20So really, that's the whole point.
07:21So the footer tag doesn't really add anything visually,
07:24but it represents that this area is part of my footer.
07:28Now, why is that important?
07:29Obviously, it just creates a more natural flow,
07:32because every site has a footer, every site has a header.
07:35So why reinvent it?
07:36Why create a div id equals footer?
07:39But on top of that,
07:42when a search engine comes to my website
07:44or a programmer comes to my website,
07:46and they only want to see the content of the website,
07:49or they only want to read the article itself,
07:52Google wants, and Google News,
07:53to only show the news article.
07:56Instead of needing-
07:57That's important, that's excellent.
07:58Exactly, so instead of the needing
08:00to go through this whole spiel of figuring out
08:03how to actually get the content,
08:04and using advanced algorithms,
08:06instead of that you're just telling them,
08:07look, this is the content that's the article.
08:09So you could grab the article.
08:11Now, obviously, if you don't want people
08:12to have access to your site,
08:13there's ways to protect it, that doesn't stop it.
08:15But still, when you want to be SEO friendly,
08:18and you want search engines to be able to crawl
08:19through your site and understand what content is what,
08:23you're basically helping the SEO,
08:25and in other words, you're going to help your site,
08:27because then your site is going to get
08:28more easily indexed in the search engines of the future.
08:37They will put less importance onto them,
08:39and they'll put more importance onto the article itself,
08:42or the main content, yeah.
08:48Similar to when we use Word,
08:50and when we use, where we assign,
08:55where the footer always means footer,
08:57and it treats a certain way in documents.
09:00If we go into everything at filet.com,
09:02this is just an example.
09:03Everything at filet.com is indexed on the web quite well.
09:08Only problem I have is that my,
09:10because these buttons are on every single page
09:12on my website, they're the most,
09:15there's in theory the most important links on my website.
09:18So if I go and I search on Google for everything at filet,
09:22I'll see that in my elements I have here about,
09:26and I really don't want about to be here,
09:28because about is not one of the most important pages.
09:31But it became important because it's on every single page.
09:34So basically by having these elements
09:36and saying that this is the footer,
09:37I'm kind of lowering the priority of the page,
09:39because Google knows that every page has a footer page,
09:42but the footer is not as important as your,
09:44as your main navigation.
09:48So over, but in my case scenario,
09:50I have an about on the bottom and about on the top,
09:52so about is obviously getting a lot more importance
09:55than it probably should.
09:57Yeah, that's about it.
10:01Okay, that makes sense.
10:02Does that make sense?
10:02Yep, absolutely.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!