Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Writing HTML code for the home page

Writing HTML code for the home page provides you with in-depth training on Developer. Taught by Chri… Show More

WordPress 3: Creating and Editing Custom Themes

with Chris Coyier

Video: Writing HTML code for the home page

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
Expand all | Collapse all
  1. 6m 44s
    1. Welcome
      1m 19s
    2. Using the exercise files
      5m 25s
  2. 40m 42s
    1. Reviewing the client spec and deciding on WordPress
      6m 50s
    2. Reviewing assets and resources and creating a mood board
      8m 41s
    3. Building a home page mockup
      11m 26s
    4. Finishing the home page
      12m 27s
    5. Planning the rest of the site
      1m 18s
  3. 1h 8m
    1. Starting with a base project
      3m 6s
    2. Writing HTML code for the home page
      12m 6s
    3. Starting the CSS: Creating the header and basic style structure
      11m 28s
    4. Styling the Navigation panel
      10m 59s
    5. Styling the sidebar
      7m 55s
    6. Styling the home page, pt. 1
      8m 20s
    7. Styling the home page, pt. 2
      8m 17s
    8. Finishing the CSS
      3m 14s
    9. Moving on: One page is enough
      2m 43s
  4. 1h 56m
    1. Setting up WordPress and MAMP on a Mac
      6m 7s
    2. Setting up WordPress and WAMP on a Windows computer
      5m 38s
    3. Modifying important settings
      6m 26s
    4. Starting with a blank theme template
      4m 35s
    5. Introducing template file structure
      4m 55s
    6. Breaking up the HTML
      9m 53s
    7. Building the sidebar
      3m 54s
    8. Building the navigation
      7m 20s
    9. Showing one recent post
      4m 1s
    10. Fetching external content
      8m 23s
    11. Creating a custom home page
      3m 30s
    12. Introducing custom fields
      5m 23s
    13. Creating custom product pages
      9m 52s
    14. Creating custom category pages
      15m 39s
    15. Creating the blog home page
      5m 39s
    16. Creating a single blog entry page
      4m 15s
    17. Implementing comments
      5m 57s
    18. Finishing the home page
      4m 45s
  5. 34m 17s
    1. Will this work with WordPress?
      3m 10s
    2. Using JavaScript in themes the right way
      8m 35s
    3. Implementing something fun with JavaScript
      7m 53s
    4. Introducing plug-ins
      6m 31s
    5. Setting up security
      8m 8s
  6. 2m 7s
    1. Goodbye
      2m 7s

please wait ...
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

View Course Description

In WordPress 3: Creating and Editing Custom Themes, author Chris Coyier shows how to build a custom WordPress theme from scratch and satisfy common client requests. The course covers steps necessary to build a theme using a complete workflow with Photoshop, HTML, CSS, and WordPress 3.0. Also included are tutorials on enhancing a WordPress site with JavaScript, using plugins, and ensuring site security. Exercise files accompany the course.

Topics include:
  • Building a design in Photoshop
  • Converting Photoshop design to HTML and CSS
  • Setting up MAMP on Mac and WAMP on Windows
  • Moving HTML and CSS into a WordPress theme
  • Building navigation
  • Using custom fields
  • Creating a commenting system
  • Using JavaScript and plugins
Developer Web

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.

Find answers to the most frequently asked questions about WordPress 3: Creating and Editing Custom Themes .

Expand all | Collapse all
please wait ...
Q: What prerequisite skill do I need to be successful in this course?
A: This course is set at the intermediate/advanced level. You’ll do best if you have a good knowledge of Photoshop, plus a good grasp of PHPHTML, and CSS.

Q: The index.php file that the author is working with in Chapter 3 doesn't match mine after the "Building a sidebar" movie. It appears to change between the "Building a sidebar" and "Building the navigation" movies. What code am I missing?
A: The author makes some changes off screen between several movies in this title, simply because there is so much material to cover. These changes are provided in the exercise files.

However, if you are following along without the exercise files, you catch up to him by adding the following code to your index.php file, directly after the <?php get_header(); ?> line:

<div id="main-content">

Near the end of the file, just before  <?php get_sidebar(); ?>, add a closing div tag, </div>, to complete the div wrapper.

The resulting code will look like so. You may also copy and paste this into a new file and save it as index.php.

<?php get_header(); ?>

<div id='main-content'>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

        <div <?php post_class() ?> id="post-<?php the_ID(); ?>">

            <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>

            <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>

            <div class="entry">
                <?php the_content(); ?>

            <div class="postmetadata">
                <?php the_tags('Tags: ', ', ', '<br />'); ?>
                Posted in <?php the_category(', ') ?> |
                <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>


    <?php endwhile; ?>

    <?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>

    <?php else : ?>

        <h2>Not Found</h2>

    <?php endif; ?>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

Q: How do I load my custom theme once I have finished?
A: Copy the Custom theme folder to your new WordPress installation and put it in wp-content > themes. Then you can activate the new theme and work with it from there.





Don't show this message again
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed WordPress 3: Creating and Editing Custom Themes.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a Member and Create Custom Playlists

Join today and get unlimited access to the entire library of online learning video courses—and create as many playlists as you like.

Get started

Already a member?

Log in

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

You started this assessment previously and didn’t complete it.

You can pick up where you left off, or start over.

Resume Start over

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.