Build Your WordPress Home Page with HTML

show more Writing HTML code for the home page provides you with in-depth training on Developer. Taught by Chris Coyier as part of the WordPress 3: Creating and Editing Custom Themes show less
please wait ...

Writing HTML code for the home page

Let's start writing the HTML for this design. When I say let's write the HTML, I mean let's focus ourselves entirely on that one task. We're going to open our Photoshop file that we ended up with here on the left and I am going to open the project file, the index.html file, here on our right. So what we're going to be doing is looking at what's going on here on the left and writing what we see on the right in our project file. That's going to keep us as semantic as possible. You've heard the word semantic be used in web related discussions, they are generally talking about HTML and they're talking about how well you've described a website with HTML tags.

So very semantic means you've done a good job with that and non-semantic means that the HTML tags you're using don't make sense together with what you're looking at. Most of our content exists in this big white block here. So we are going to need a div for that. I am going to say div with an id of page wrap. just an element that wraps our entire page. We're going to start with that. Then we'll start at the top here, we've got this logo. We've got Widget Corp here, and this Established 1987 here, all this I can see being grouped.

We'll use the HTML tag header. I am going to press Command+Option+ Period to auto close that tag in TextMate and then we have a logo. Now, I am kind of seeing this as a separate entity, so I am going to say div with an id of logo, and probably not put anything inside it. We might put Widget Corp inside it if it was the logo and the type together, but it's kind of a separate entity over here. I am going to let Widget Corp actually just be an h1 tag. So Widget Corp, close that tag, and then we'll just have a paragraph up here in the header for Established 1987.

Now, there is that letter mark up here. We can do that with CSS. That doesn't need to be content necessarily. So there is our header. Underneath the header we have this paragraph here. But I'm thinking we should separate everything that we can see on the left here and everything that we can see on the right, so this is main content and this is our sidebar. That makes sense to me to kind of do it that way. Let's start with the main content first. That's more important. It should be above the sidebar. So we'll say div with an id of main content. Close that out.

Now, in the homepage here we have that intro paragraph. So I am going to make a paragraph tag. I can think though, just thinking ahead a little bit, that this might want to be styled differently than other paragraph tags across the whole site. So I'll give it an ID if intro just in case later on we'll have a CSS kind of hook there then to style that differently if we want to. Now, this is just Lorem Ipsum, just kind of generic filler text. We can get that in TextMate by just typing lorem, Tab. That's just going to fill that with a bunch of Lorem Ipsum text for us.

Now right below that we have this quote. "We are able to do the work we do because of the quality of these widgets." That's a quote. It's a blockquote. I can think probably we're going to end up replacing it with an image. Well, that doesn't mean we shouldn't use the proper tag for it. So I am going to say blockquote and then within it I am going to say, "We are able to do the work we do because of the quality of these widgets," and we'll close that blockquote but it also says Frank James from the Tick Tock Corporation.

So the semantic way to cite a blockquote is the cite tag. So we'll say Frank James, Tick Tock Corp, and close that tag. So we're looking good there. Now, blockquote, we already know that they are interested in blogging and writing their own articles. It's pretty common to have a blockquote in a blog post. So this is going to be different than other blockquotes on the site. So we'll say this is an ID of like main-quote here or something.

So we can get our hands on it uniquely without affecting other blockquotes in the future. Now below that blockquote says Featured Widgets. That's a header but it is one level deeper than Widget Corp here. So we'll say h2, Featured Widgets, close that tag, then there is these two featured widgets. Now I am feeling like they should have a relationship to each other. There should be a tag that encompasses both of them if we can. There is probably a number of different ways we can do it but let's just make it an unordered list. So it's like a list of widgets.

That's fine I think. An opening and closing list tag for the first one, and then let's describe what we're seeing. We're seeing a title, a description, an image and a View Product button. So let's try that. Now we are one level deeper on headers again. So we'll make an h3 tag. Call this the Super Sprocket 1000. There is a description in there. We'll just use some Lorem Ipsum text there again, and we're seeing an image. So we'll say image equals, now with the source of. Now where we're going to put these? It will probably be somewhere like product-images.

We're just making some decisions. I am not sure if this is actually where we'll put them. We're just kind of making the call right now as we are writing this HTML. Super Sprocket 1000. We'll probably have an alt text of product image or something like that, and then there will be a button, an anchor link, so A with an href, we're not sure where it's going to go yet. We'll just put a hash tag. And it looks like a button. I am thinking if there is a link in this text over here or there is a link in this text over here, it's going to be different than this, but they're all just regular As, regular anchor links but this one looks differently.

