- Podcasts
- Programming Throwdown
- HTML and CSS
About this episodeThis show covers HyperText Markup Language (HTML) and Cascading Style Sheets (CSS), two of the three languages that make up most…
This show covers HyperText Markup Language (HTML) and Cascading Style Sheets (CSS), two of the three languages that make up most client-side Internet programming. The episode talks about the Humble Indie Bundle 3, Linux Kernel reaching 3.0, and the end of manned space flight program. The tools of the biweek are Freemind, an open source brainstorming assistant, and Picasa, a free photo editing and hosting service.
★ Support this podcast on Patreon ★Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
HTML and CSS
Yeah, yeah. But anyways, yeah, boring. Okay, Ireland. So, yeah, Ireland was great. The conference was awesome. The conference was GECCO, which stands for Genetic Evolutionary Computation Conference. And so it's a bunch of guys who are interested in genetic algorithms and neuroevolution, which is my focus. And it's basically a way to sort of get computers to, you know, through trial and error to sort of adapt to their environment. So, you know, in the same way as we adapted as human beings and plants and animals continue to adapt today to their environment, you know, we want to write computer programs that, you know, might not really know the answer right away. But through adaptation, you know, two parent programs can make a baby program that's a little bit better at solving the task. You should
Yeah, definitely. I want to plug one thing, which so I made an algorithm as part of my PhD dissertation called Hyperneat. Like a neat freak algorithm. Yeah, exactly. It cleans your floor. No, it's a Roomba. So it stands for Hypercube Neuroevolution of Augmenting Topologies. But that's neither here nor there. The important thing is someone took this algorithm and used it to generate a 3D model maker. And he actually had a bunch of these 3D models that he created with a 3D printer. And you can actually go on this website and evolve your own 3D models. And I thought this was really interesting and super fun. Let me see if I can find the link here. Okay. Ta-da-ta-da. I know it was on my Google Buzz. Oh, here it is. So yeah, the link is www.endlessforms.com. That's all one word. Endlessforms.com. So we'll put a link in the blog and all that good stuff. But yeah, you can go on there and you can actually take two parent objects and make baby objects and do mutation and stuff like that. And grow your own sort of crazy object. And then you can even, for a small fee, have them print it and mail it to you. Which I think was really interesting. And they also found a bunch of bugs
and stuff, which is kind of useful. So although I don't know how useful it is now, but at any rate, yeah, the conference was great. It was fascinating to talk to some of the people there. And it was also very interesting to go around Ireland. As many people know, Ireland's been the source of strife between Protestants and Catholics. And one of the things that my wife and I did was take a bus tour through Northern Ireland. And we saw a lot of the places where the conflicts happened. And actually, as recently as 1997, the area was a militarized zone. And there were many places like cathedrals and even whole cities that civilians weren't really meant to, outside tourists weren't really meant to visit and weren't supposed to visit. And around 1997, they opened everything up and demilitarized Northern Ireland. And so it was fascinating to see. You know, there's a lot of culture there. And it was very interesting. That sounds pretty good. Had you been there before? No, this was the first time for me. Awesome. Yeah, the bus tour really kind of made it happen. Because otherwise, you know, even though we speak the language and everything, Europe is just vastly different, you know. So they drive on the left side of the road and all those things. So, yeah, I definitely wouldn't have been comfortable driving myself from Southern to Northern Ireland.
Well, not nearly as cool as going to Ireland. But I saw the Humble Indie Bundle Number Three is out now. And so I guess this is a group of independent game publishers. I guess it's a group of people who work with independent game publishers to get some games together. And it's almost always cross-platform, so it works on OSX, Linux, and Windows. And they bundle them together and sell them in a pay-what-you-want style of sale. So you can pay, you know, I assume as little as a penny. I don't know what the exact minimum is. All the way up to, you know, some people pay thousands of dollars for the bundle. And then you can, one really cool thing about it is, well, there's lots of really cool things. But one of them is that you have little sliders and you can set how much of what you pay goes to the developers of the game, the developers of the package, like the people putting it all together and hosting the website and that stuff. And then they have two charities that they support: the Electronic Frontier Foundation, or EFF—sorry, I messed that up—and then Child's Play. So I know you're a big Electronic Frontier Foundation supporter, right?
Yeah, definitely. So the Humble Indie Bundle is great. You know, I do it every year. And, you know, I put a lot of the slider towards EFF just because it's something that I strongly believe in. But you can really, as Patrick mentioned, you know, set the sliders and the proportions of your donation however you want. But they're usually pretty quality games, especially considering you can name your price. They're definitely high-quality games for the value. And they distribute them through Steam, which is really useful. So you don't have to deal with, you know, as long as you're a Steam member, you don't have to deal with downloading the EXE and going through the install shield and making sure it's on all your computers and things like that. And I think the last few times they've even open-sourced the games. So you
Yeah, and Child's Play, just if people don't know what that is, is a charity where they try to install, you know, game consoles or video games of various sorts to hospitals for people who are, you know, kind of in the hospital for extended periods of time to have something to do. And to kind of help them with that. So...
Yeah, the games for this year are Crayon Physics Deluxe, which is an awesome, awesome game. It's one of my favorite games. I actually already own it, but I think I'll, you know, I'll almost definitely buy it and play the whole thing again. And just to put it simply, you know, you could think of it as being a child and you draw these objects on a piece of paper with your crayon, but they come to life. So if you draw, say, a circle, that circle turns into a boulder and it falls down to the bottom of the page and starts rolling. And you can create all sorts of different objects and they act as, you know, boulders, cantilevers. You know, you can make a car. You can do all sorts of crazy things.
Oh, man. This is the first time we've been wrong on the podcast. Yeah, only time. So, V to the fifth is a platformer game that's known for being especially difficult and challenging. And so, you know, the thing about platformers is you can start, like, usually there's many levels. And when you die, you just go back to that level. So, you don't lose a lot from dying. But they make it very difficult. So, you're constantly pushing yourself to, like, you know, get that one more level. Cool. So, I've heard a lot of good things about it. I don't know the other two. Do you know the other two?
A hammer fight is some, it's like a steampunk helicopter with medieval weapons. You, like, fly around and destroy stuff. Oh, that sounds awesome. And yet it moves. Looking at the, you know, little demo video, it looks like you kind of move through a world. And you can kind of rotate the world around you. So, you're going to always stay straight up. But the world rotates around you to allow you to move through passages and stuff.
Yeah, I mean, it was, I think like, if I remember correctly, the way it works is every even number is stable. And every odd number is like experimental. So, like 2.5 and 2.3 and 2.1 were all sort of these experimental that, you know, as long as you were running, if you were running, you know, operating system like Ubuntu or Gen 2 or something like that, you never got those versions. But all the even numbers like 2.6, 2.4 were the ones that went out to production. And so, to go to 3, just, you know, a lot of people thought that it might even go to 2.10. So, to go to 3, it was
Now I feel old. It's okay. Anyways, but yeah, so I guess they said 3.0. I was looking a little bit into it, but I don't run the bleeding edge Linux kernel by any means. But it looked like there were some updates to it, but they were more kind of relatively going to 3.0, which seems like a big deal. There were only a few minor updates. Yeah, that makes sense. And it just wanted to get to 3.0. They just, you know, too many, too long had they been in the two-point region. And so, they were ready to move on to 3.0, and they decided this is as good a time as any. Yeah.
That's cool. I mean, as the article mentions, there's LinuxCon. There's, you know, a bunch of different conventions. And, you know, being a Linux developer is a largely social experience. Because you think about it, you're writing drivers. And, you know, often, I mean, of course, there's algorithms involved and things like that. But a lot of the work, a lot of the code base is, you know, drivers for different hardware. And so, to implement these drivers, you have to, you know, talk to a lot of people. And so, you know, it's kind of a social environment. And as the 20th birthday approaches, bumping up to 3.0 is sort of a little, you know, kind of cute gesture.
Yeah. Another thing that's been, you know, as long as I can remember since, I don't know if I said this before, but living in Florida, the Space Shuttle has always been something that, you know, you can always hear the sonic booms when it comes back into the atmosphere. You know, I've been out to a number of launches, which is, there's just really nothing to compare. It's something you can't capture in video or words or describe. And sadly, the shuttle program's now at an end.
through NASA. No, no. So, they are. So, NASA is going to continue to do, you know, all the other stuff it's been doing. And there are plans for more manned spaceflight. They just don't have a manned spaceflight replacement now for the Shuttle. Oh, I see. So, we'll be using, to go to the International Space Station and to do any other sort, we'll be using rockets from other countries. So, mainly the Soyuz capsule from Russia to send people into space. And then in about, the numbers constantly change, but in about four to five years, you know, they plan to have something that we have that we can send people up. And there's a big push, though, for there to be more private involvement. So, private companies instead of, so NASA, for those who don't live in the United States, NASA is a government organization. And so, they're trying to get more private organizations that will send people to space. And then NASA can basically just buy tickets on other, like an airline, right? You know, NASA just wants to buy tickets to space to send people. Yeah, that's hilarious. I wonder what, do
So, there's a number of companies doing this. And this is kind of a highly charged political thing, so I'll try to stay non-political in this discussion. But, yeah, so various companies have different motives. Some have the idea of space tourism, which is, you know, send people into sub-orbit or low-orbit. Or to even, you know, there's the idea of having space hotels and sending people to that, right? And then, the cheaper you can make it, the more people on Earth will have money to be able to do that. And then, there's other people who say, you know, only big government-sponsored contractors and the government themselves can send satellites. And so, there's a lot of people who would want to send satellites if they're cheaper. Or it would just be better for everybody if they were cheaper. So, they're trying to be able to send satellites. Well, if you can send a big enough satellite, the satellite can just be a, you know, capsule that has humans in it. And so, but then you add this all, much more important to keep safety in mind and that kind of stuff. So, you know, but basically, the humans in a capsule become the payload instead of a satellite. And so, there's some people who are taking that approach. So, basically, being cargo ships with the one day being able to put humans there, too.
And I mean, you know, within, well, not within our generation, but, you know, there's plenty of people. All the baby boomers who are around, you know, remember, you know, in their lifetimes the Sputnik and the space fever and Carl Sagan. You know, people just really, you know, pushing the envelope on educating people about space and the universe and the cosmos. And, yeah, to go from that to canceling the program is, yeah, it's a little sad. But, you know, now we have new technologies that are sort of fueling our imagination. Yeah.
Sorry. Yeah. Oh, no. I was going to say it's time for the tool of the bi-week. Tool of the bi-week. All right. You're up first, man. All right. My tool of the bi-week is FreeMind. And I've actually been using this a lot lately because I've had to sort of, I've been doing sort of, not really a lot of design, but I guess I've been trying to really educate myself on a lot of different technologies lately. And this really sort of helps to let you sort of jot down a bunch of ideas really quickly. Basically, what FreeMind is, is a tool for creating a tree of phrases. And actually, it can even hold, you know, rich text and paragraphs and what have you. But, you know, you have a root node, which might be, let's say the root node is, you know, HTML. And then just there might be different categories of HTML that you want to learn. Like you want to study, you know, you want to study different like divs and how to write divs. You want to study tables, like different things. So you can have sort of this tree structure with like a root node and then children. And this thing automatically draws the tree and helps to, you know, reposition the tree. Like if one of the areas of the tree gets very large, it'll move all the nodes around. But it's a way to just quickly jot down a bunch of ideas in a medium that allows you to sort of make connections and allows you to think critically.
Yep. Yeah, it actually lets you export it to a number of different formats. One is HTML, ironically, which we'll talk about later. But it lets you, you know, export it to a website, export it to PDF. It'll let you do many different image formats. And it's really slick. It'll even import. If you have like an XML file, it can import that and make a mind map out of it. Oh, awesome. Which can be useful.
Yeah. So my tool is, I think most people kind of know about this. And I'm on a streak. You're always on the open source stuff. And I kind of haven't been doing open source stuff. I'm probably garnering a lot of glares from people in our audience, but that's okay. Yeah, so this week I chose my tool as Picasa, which is a photo management and, you know, kind of editing software from Google. And I've been taking a lot of photos recently. And you don't realize now how many pictures you really take between having them on mobile phones and a point and shoot. And I have a nice SLR camera. And you go on vacation. You come back with just, you know, literally hundreds of photos. And having them like with weird names. And sometimes they get off on dates or something. And it just, it can be really a mess to track them and sort them. And then there's all this, you know, cleanup you need to do because inevitably you can tweak the picture some little way and make it better. And so Picasa has been really good to be able to handle that. I have tried a couple of open source photo management tools. And I just never made it through the learning curve of getting used to them. So does Picasa use the cloud or is it all on your computer? So it has support for both. I mainly use it just because I don't have that many photos. And I don't really share them with people because I've, it kind of to me ends up, I'm not a great photographer. So I feel like it's watching somebody's boring vacation video. And so I don't typically feel compelled to share my pictures with people. But yeah, they have, so mine just used on my local computer, but they have the ability to store it Picasa online and Picasa web albums, which is integrated in the new Google Plus, which you were talking about last time, which I guess now we are both on there. And we have a couple, we have about 12 people following us on Programming Throwdown on Google Plus. So we should give a shout out for that. But Picasa web albums integrate tightly with that. So you could post from Picasa the computer application and be able to use that in one of your Google Plus posts.
Yeah, definitely. We should mention that we are on Google Plus. And if you do add Programming Throwdown, make sure to add us too, because sometimes we'll post geeky stuff, you know, from our personal accounts that might be interesting. You know, but we will use the Programming Throwdown account to post, you know, when there are new episodes and things like that. So it's definitely very useful.
About Picasa, I mean, my concern is like, so I have a bunch of photos, and I have, you know, a gallery software that I run on my computer. My concern is like, if there was to be a fire in my apartment and my computer and everything, and it burned to the ground, I'd lose, you know, all of my memories. That
Yeah, yeah. I mean, you can keep them private, and for a backup purpose, that's good. And I believe you actually, there's a, you know, they give you so much space for free. And then if you want more space, you know, there's a fee. And I don't think the fee is actually very much, but that's their arrangement. But I actually use separate, which I guess we should talk about at some point, backup strategies. But that is important to make sure you're backed up. And a lot of times people back up to external hard drives, and that's good. But if something happens to your house—flood, you're moving, whatever—and they lose the hard drive, then what? Yeah. So that's kind of better than nothing, but not still the greatest. So I actually run some other software that I use to back up more than just my pictures, but kind of my music and other stuff to the cloud. Oh,
All right, so we're talking about programming languages, HTML, and CSS on this show. And the hope is, you know, this is going to be a two-parter. We're going to start off by talking about HTML and CSS, which is mainly for, you know, making static web pages. And then we'll go on and talk about JavaScript in the next episode for making, you know, dynamic web content. And, yeah, the goal is at the end of these two parts for people to really have a good understanding, you know, when they go to a web page, especially, you know, nowadays with modern websites like, you know, Gmail, for example, where it's constantly, you know, checking for new emails. You know, what's actually happening under the scenes? Yeah.
Definitely. I mean, some people kind of, you know, I was telling some people that, you know, we were going to be covering HTML and CSS. And then they were like, oh, that's not really a programming language. But, I mean, it is really so vital to a lot of what's being done today. And it kind of serves, if not a programming languages by some definition. I mean, it does have very close analogies and similarities to programming languages. And, I mean, I don't know if HTML, it doesn't have loops and stuff like that, like you might associate with a normal programming language. But it is something you can write. It's something that's, in a way, executed by the browser, which we'll talk about in a second. And, I mean, all of us use the web. I mean, that's probably how you found this podcast even. So, it really is important to know the technologies that underlie that.
Yeah, I feel like, you know, in many cases people would argue that a programming language is one that lets you manipulate things. And so, you know, something like PHP or something, which we'll talk about later, would be a programming language that lets you create HTML. And HTML is sort of the output of a programming language. But, you know, remember that, and we'll talk about this more later, but basically HTML is read by, you know, the web browser and processed. And there's many instructions there, like go grab this image or, you know, move this table over there. So, in many ways, there's a lot of computation going on. I feel like that can be underestimated.
Yeah, and it is such a fundamental part of, you know, like you indicated, output of PHP. There's, you know, all sorts of, we're talking about second web frameworks that output HTML and CSS. So, yeah, it's almost an intermediate language. It's the output of a language that gets run on a browser. Yep. So. So, go ahead. I was just going to say, so, I mean, it is a markup language. So, what, where does that come, what's a markup language?
Oh, really? Oh, yeah, I guess that makes more sense. But they would basically get, you know, they would want these sort of blue collar laborers to go and position these stamps every day for the printing press. They would have to run, you know, newspapers or magazines, et cetera. And so, they created this language to say, you know, to give a very generic way of laying things down on the paper. And so, when the HTTP protocol was invented very early on, you know, it was clear that they wanted to use it to disseminate information. So, they decided that, you know, there's already this markup language in place for newspapers and books. So, they might as well sort of leverage some of this and create a hypertext, a markup language that can be used over the internet. And so, that is what HTML is, hypertext markup language.
Nice, nice. So, you know, we talked a little bit there about the HTTP protocol and the web. So, it might be good if we walk through kind of the process, you know. This isn't specific to HTML, but it gives us the context for where HTML fits in this pipeline, as it were. What happens when you go to your web browser and you type in a site? And, you know, how does HTML get there and get rendered and all that part?
Yeah, yeah, that's really important. So, let's, I guess let's start here. You go to any website, you know, AOL.com, right? Nice. And you hit enter. And the first thing it does is it, you know, turns AOL.com into an IP address using something called DNS. And we'll kind of leave that for another time. Hand waving. Yeah, that's right. It has this number, this address on the internet. And it actually opens up a TCP connection. TCP stands for Transport Control Protocol. And opens a TCP session and then makes a HTTP request on that session. So, the request will contain different things, like a little header saying, you know, who's making the request, some information about them. It'll contain some parameters. And it'll contain a cookie. So, we'll talk about these. Basically, let's say you visit a website. And you'll go and make a request with no parameters, like AOL.com. No parameters. I just want to see what AOL has to give me. The server will receive your request. Now, the request is going to go through many layers. The first layer it'll hit on the server side when they've got your request is called a layer of filters. So, they might have filters that say, is this person logged into AOL? If they're not, then send them to the login page. You know, is this person coming from another country? If they are, then redirect them to AOL.de or AOL.cn for China. Then, after it passes through all these filters, it goes to what's called a servlet, which is a piece of code on the server dedicated to handling a specific client request. So, in this case, it would probably be a front page servlet for AOL. And you would go on there and it would serve you, you know, the servlet would return the front page contents. Maybe there's some news articles, etc. And it would return this as HTML. And when it returned it, it would return, it would give you a response. And the response contains the, you know, the packet, the payload, which is, in this case, you know, an HTML, you know, a block of HTML. And it will contain some header information. So, it would tell you the Multipurpose Internet Mail Extensions, or MIME type. So, in this case, the MIME type would be HTML because they're giving you an HTML page. But they could also be giving you other things, which, you know, I'll talk about in a second. So, the header information will also contain a cookie. And the cookie is a way for you and the website to pass information back and forth. And so, we'll talk about that also a little bit later. There's actually a lot that goes on, much more than you would think when you hit
a website. So, that's because the HTTP is stateless. So, it doesn't maintain an inherent state about the connection. Every time you go to a website and say, 'Hey, I want your webpage.' Without the cookie part, it would just give you the default webpage and it would know nothing else. Right? Because it doesn't keep like, 'Oh, you came back. You were just here a second ago. Well, here's what you were doing last time.' And so, all that is pushed onto the client side, which is the browser versus the server, which is the part hosting the code. And so, the client has to maintain any state that's necessary and change how it interacts with the server so the server knows who it is.
Yeah, exactly. So, like two ways to do state. One would be, let's say you're looking at the news now on AOL News or something. You can pass in what's called a parameter to the website. So, you go to AOL and it shows you the first news article, and you want to see the second one. So, you click the little arrow that says 'Go to the second news article.' What your browser could do is it can go to AOL.com?2. And so, whenever you see a question mark at the end of a URL, at the end of an address, anything after the question mark is a set of parameters. So, you could say '?page=2'. And when that request gets to the server, the server will see you want to go to AOL.com, but it will also see, you know, this page variable is set to 2. And it might, the servlet might intercept that and say, 'Oh, this person wants the second news article,' and return that. There's another way. There's actually two more ways to send information to the server. The second is through what's called a POST. So, whenever you have the question mark and the page equal to at the end of the URL, that's called a GET request. There's also a POST request, which is, I guess you could say a little bit more private. What it does is, it does effectively the same thing as the GET request. It sends you—it would send, you know, page= over to the server. But it does it behind the scenes, so it doesn't show up in the URL. And so, this is important. Let's say you
Because you don't want, like, your buddy behind you looking at the URL and knowing your social, right? Although, or even just, you know, you leave the computer. All of the URLs you visit are in your history. You don't want your social security number. So, POST gives you a little bit more security there. But by far, the best security comes from cookies. And what cookies are is basically an object that gets passed from you to the server and then also passed back from the server to you. So, you know, the POSTs and the GETs are one way, but the cookies are two-way. And so, cookies are a way for you to do a bunch of really interesting encryption things with between yourself, the client, and the server. So, for example, you know, you don't want to just pass your social security number, like, Patrick social=this across the internet. So, what you might do is you might pass a cookie saying, 'Hey, here's a key.' And then the server might pass back another cookie. Or a third party might pass you another cookie across the internet and say, 'Hey, here's some other key.' And using these different keys, you can encrypt your password and then pass that encrypted password as another cookie. So, cookies allow you to do a little bit more fancy, you know, message passing back and forth. But, yeah,
basically... So, you ultimately get this HTML description in this MIME. And that, we talked about that it's a markup. So, it shows here by whatever means, you know, that's gone on behind the scenes. But it finally arrives at your browser. And then your browser has to do something with it. So, it goes through and finds tags, right? If you ever look at it, those are the things in the angle brackets. It's... And says, 'Hey, this is markup.' This is telling me to stick this thing here or, you know, this thing over there. And so, then it goes through and parses that information, reads it, and decides what to do with it. And then just... It may also contain, 'Hey, you need to go grab this other thing.' Like, we'll talk about it in a second. 'But go grab this CSS, this Cascading Style Sheet from over here.' Or 'go grab this image at this URL.' And then render it and stick it here. And so, once it has that, your browser gets the HTML. But then it has to go back to the server, possibly, and get more information. It might have to make other requests to get images, to get other things that might be there. Exactly. Yeah.
So, when the server returns that response, it will have that MIME that we talked about. So, you might grab the HTML. And the HTML might say, 'Hey, you need a bunch of images.' And you might go to the server and say, 'Hey, I need to get this resource.' And I'm pretty sure it's an image. So, you could tell the server, 'Hey, I want, you know, this resource in the MIME. I think it's an image.' And the server will return back and say, 'Yes, the MIME, it's an image. It's a PNG image. Or it's a JPEG. And here's the payload. In this case, it's not HTML. But it's just a chunk of data that represents a JPEG image. Or a Cascading Style Sheet. Or many other things.'
Yeah. So, that describes kind of where to stick the data on the page. How to locate it in ways. But you could make the HTML describe and only have an HTML. And have a static, you know, webpage with just text and colors. And, you know, that kind of stuff. But as you try to do more and more, it could get really complicated. Very intricate. And, you know, kind of have all these layers you're trying to do to get something exactly where you want it on the page. And a certain color with a certain look and feel and texture. But then when you want to make, you know, news page two, then you've got to recreate all that HTML code. And so, Cascading Style Sheets are a way to take away the data, the text, the paragraphs, the images, as it were, that the HTML represent. And the way those get rendered, kind of maybe where they go on the page or the background color. Or if you have, like, curvy edges on your tables or whatever. And put that in a separate document that separates what the data is from how it gets presented or displayed. Yeah, exactly.
I mean, let's say you had 100 web pages, 100 HTML pages that you were serving to people. And you wanted to change the font on all 100 of them. Well, that would be brutal because, you know, you'd have to change it on all of them. You'd have to make sure, you know, it looked right. And you'd have to push it out, push 100 files out to the server so that they could be read by users. If you have a CSS, a Cascading Style Sheet, you can just make the change once in that style sheet. And all the HTML files will just say, hey, use this style sheet over here. And, you know, any text, you know, the font's going to be whatever this style sheet, you know, says it is.
Yeah, so they all reference this same style sheet. Wow. This same style sheet. Too many S's in a row. The other thing, so the cascading part, so the style sheet makes sense. And then the cascading comes in because you can get what amounts to inheritance between the style sheet. So, like, you know, a master definition of some, you know, high-level things for your site. But then maybe you're in the forum section of your site. So you could have a separate CSS that's for the forum section of the site, which gives more specifics, details that are only used there that aren't used somewhere else.
Right. Like, as Patrick mentioned, there's HTMLs made up of a bunch of tags. Like, you might have a tag that says, 'Here's an image.' You might have a tag that says, 'Here's a paragraph.' Another tag might say, 'Here's a table,' or 'Here's a heading.' And each tag has two things. It can have up to two things. It can have a style and it can have an ID. And they're both strings. So you can have a table and the style is dark, and the ID is, you know, news-table. So you can only have—the ID is meant to be unique. Like, so if one table is called 'news-table,' the other one has to be called something else, like 'footer.'
Table too. But you could have ten things all with the style, you know, dark. Right? And so where the cascading comes into play is you can say, 'I want my font, like in general, I want my font to be Helvetica.' But if my style is dark, I want my font to be Arial Black. And if my style is dark and my ID is news, then I want my font to be Arial Black and bolded. So that's where the cascading comes into effect. It'll try and pick the most specific style. But, you know, so it'll try and find a style for your specific ID. But if one doesn't exist, it'll take a step back and try and find a style for your style tag attribute. And if it doesn't find that, it'll take another step back and say, 'Okay, what's just the default font for all paragraphs?' And it'll use that. If it doesn't have anything there, the web browser has its own default style sheet that it applies.
Yeah. And that helps, like, you know, like Jason was indicating, you know, if you've got to put that file in one place, then you have all these specifics laid out and you can have multiple style sheets. And you only have to go change those. You don't have to go change every single web page that you have, which may be many, many, many web pages. Or in the case of if it's generated from a web framework, then you just have to worry about rendering the data and the CSS handles the style. And then you don't have to go and make sure your code knows how to output the formatting as much.
Yeah. Yeah, I mean, imagine an environment where, you know, you have a couple of web pages that are static and they're just .html files. But you also have some pages that are generated, you know, based on certain content. I mean, maybe you're scanning the weather and you're giving someone a map, but the map's generated based on the weather in the area and it's different every time. You know, that code that does a generation and the static HTML code are usually in two different places. But you want to make sure that it all looks the same. You don't want that code just because it's done dynamically. You don't want it to look ugly. So the style—the Cascading Style Sheets allow you to apply the same style to everything, regardless of where it came from.
Another really useful feature is that if you've ever been to a website that allows you to choose a theme, that can be handled by choosing what CSS is loaded. So you can have a CSS that's the light blue theme or one that's the happy kitten theme. And that changes what CSS your browser uses. If you want, and this can be kind of interesting, it's like if you download an HTML page, you could change what CSS it uses and change how it looks. Or, you know, in theory, right, you could have some part of your browser that overrides the CSS referenced by an HTML and point it to something different and change how, you know, websites you use every day look and feel by writing your own CSS for it.
Yep. Yeah, there's a plug-in. You know, most browsers will have a plug-in where it will go through and replace the CSS links with links to CSS files on your computer. And that's mainly for development. So you could go right now to, you know, to keep using the same example, to AOL.com, but have it use your CSS files that are on your computer somewhere. And, you know, people from AOL would do something like this to sort of change the look and feel and do nice cutesy design, make cutesy design decisions without, you know, breaking the website or without, you know, having to push something out to the users. They can just test it on their own machine.
content management systems. Right, right, right. So something recently that you might hear about is HTML has version numbers. So most of the web nowadays uses HTML 4. But you hear about this HTML 5. What are some of the changes coming up in HTML? We talked earlier about Linux 3. HTML must be better because it's at 5. Yeah,
that's right. Yeah, so we'll post a link on the blog that we'll have. It's actually called html5rocks.com. And it has some cool slides and some nice slick interface for showing you some of the new features. But in a nutshell, HTML works hand-in-hand with JavaScript, which we'll talk about on the next show. But what HTML 5 adds is a bunch of sort of dynamic tags that add very rich content. So, for example, there's a canvas tag. So you can say, you know, canvas tag. And then in there you can say box or you could say triangle or you could say whatever. And it'll just draw these shapes like right onto the website. So, you know, in the past you had to do sort of really crazy stuff or use Flash or use Java applets or use, you know, all sorts of different hacks, ActiveX controls to get, you know, rich content on the Internet. And HTML 5 is an attempt by, you know, a consortium of companies to say, you know, look, we don't need all these third-party applications that are really kind of hacked together and don't work on every browser. What we really need is to just make HTML better and to make it dynamic and to make it, you know, more interactive.
Yeah, and add things like the ability to embed movies directly and even have some ability to have offline storage for your website so that you can do kind of offline use of the website. For things like, you know, if you have a mail client, you might want to be able to browse your Hotmail even when you're not connected to the Internet. You won't be able to get new stuff, but at least you can browse what you already have. Yep, that's right. So HTML has that. But with great change comes great controversy. That's right. So it's not completely settled exactly what HTML 5 will end up being when it's all said and done.
Yeah, one of the biggest controversies in HTML 5 right now is the video encoding. You know, right now there's sort of a patent war going on, as many of you know, in Silicon Valley between many different companies and consortia. And basically where it stands right now with the video encoding in HTML 5 is, you know, the Internet Explorer and Safari, so Apple's browser and Microsoft's browser, they support MPEG-4. But MPEG-4 is covered under a patent. So they pay a license fee to, I believe, Frankhauser, which is a company I believe located based out of Germany. But so they pay Frankhauser LLC, you know, to use the MPEG-4 codec. And, you know, patents are really hairy business. Technically, they're breaking the patent, but they have an agreement, so on and so forth. It's all kind of shady. So, you know, Firefox being, you know, an open platform and, you know, being largely funded by the EFF, which we talked about, and the Free Software Foundation, which are vehemently against patents, said we're not going to do MPEG-4. This doesn't work. You know, we're not happy with this. So they decided they're going to support AugTheora and another codec called the VP8 codec, which is a codec developed at Google, which is completely open source with no patent restrictions. Chrome, Google Chrome, which is another browser, has jumped on the bandwagon and supports the same, you know, video codecs that Firefox supports. And so what you end up with is if you're on IE, you know, your HTML5 videos won't work if the server expects you to be on Firefox and vice versa. And so, you know, these kind of things always happen with new technology. There's always these battles. But, you know, eventually things will start to stabilize. Yeah. Yeah, so that's my soapbox for the day. So there
Yeah, so these are very pedantic. I mean, this isn't the kind of thing that revolutionizes the web as much as people at the time would like venture capitalists to believe. XHTML is just a stricter formatting for HTML. So, for example, in regular HTML, well, let's explain a little bit how tags work. Okay. In HTML, you have an opening tag and a closing tag. So you might say opening tag table and then have opening tag row and then have opening tag cell. So a table is made up of rows, which are made up of cells. Then you might put in some cell data. Then you might say closing tag cell. You know, that's the end of that one cell. Then close to, you know, put some more cells. Open a cell, close a cell, open a cell, close a cell. Then you'll close a row. You can make some more rows. And in the end, you'll close the table. And that's the end of that table. Some of the tags in regular HTML don't have to be closed, although they really should be. So, for example, you can have a paragraph where you open the paragraph and you just don't close it. You know, you just have a paragraph open tag. You type some text. And then you have a table open tag. And browsers had to get really smart about knowing, oh, this paragraph closed because this person started a table. And the table is clearly not part of that paragraph. But this got very tricky in browsers. You know, you'd go from one browser to the other and your page wouldn't work right. So they decided to make HTML more strict. And most web pages made nowadays are written in XHTML, which adds some extra restrictions. So if you open a tag, you have to close it. And there's a couple other restrictions, but that's the biggest one. Another buzzword is DHTML. And this basically just means using JavaScript and HTML at the same time. This is kind of a buzzword that was used. It generated a lot of hype. But it doesn't really mean anything. So don't confuse these two things with HTML5. HTML5 is huge and revolutionary. And these two things, really, they're not much of anything. So definitely be excited for HTML5.
Yep, that's right. If you do want to use the latest HTML5 features, I believe the development version of Firefox and the current version of Chrome support just about everything. There's a few things with the audio API that aren't supported with the regular version of Chrome. You have to go on the dev version. But if you use either of these two browsers, even the public versions, you'll see a lot of what HTML5 has to offer. Yeah. Yeah.
So besides just webpages, which is what prior to a year or two ago, most everything, when you talked about HTML, was talking about a webpage. Or, I guess, a few other niche uses. But now, more and more people are using HTML to do things not just in a browser, on a website, in the traditional sense. We talked previously about, on iOS, that you could have a webpage show up as, like, an icon on what amounts to your desktop. And, you know, when you click it, it launches. And it can even launch, basically, a web app, a web application, with a browser that you don't see. So you just see the app. It just runs just like a program. But it's really embedded browser rendering HTML content for the user. So think of this, again, to use, like, Hotmail. You could have Hotmail as, essentially, an HTML that lives on the phone in some JavaScript that, when you run it, displays what's local to the phone. But then has a component which can go out and grab new mail, bring that in, and display that. And if it's written well enough and supports what's needed to do that, you wouldn't even be able to tell the difference between that and a program written in Objective-C for the iPhone.
Yeah, I mean, you know, just take a moment. If you're looking at a web browser right now while you're watching this podcast where you can visualize one, as long as you're not driving, we don't want you to get in an accident. Yeah, don't close your eyes. Yeah. Just imagine the address bar not being there and the tabs not being there and you're just looking at the one page you're looking at and it's taking up the whole screen. There's really not much standing in between that, you know, differentiating that from just a regular application. The nice thing is, you know, you can make an application that works in a browser but then also works without a browser at the same time. And this is really, you know, for things which are largely static, this is, you know, a great way to go because you get so much for free. You know, the people who wrote the browsers kind of did the heavy lifting for you.
Exactly. There's an application called PhoneGap, which what this does is it takes a website that you've created and it will deploy it on all sorts of different environments. It's on Android, iOS, I think it even does Windows Mobile, and it even does, like, some of the more obscure ones like Palm and things like that. But basically, it'll just, you know, take the HTML and JavaScript that you've written and do some reinterpretation as necessary to get it to be compatible with the browser on the phone and just make it an app on the phone. So, you know, you can write something once, you can test it on your computer using, you know, your web browser, and then using this PhoneGap, you just, you can deploy it and be 99% sure it's going to work on, you know, every smartphone out there, which is really powerful.
We already kind of talked about before, but to kind of emphasize again, although you can write hand, by hand, write HTML, a lot of HTML that you see on the web is generated from other programs written in other languages. Some of the popular ones, you know, being like PHP, Ruby on Rails, a number of Python web frameworks. Some websites actually have a C++ backend or even a C backend, which once the browser communicates with it, responds with an HTML page. It's really flexibility of HTML that allows all of that to happen. And so it is used as a method of communicating what needs to be displayed. And it doesn't just have to be the traditional old school static HTML site that a person wrote by hand. Yeah, that's right.
I mean, imagine if you have, you know, you're writing some kind of inventory system, and you have some database somewhere where every time someone buys one item, it, you know, reduces that inventory by one. And so then when it gets to zero, it pops up, you know, it might show up in red or something like that. So, yeah, you might write something in Python, which says, hey, you know, go to this database, get all the records, and for each record, convert the record into a block of HTML. So, you know, make a paragraph tag and make a little font tag for the ones that are empty and things like that. And just turn this database data into HTML code on the fly. And so if the person hits refresh on the page, you know, after some people have gone through and bought some things, they'll see the new value, like the new inventory.
Yeah. Yeah. So, I mean, that's kind of a big strength, and I don't know how much people anticipated. They designed a lot of flexibility in HTML, but it really has survived. I mean, we haven't gone through any other real ways. I mean, there were early on, but for a long time we've been on HTML, and that'd be kind of the language of the web. And so the basic HTML has very widespread support. As long as if you don't do anything weird or funny, it's really well supported. It's when you get into adding plugins or JavaScript or other things that you can run into cross-platform issues. But HTML itself is very cross-platform compliant.
Yeah, definitely, definitely. Yeah, so I guess we'll cover the strengths briefly. You know, as Patrick mentioned, it's very cross-platform. So you write the website once, and 99% of it will work, you know, on everyone's computer. And typically when you're making websites, you're making them for a lot of people. I mean, you might, I mean, imagine how many people visit, I don't know, AOL or visiting these really popular websites, Yelp, right? I can't has Cheeseburger. I can't has Cheeseburger. Google Plus, right? I mean, there's millions of people going on these websites. And they come from, their computers come from all sorts of backgrounds. Some people are running Linux. Some people are running Linux kernel 3.0 beta with the latest Chrome on them. Some people are running really old Windows 98 machines with IE6 or something, right? And so the web has to work for all of these people. Actually, it doesn't have to work for IE6 anymore. But the web has to work for a lot of these people. And so, and the way HTML is designed, it does, it accomplishes this. And so one of the hardest things in, you know, software development is deployment. You know, it's getting your application to run on everyone's machine. Anyone who's worked for a company or done commercial software development knows that there's a percentage of people that you just know up front that you're going to have to refund them their money. Because the game you made isn't going to work. Or, you know, the app you wrote, it just crashes every time. And this is just a known fact when you're writing, you know, desktop apps and things like that. You're just going to have, there's going to be unsatisfied customers. When you're using HTML, you know, the number of people who actually get your content correctly is amazing when you really think about it. All the different machines that are coming to your site. Yeah. Yeah. But the other thing is it's hand writable. So, you know, this, you know, we've talked about using, you know, programs to generate HTML. But, you know, especially for some of the static things, like you might have an idea in your head of sort of how the webpage should flow. And it's sort of a, it's a design. It's an aesthetic, you know, exercise in making a website. And so making something that's hand writable where you can go in and tweak some values and maybe you want the heading bar to be a little bit smaller to give you some more real estate. You can go in and do that. You don't have to mess with some program or something to get at the HTML. You know, typically, especially with cascading style sheets, you can go in and tweak all the values and make your website look just right.
Yep. Yeah, definitely. I mean, we'll talk more in the next episode about JavaScript and Ajax and things like that. But yeah, I mean, regular HTML and CSS, if you want to see something different, you have to hit F5, you know, or Control-R if you're on Linux. You have to hit the refresh button on your browser to get new content.
Yeah. There's also the way it's implemented now, and I know there's some movement afoot to try to fix this or change this in a number of different ways. But when we talked about you go request the HTML site, right? So whatever, AOL.com, and it responds with AOL.com/index.html. And you get that, and your browser starts parsing it. And it says, oh, I need to go get this CSS sheet. It doesn't maintain that connection. It opens a TCP connection, gets the HTML, and then closes the TCP connection. So that's like a phone call: picks up the phone, dials, says, 'Hey, I want the HTTP thing here,' grabs it, hangs up. Then it goes, 'Oh, I need the CSS sheet.' Picks up the phone, dials the number, you know, asks, 'Hey, I need the CSS sheet.' What server sends it across? Then it hangs up. And while it's doing that, the browser can optimize a little by making all of those requests in parallel. But still, each item is a separate TCP session. And just like in that analogy of picking up the phone, there's an overhead of picking it up and dialing a number. And the same is true in TCP; that to be flexible, TCP has like a little bit of a slower startup time than you might want if you're going to be making many, many, many, many requests to the same server. Yeah.
Exactly. I mean, just to put things in perspective, you know, video games and things which have a high, you know, real-time component to them are done in UDP. So because UDP is another protocol, which we won't really get into, but because TCP has too much overhead, so they have to use UDP. So this, you know, HTML is going over HTTP, which has even more overhead than TCP, which isn't good for a lot of applications. So HTTP really isn't good for a lot of applications. And this is the biggest weakness. And, you know, again, there are, as Patrick mentioned, there's, I think it's called Speedy—S-P-D-I—which is an HTTP replacement that Google Chrome has built into it. And there's, you know, other, you know, WebSockets and things like that, which are trying to sort of alleviate this problem. But, you know, for 99% of the web developers out there, this is, you know, this is a major weakness of using HTML.
Yeah, and so the way the user would see that, though, is it's going to be latency. So the time you hit enter to the time they can browse your web page. And you want that to be as short as possible because if it's too long, we all remember the days when the transfer speed, you know, just the bandwidth to transfer all the images and text took a long time. Now we—I won't say we've completely gotten past that, but now we're running into other bottlenecks which are becoming meaningful portions of the time to load a web page like these things.
Yeah, and I mean, even just if it's not, you know, many seconds like it was back when we had modems, we still have this issue where because, you know, each thing is a different request, you might go to a site and it might have, let's say, 30 images in it. But they all load at different times. And so there's like a second or so where you're just getting all these weird things shifting around and your browser is just, as it gets all the images, it just sort of does something crazy. And again, there are ways around this, but, by default, HTML and CSS, this is a big weakness.
Once you start adding layers to fix some of these weaknesses like add interactivity and try to add animations, those kinds of things, you start to run into the fact that although it was a strength that HTML is cross-platform, you also have the fact that people are running browsers that are 10 years old and eight years old. And I saw a really good graph about this once for each of the major web browsers, how many people are still using old versions. But corporations don't necessarily want to roll up the latest and greatest thing because it's an unknown. You've got your grandmother who doesn't know how to update her Internet Explorer. And so if Windows doesn't tell her to do it, she's not going to do it. And so you've got people using really old browsers which may have bugs or problems. And so you can get, as you build up complexity, you get all these weird rendering issues and you have to check compatibility across more than just four or five, probably 10 or 15 different browser and browser version numbers to really if you want to make sure you get all of your users the same experience.
Yeah, so it's not uncommon for a web developer to use VirtualBox, which I think we talked about VirtualBox as one of the tools of the bi-week. Yeah, yeah, yeah. So it's not uncommon to have VirtualBox with, you know, a Windows XP machine with IE6, a Windows XP machine with IE7, Windows XP machine with IE8, et cetera, et cetera. And to have all of these virtual computers all with different virtual browsers and to try your website on all of them and see what happens. It's not uncommon. Actually, it's almost guaranteed that you'll write a website with, you know, with Chrome or with Firefox or with Internet Explorer in mind. And then you'll go to one of the other browsers and it won't look right. I mean, something will look different. Maybe the text is just big enough where it causes everything to sort of collapse further down in the page. And you'll have to go in and make tweaks. You'll have to say, you know, in your CSS, you'll have to say, 'If this is IE8, do this.' Or in your HTML, you'll have to write some JavaScript that says, 'You know, if this is, you know, Chrome, you have to make this setting. Otherwise, make that setting.' Yeah.
There are some tools out there to help with those kinds of things. Like I know there's some services cropping up to have a bunch of basically, like you said, VirtualBox instances where they run your website and then send you pictures of all of the results or pictures of the ones that they've detected to have rendered differently.
Yeah, I mean, it's genius. Because that way they just have the virtual boxes up all the time. Mm-hmm. And they just, as soon as you give them a website, they go and visit it. So it's really cool. Yeah, I guess the only other weakness I can think of is just the verbosity, right, of HTML. So, you know, when the HTTP protocol does have compression standards built in. So it will automatically compress your HTTP content before it sends it over the wire. So you don't have to worry about doing that. But even in compressed form, you know, it's a description of what the webpage should look like. And so the tags are very verbose. And, you know, you're having a lot of these opening and closing tags all over the place. So you might want to just, you know, have a little table with some text in each of the cells. And you might, if you're writing it in C or something like that, you might just say, look, at this position, put this text. At this position, put that text. But because you're writing it in HTML and it has to sort of conform to all these browsers and it has to look nice on all these different computers, you have to be sort of very generic and say, 'I want this table,' and 'I want this row and column.' And it ends up becoming very verbose.
Yeah, and not only in, you know, data overhead of sending all that redundant information across, but trying to fix a problem and go through, you know, all of these tags and parameters and stuff to try to find where the problem might be can be a little overwhelming. If you're trying to debug, like, a static HTML page by hand or trying to debug the output of, you know, a machine-generated HTML page.
Yeah, I mean, a lot of people say that the, you know, the modern internet was built on the back of Firebug, which is an extension, or maybe it's built into Firefox. I think it's a plug-in. Oh, okay, still an extension. Yeah, but they, you know, what it does is it will actually, you can click on something while you have this Firebug running and it will sort of show you what the HTML is. Because you might have a program, as we mentioned, generating HTML on the fly. And let's say you had a bug in that program. Your output is just going to be a bunch of HTML. So you might end up with garbage HTML or you might end up with lines being colored red, even though they shouldn't be. And this Firebug lets you sort of go inside and say, 'What does this HTML look like at this particular spot?' So I think Chrome has something similar called Inspector, which is built into Chrome. You can just right-click and say Inspect Element. And you can do this right now, even if you're using Chrome. And it'll sort of show you the HTML that was generated for that particular element.
Yeah, so HTML, CSS—I mean, the technology started a long time ago, but it's still very applicable to today. It's still used. It's the language of the web. And although it may not be directly a programming language, certainly it'll be a valuable experience for our listeners to learn some more about it.
Yeah, definitely. I mean, I think that the Internet is really, you know, they always say, I think Larry Page is quoted as saying, 'Never bet against the Internet.' And what he's insinuating is that the Internet is really, because of the way it's just so distributed in nature and the way you can broadcast content out to hundreds or thousands or millions or billions of people, it's really just an amazing medium for getting information out there. And so this is HTML and CSS are your paintbrushes and pencils that you use to sort of create in this medium. So this is the first of two, you know, podcasts on this topic. In the next show, we'll talk about JavaScript, which is a way to sort of add dynamic content and make your page change on the fly. But yeah, I mean, this is definitely where it all started and this isn't going away. You said next episode. Next episode is going to be episode number 10. That's right. It's a milestone. The double digits. Pretty awesome.
Yeah, it's been enjoyable so far. You know, typically wrap up the show talking about how things are going. So like I said, we've gotten some people following us on Google+. That's been really nice and encouraging and awesome. Hopefully we can get a dialogue going there. As always, make sure you can visit the blog for show notes and, you know, able to download the podcast there as well. And that's programmingthrowdown.blogspot.com. You can also email us at programmingthrowdown@gmail.com.
Yeah, I mean, if you have any, you know, questions or, you know, feedback on the podcast or if you have any programming questions, you know, let's say you want to know about something in particular like game design or you want to know about, you know, data structures. I don't know, anything that kind of like piques your curiosity and you want us to sort of elucidate more information on. That is not a problem. So, yeah, we're definitely, you know, there's no shortage of programming languages as I'm sure you guys know out there by now. But if there's a particular one that you're interested in that we haven't covered yet, definitely shoot us an email and let us know. Yeah. Well, if that's it, I guess we'll wrap it up. Thank you all for listening. Yeah. Have a good week. The intro music is Axo by Bynar Pilot. Programming Throwdown is distributed under a Creative Commons Attribution Sharealike 2.0 license. You're free to share, copy, distribute, transmit the work, to remix, adapt the work, but you must provide attribution to Patrick and I and share alike in kind.
