Out With The Old
Out with the old... We explore the basic things you need to do in your html files to modernize them and get them to fit the new spesification formats. from default styles, default scripts, getting rid of your dtd info and more.
Video Transcript
00:00All right, so let's continue.
00:02Let's actually see the script itself.
00:04So I created a very, very simple HTML file,
00:08some script here just right here on the screen,
00:10just to show you the basics of what are the stuff
00:12that we're first gonna get rid of
00:13from the most basic, basic document.
00:17So the first thing I wanted to focus on is the media type.
00:19Now this is something you can't visually see,
00:22but every single file has a media type.
00:25That's one of the reasons, besides that,
00:27.3.html or .txt or .xml
00:34that helps your native operating system
00:37understand what application it should open.
00:40The web works in a very similar way
00:41where files have headers,
00:44and those headers basically let that application
00:46know what type of file it is.
00:48Now if you're working on a server,
00:50automatically the server's already configured
00:52to set up the media type of .html file
00:56to be an HTML file, an HTML text file,
01:00or you could actually see it right here
01:03in the text slash HTML.
01:04So basically it's letting our browser know
01:07that the file is a type of HTML file,
01:10but that is true already by default.
01:12Now of course if you're a more advanced developer
01:14and you're doing these different applications
01:16where you're sending the file
01:17to something that's actually not a .html file,
01:20but something else, but you want the browser
01:23to treat it as an HTML file,
01:25then you'd have to make sure that you're working
01:26with your server provider,
01:29making sure that your media type is configured
01:31to accept the file and so on and so forth.
01:33But there is no real reason for that
01:36to be inside of our HTML as well.
01:39Can't we just assume as soon as we open the file
01:41if it's in the media type that it's actually
01:43an HTML file, and the answer is yes,
01:45so it's not needed anymore.
01:47Now because it's not needed anymore,
01:49there's no need to type it.
01:50Now on top of that we were talking earlier
01:53about how the different specifications,
01:57in the beginning we're to tell the browser
01:59what version of our file is,
02:01so will it be able to actually know,
02:03so the browser will be able to know
02:05in what kind of profile it should configure it.
02:08That's history already, because the W3C
02:11wants every browser to support historic attributes
02:14even if they're not configured anymore.
02:16And although now we're gonna be an HTML5,
02:19maybe it'll be HTML6, 7, 8, we don't know.
02:22And we wanna make sure that all the different versions
02:24of HTML historically will always continue to be supported.
02:27So this is the idea.
02:29So if we go on to the next tab,
02:31we're talking about the character encoding.
02:33So we talked about the file type itself,
02:35which we know it's already what file type we're in,
02:38hopefully, because it's configured on our server.
02:41We know what character encoding is usually,
02:44because that's configured in the header of our file.
02:47Now if we don't have it configured,
02:49we definitely wanna manually input it and type it in.
02:52So just to make sure it does not hurt to add that extra line,
02:56which basically tells your operating system,
02:59tells your browser, and this file type
03:01is from a character set of UTF-8 or UTF-16.
03:06Now it's not a mandatory parameter.
03:08The reason why it's not mandatory,
03:09because if you configured it already
03:11and the file itself and the file was saved,
03:13it knew what is the char sets of that file,
03:15it's kind of a repetitive thing.
03:17Really, the only reason for this really
03:19would be to superimpose to make sure
03:21that your character set would be UTF-8.
03:24But just from my experience,
03:26it actually created a lot of,
03:27especially if you're working with foreign languages,
03:29it actually created a lot more confusion,
03:31because sometimes the file itself in the header
03:34would be saved as a UTF-8,
03:36but in the characters inside, it would be Unicode
03:38or something of that nature, so it would create confusion.
03:42Now, without further ado,
03:43all I'm really saying is let's continue using it,
03:48because it's, you know what?
03:50It makes life a little bit easier,
03:51it makes life a little bit more,
03:55it makes life easier also for the browser itself.
03:57It does not mean that if you're working
03:58with foreign characters that they'll always work perfectly,
04:00because you still have that issue of making sure
04:02that the file itself is saved in the right character set
04:06as much as that the browser will be able to decrypt it.
04:09But without further ado,
04:12basically all the copy that we had here
04:14before in our metadata, we can basically remove.
04:17All we need now is the character set,
04:18because before we had to say also what type of file it is,
04:21we don't need to do that anymore.
04:22All we have to do, and we don't even have to do this,
04:24but we're recommended to do that,
04:26is to just say that our character set equals UTF-8,
04:29so we could get rid of all that extra goodies,
04:30just meta space character set equals double quotation,
04:35and inside of it are UTF-8
04:38or whatever character set that we're going to be using.
04:41All right, so the next one.
04:41Let's talk about the doc type.
04:43So we talked a little bit about the doc type,
04:44we said it's not really needed anymore,
04:46mainly because the browser's responsibility
04:49is to figure this out.
04:50So instead of us telling it what version
04:52and what DTD file,
04:54what kind of specifications we want to work with,
04:56all we really want to tell the browser
04:58is that we're working under the specification.
05:01To do that, what we have to do
05:02is just basically remove everything here.
05:04We're going to remove all that, remove all that,
05:06and all we have left is just saying
05:08we're under the specification.
05:09We're that doc type HTML basically saying
05:12we're trying to enforce the specification.
05:16Now the browser's responsibility now
05:17is going to make sure that as long as
05:18it's in the specification,
05:20it will know how to implement it.
05:22Now you could still do more strict types such XHTML.
05:26That still exists and it's even encouraged
05:28only when you're doing XHTML
05:30instead of baking it directly into your HTML file,
05:33you're going to change your HTML file mime type
05:37as we were talking about before to be XML.
05:40Now if the mime type of your file is XML,
05:42you're going to treat this file
05:43just as much as you would treat an XML file
05:46and then put the DTD file in the XML specification.
05:50We're not going to go into that world
05:51because I think the standard of just using
05:53the basic HTML is what we're going to flow with.
05:55But if you're comfortable in that way
05:57and you've been using XHTML
05:59and you want to continue doing it that way,
06:01all you really will have to do
06:03is create your HTML as an XML document
06:07and specify its DTD to be that way.
06:12We'll put this probably one of the extras
06:13and maybe on our YouTube site
06:16to show you how to do that as well, okay?
06:18All right, so let's move on to the next topic.
06:20Our next topic that we wanted to cover about
06:22is the scripts.
06:23Now the scripts are basically really JavaScript.
06:27Now historically there were a lot
06:28of different types of scripts.
06:29There was VBScript, there was actually quite a few fights
06:33between the browsers in the old days of the 90s.
06:37Today JavaScript is the winner.
06:39It's the only thing that's in the specification
06:41part of the EMCA script.
06:43I think that's the name of it.
06:45And there's really no need for us
06:47to actually say to the browsers each time
06:49that we're using a script
06:51that we mean that it's a text JavaScript
06:53because that's really the only possible variation today
06:56that is approachable, that is acceptable
06:59if we're using a standardized HTML
07:02because there's nothing else in the standard
07:03besides JavaScript.
07:05Thus we don't really need to say
07:06that it's JavaScript anymore
07:08so we could remove the type both for external scripts
07:11and for internal ones, we just don't need the type anymore.
07:14So let's get rid of the type.
07:15Now that doesn't mean it's deprecated.
07:17If you wanna use it, use it.
07:19You just don't need it, okay?
07:20So we could get rid of it, we just don't need it.
07:24And let's talk about one last thing
07:25before we start actually getting our hands dirty
07:27into actually building some HTML5 stuff
07:31is the CSS itself, same deal applies for CSS.
07:34CSS is really the standard.
07:36The CSS is our style sheets.
07:38Thus, any time that we're using a style sheet
07:40and we're saying it's a style sheet, we're using CSS.
07:43So if we're creating a link externally
07:46and using a style sheet, that's all we really need.
07:48We already set a style sheet
07:49so there's really no need for us to say that it's a text CSS.
07:53There were other implementations
07:55but they were never really embraced by the browsers or users.
08:00So really, text CSS is really the standard.
08:02You don't put anything in there.
08:03And again, if you wanna put something in there,
08:05if you're doing something else, you could.
08:07But it's not needed if you're building an HTML5 document.
08:10By default, it should be just CSS.
08:13So we could get rid of that.
08:14And same deal applies to when we're using styles internally
08:17in our application.
08:18We don't need the type anymore
08:20because we know that if it's a style, it's CSS.
08:23So let's get rid of those styles.
08:24Let's get rid of those types as well.
08:26And there we go.
08:27We have our basic beginning
08:29of how our HTML should look like.
08:32So let's take a visit into that raw document
08:35and let's just delete the stuff ourselves
08:36and see how easy it is to convert our new fresh document
08:40into an HTML5 compliant document.
08:43Now I created, I have your two files
08:45that we're gonna be working with
08:46throughout our different exercises.
08:47One is gonna be our basic file
08:49that we're gonna be playing with.
08:50And the other is gonna be a HTML file
08:52that is a little bit more rich
08:53than has a lot of other goodies inside of it
08:56which you could get in the download section of the site.
08:59Before we start playing with that,
09:00I just wanna show you how they look like.
09:02And I wanna make sure that I'm opening it up in a browser
09:04that actually supports both,
09:07that supports HTML5 as much as we could.
09:09So this is a, we're in Safari on a Mac
09:11which is quite there on an HTML perspective.
09:15We have our index.html
09:17which has that more build full page
09:20that was a theoretical site
09:22that never really was built, might get built, might not.
09:27And it's just a page here
09:28that has some buttons and functionalities.
09:31And we're gonna see how could we can convert
09:32this document to be more HTML5 friendly.
09:36Same deal here, we have a very, very simple HTML page
09:38which is our basic HTML page.
09:41All the changes that we're gonna do right now
09:43are completely non-visual.
09:44So if we go back into our source code,
09:48we could let's start with our basic.html
09:52like we were saying,
09:53and if we could make it a little bit bigger
09:55cause there's so much here.
09:56All this public extra data we don't need anymore
09:59so I could delete all that specifications
10:01about what type of specification are we implementing.
10:06No need for that anymore.
10:08Docked up HTML, that means we're in the specification.
10:10Now it's the responsibility of the browser
10:12to figure out if it could render it.
10:15Regarding the XMS, this is not really needed anymore
10:19because we're not following any specific documentation.
10:23We have a document that is a legal HTML document
10:27which technically is the HTML5 document.
10:30All right, now the next step is we were talking about
10:33how this character, the HTTP content type
10:37is not needed anymore.
10:38The content HTML is just not needed
10:40cause we are in an HTML document.
10:43And really all that we have here that we wanted to set
10:45that we still wanna set is actually the type of characters.
10:48So all I have to do is set it to the character set
10:50and make sure that I'm selecting
10:52what type of character sets my file has.
10:55All right, next in our line was our style sheets.
10:58So our style sheets, we already know it's a style sheet
11:00so we could get rid of that text CSS.
11:03We just don't need it because we know it's style sheet
11:05because CSS is the specification featured.
11:10So the same thing for the other one.
11:11We could just delete it
11:12and we're going to the script exact same deal.
11:14We could just grab our text here,
11:16telling it we don't have to tell it that it's JavaScript.
11:19It already knows it's JavaScript.
11:21And same thing for our internal script.
11:23And there we go.
11:25Now, just for the sake of starting to build out
11:27our HTML document, let's just do that also for this one.
11:31And I'm not gonna talk,
11:32I'm just gonna do it really quickly,
11:33just so you can see how simple it is
11:34to convert your document, at least on the get go
11:37for it to be standardized to any version of HTML.
11:40So here we go.
11:41So I'm just gonna delete anything I see here
11:44that's not needed anymore.
11:46Good, get rid of that.
11:48If you have any HTML documents,
11:49I do implore you to play around with that.
11:53And I'm just gonna delete everything that is not needed.
11:58There we go, that looks okay.
12:01This is not needed.
12:03Whoopsie.
12:05And there we go.
12:06So it looks like we got here most of the stuff here
12:08and they're already out of the header
12:10and already in the body.
12:11So there you go.
12:12So we just got rid of all the goodies
12:14that were not really needed.
12:16We could save this file as well.
12:18And we could just test our files
12:20although there's nothing really to test
12:21because visually they're gonna look exactly the same thing.
12:24Now, what's really nice about this,
12:25even if you're in a browser
12:26that does not support HTML5,
12:27your browser is still going to
12:30render everything the same way.
12:31So this is definitely not gonna affect anything
12:33because as long as you have the same character sets
12:36and the same tags you had there before,
12:39it's, that's still there, it didn't change.
12:42The only thing that's changing
12:43is what new features are coming in
12:44that the browsers are really not gonna know
12:46how to deal with if they don't know how to deal with them.
12:49So that's it.
12:50This covers our really that first step
12:52into digging into our code
12:53and trying to figure out what is needed and what's not needed.
12:56Now that we know what's not needed,
12:57we got rid of what's not needed,
12:59let's move on and learn a little bit more
13:01about how to do some stuff that actually we could see.