So let's give it a class of Button. So anywhere we want to have a link look like a button, we'll just style this class of button. So View Product. Now, there are two of these. So I am just going to go ahead and copy and paste, paste that in there, but the name is going to be different. Triple Spunkler, and the image path will be different. But mostly, it's going to stay the same here.

So that's the main content. We just wrote all of the HTML for that. Now after the main content we're going to have this sidebar. Now where should we start the sidebar? It's already getting a little confusing down here because I am not sure should I start here or here? I do remember that the first div that we opened up was the page wrap. So let me make a note here that says this is the end of the page wrap. Just keeps us more organized down here. And then what's this div? Well, it's the end of the main content. So let me mark that just so we know what's going on.

So after the main content, but still within the white page wrap area, we're going to have a sidebar. In HTML5, it's often called an aside. So within that, it starts out with a navigation. HTML5 has a tag for that, nav, and there is going to be an unordered list within it. So we'll make an unordered list, and it's going to have, we're looking at four different links here. So let's make four links. In TextMate, I can hold the Option key and drag up and select multiple lines.

pretty neat little trick. Now I can write on four lines all at once. Pretty cool! If I click away, I am all out of it. Now, each one of these will have a different name like Buy Widgets, About Widget Corp, Contact Us, and The Grind. Oops. I put that in the wrong place, didn't I? Now, it has that little "Our Blog" part in there.

I'll just use an em tag for that. em meaning emphasis, but often italic text as well. Now, notice that there are different colors. Should we put a class name on this that says blue? No, that would not be semantic, because what if we wanted to change that color later and we wanted the first one to be green instead? Well, then our class of blue is going to be green. That's going to be weird. We could put class of Buy Widgets here and make it blue with that. But then if we move Buy Widgets down here, it could screw up our color scheme.

We're really not going to apply classes at all to it, knowing that we can use CSS actually to target each one of these in their position and affect their color that way. So that's what we are going to plan to do there. Just two more areas to mark up quick. It's this area, the Latest Posts and this area, the Industry News. So we'll make divs for those. We'll call them widgets. Why not? Thinking of, in the WordPress world, I just happen to know that when you drop things in your sidebar they are often called widgets.

Now this is a header, Latest Post, but we've already made it down to h3, which was Super Sprocket 100 here. So let's make this h4, and we'll say Latest Post. Let's put a div there and we'll have a class of date, because that's what we're looking at here is just a date and we'll say March 16th, 2010. Close that. Then there's another title. We've made it all the way down to h5. h5 and it says, "This just in: Don't get gremlins wet!" Super important advice. And we have some Lorem Ipsum text there. One last time.

So this is the end of a widget. That's that one more and we can kind of copy and paste this except for our widget here. There are two things inside this widget. So we'll just copy and paste everything from the date down, we'll do again. Maybe I'll just have a different date and we'll have a different title like "This is another blog post" down here or whatever.

We've made it all the way. Very one last thing is that there is actually two little bits of text down here and it's outside of this white box. It's the footer area. So we're going to put it after the page wrap. We're going to call it footer, HTML5 tag there. There are two things in there. It says "One wheel turns another" on the left, and it has the copyright on the right. So we could do something like div id footer-left or something like that, but again that's one of those things where it's not very semantic because what if we wanted to flip-flop these? Then our left class is really on the right, and our right class is really on the left.

That doesn't make sense. Let's describe it better and say there is an id of quote and then we'll say, One wheel turns another, and we'll have copyright. So if we want to apply float-left and float-right for example in our CSS later, we can do that, flip-flop them around, and it stays just as semantic. So, Copyright 2010 Widget Corp. So that's it.

We've done it. We've written all the HTML for this entire page that we're looking at, really focused. That's why we wanted to do it this way. Just for fun we are going to open this quick in a browser. So let me close this. I am going to open up that HTML file that we just finished writing in the browser so we can look at it and wow! It doesn't look like much, does it? But that's okay. This is what we're expecting to look at. This is what like a search engine would see when it reads your site. This is what someone with sight disabilities would see when they are looking at your site, and it all makes perfect sense.

Widget Corp and the tagline for the company, and introduction text right into the Featured Widgets. This is exactly what we want to see and a great base for us to start styling.

Writing HTML code for the home page
Video duration: 12m 6s 4h 28m Intermediate


Writing HTML code for the home page provides you with in-depth training on Developer. Taught by Chris Coyier as part of the WordPress 3: Creating and Editing Custom Themes

Developer Web
please wait ...