Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Styling the home page, pt. 1

From: WordPress 3: Creating and Editing Custom Themes

Video: Styling the home page, pt. 1

So, we're ready to start styling the main-content area of our homepage. Now, we're going to do a little bit of prep for this. Because we're going to be styling this area of the homepage, it's likely that the CSS that we're using to style this is unique to the homepage, in that the CSS doesn't need to be loaded when we make these other pages. It's kind of unique to the homepage. So, I'm going to make a new CSS file in our CSS folder of our project that I have open here in TextMate. I'll call it home.css and then in our index file, I am going to load that up with another style sheet and I'll just make a note here and a comment that says only load on homepage, in case we choose to do that later.

Styling the home page, pt. 1

So, we're ready to start styling the main-content area of our homepage. Now, we're going to do a little bit of prep for this. Because we're going to be styling this area of the homepage, it's likely that the CSS that we're using to style this is unique to the homepage, in that the CSS doesn't need to be loaded when we make these other pages. It's kind of unique to the homepage. So, I'm going to make a new CSS file in our CSS folder of our project that I have open here in TextMate. I'll call it home.css and then in our index file, I am going to load that up with another style sheet and I'll just make a note here and a comment that says only load on homepage, in case we choose to do that later.

So now both of these CSS files will be affecting this page in the browser. So, let's take a look at the Photoshop file and what we're trying to match. I'll zoom in a little bit so you can see what's going on. We have this paragraph here, and this blockquote here. So, we're going to start with that. I can notice a few things in the browser right away. Font size is too big. It's too close to the header. It's too close to the edges over here, and the quote has no styling at all. So, there is a number of things that we're going to need to accomplish here.

So, let's take a look at the HTML for that area in our index.html file, and here is the header and here is the main-content area. It's these two things that we're trying to style. We have the foresight here when we wrote the HTML that we gave this "intro" paragraph an id of "intro," just thinking that it might be a little different than other paragraphs on the site. Probably will be. So, if we go into our home.css file, we can target that intro, and take care of that spacing issue.

We could give it a top margin and bottom margin. Now, when you only give margin two parameters like this, the first one means top and bottom and the second one means left and right. So we want 20 on the top, 20 on the bottom. That's going to work for us, and the line-height here, it's pretty tight with the line-height. I want to make the line-height 2. And you notice I didn't put like 18 pixels or something there. If you don't give it any kind of unit like pixels or ems or whatever else, it's a multiplier then.

So it's going to be twice as high as what the font size for that is. The font size is also a little big, and we can go ahead and change it right here. We can go 12 pixels where we will make it a bit smaller, but I'm starting to think we're doing that a lot and maybe we should set the default font size on our page to 12 pixels, so that'll just kind of be the default size, and anything we want to adjust, we can do it individually from there. So we can do that in the style.css file on the body itself.

So, if we change that to 12 instead of 14, it's going to cascade down to this paragraph and that will be 12 pixels. So, let's see how we're doing in the browser. So, the font size is smaller. The lines are spaced out a bit. It's properly distanced from this top line. It's still pretty tight over here though, but we can see scrolling down the page that everything is too tight to that edge over there. It's kind of uncomfortable. Over here, we space things in about 30 pixels from that edge. So let's get that same 30 pixels over here.

Now, we could do it right on this paragraph, but the problem is all the way down, so we might as well deal with it on the container itself. Go into the style.css file and that's the main-content div. So it's this here. I'm going to add some padding on the right of it. So, padding, and it's like a clock. Top, 30 pixels on the right, and then none for everything else. When we do this, we're actually expanding the width of the overall box. I know it says width of 500, but the overall box in the browser is now going to be 530 pixels.

We got to be just conscientious of that, and I'll make it 470 pixels here to compensate for that padding that we just added. So, when I reload here, we'll get that spacing, but the overall box size kind of stays the same. Now, this isn't quite lined up with the W, how we might want it to be. So, I can squeeze that over to the right a little bit just by reducing the width of the main-content area. Just maybe make it like 67 or something, and that's going to squeeze over to the right and line that up nicely.

It's also a bit too long. Now, I know this is just fake text, but when we ultimately show this to our client and they're replacing fake text with the real text, it's going to give them a queue for how much text they should write. So let's remove a little bit of that text and we can just remove a bit. Not scientific here, just so we get down to about four lines of text. Looking good. Now we have to now we have to deal with this blockquote. Let's take a look in Photoshop at what that looks like. It's this, and remember we wrote it into our HTML literally with text. We gave it this id of "main-quote".

Now, this is going to not force it, but it just is accessible and semantic. It's the right way to do a blockquote, even though we're actually going to make this an image in our actual design. So, let's get a nice crop of this. I'm going to Save for Web & Devices. I'll make mine be a PNG-8, just when you're ever doing this, saving for Web & Devices, make sure that you're looking at the file size, making sure that it's not enormous, like if they said 200K down here.

That's just too big for an image of this size. But 20K is probably fine here and that it looks okay. It doesn't look blurry or have little aberrations anywhere. Now, I'm going to go ahead and save that out to our working directory. We'll call it mainquote. Okay. Now, in our CSS file, we have that id. That id again is coming from the id that we put on it, main quote, "main-quote", and we're going to put it in our home.css file, because that's specifically from the homepage, so main-quote.

We'll give it that background of the image that we just cut out, so I'll make sure that we don't want it to repeat. Now, just to verify, you've got to check our work at least once in a while here. We're going to go out to the Desktop, look in our working directory and make sure that we have it named exactly right, mainquote, no dash in there. That's perfect. Now, we're going to check on the dimensions. 475 pixels wide, 188 pixels tall.

Now, the trick here, what we're doing here, normally this would be a box. This is going to be a box. We gave it the size that we wanted to. It's going to have a background, but you'd be able to see this text right over it. What we're doing is actually replacing this text. So we're going to use a little trick here and just kick the text off the page, so you can't see it. With a large negative value, we'll kick it right off the page. So, let's reload and see what we got. Awesome! We got the image in there.

Now, it's not lined up exactly right. In our design, there's no gutter over here. So, let's remove that. We can do that with a little-- I guess left padding or left margin will kick that over just how we wanted to, and we should push this stuff down a bit as well. So let's say margin, none on the top, none on the right, maybe 20 pixels on the bottom, and we'll try 20 pixels on the left. See how that goes. Really close, maybe two more pixels on the left, and it's going to line up perfectly against that edge.

So, our homepage is looking okay. We just have a little bit more work to do on the homepage, which we'll do next.

Show transcript

This video is part of

Image for WordPress 3: Creating and Editing Custom Themes
WordPress 3: Creating and Editing Custom Themes

40 video lessons · 50808 viewers

Chris Coyier
Author

 
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 7s
    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

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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.

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

Congratulations

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

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


OK
Become a member to add this course to a playlist

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

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

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:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com 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 lynda.com.

Sign up and receive emails about lynda.com 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.