WP Theme Lesson #12: Post Formatting and Miscellaneous

tutorial-series.gif Follow this WordPress Theme Tutorial Series from the beginning.

You don’t need index.php today. Open Xampp Control, theme folder, Firefox, Internet Explorer, and style.css.

Before we start, forget yesterday’s screenshot that I showed you. I had the widget plugin turned on while taking the screenshot, which explains why my sidebar looked different from yours. Also, in the style.css file, change all Sans-seriff to Sans-serif. My mistake again, I tend to add an extra ‘F’ to Sans-serif.

Step 1

Get rid of most margins and paddings by typing the following codes above the body{} in style.css:

body, h1, h2, h3, h4, h5, h6, blockquote, p{
margin: 0;
padding: 0;
}

  • Notice that it’s margin: 0; instead of margin: 0 0 0 0;. When all your values are the same, use one number. Same goes for padding.
  • Save your file. Refresh Firefox and Internet Explorer. Don’t worry, now you’ll add in the margins and paddings where you actually want them to appear, and not where the browsers want them by default.

By the way, I’m telling you to put this and that under or above this or that, but know that it’s optional. You can type/place your codes anywhere. The way I’m doing it is how I organize.

Step 2

Style H1 title, type this under the body{}:

h1{
font-family: Georgia, Sans-serif;
font-size: 24px;
padding: 0 0 10px 0;
}

  • font-family: Georgia, Sans-seriff; changes the H1 title front from Arial to Georgia. Without Georgia, the web page looks for Sans-serif;
  • font-size: 24px; is self-explanatory. However, notice that when you set the font size to 12px within body{}, the H1 and H2 tags didn’t follow that rule. That’s because heading tags follow their own rules. To control them, you need to style specifically for them.
  • padding: 0 0 10px 0; means 10-pixel bottom padding. It’s for adding space between your blog’s title and description.

Save, refresh, and here’s the result:

h1-styled.gif

Step 3

Type the following codes under #container{}: (Save and refresh after each block of codes to see what the changes are.)

.post{
padding: 10px 0 10px 0;
}

(You added 10-pixel top and bottom paddings to each DIV with a class named, post.)

.post h2{
font-family: Georgia, Sans-serif;
font-size: 18px;
}

(.post h2 is not a general rule. It specifically targets the H2 sub-headings within the post DIV. The H2 sub-headings in the Sidebar aren’t affected.)

.entry{
line-height: 18px;
}

(Increased the size of the space between each line within the entry DIV.)

Step 4

Type the following codes under a:hover{}:

p{
padding: 10px 0 0 0;
}

(10-pixel top padding to each paragraph tag.)

Step 5

Type under .entry{}:

p.postmetadata{
border-top: 1px solid #ccc;
margin: 10px 0 0 0;
}

Remember the pargraph tag that you gave a class named, postmetadata, to? Styling a specific paragraph tag and styling DIV are very much the same. You can apply border, margin, padding, and background to both.

For the postmetadata paragraph tag, you added a gray border and a 10-pixel top margin to it.

border-top means top border only. border-left means left border only. Etc. border, alone, without -top, -right, -bottom, or -left means all borders. For example, border: 1px solid #ccc; means all four sides have a gray 1px border.

Step 6

Type under p.postmetadata{}:

.navigation{
padding: 10px 0 0 0;
font-size: 14px;
font-weight: bold;
line-height: 18px;
}

For the navigation DIV wrapping the Next page and Previous page links, you just:

  • added a 10-pixel top padding
  • change its font size to 14px
  • change its font-weight to bold.
  • increased its line-height to 18px.

That’s the end of today’s lesson.

What's Next?
Related Posts
chris:

hmm …
why is p.postmetadata? y not use .postmetadta ony?

if you want to use postmetadata as a stand-alone selector then remove the P.

chris:

Big thanx for this tut SP :D

I notice you’re using px for font-size attributes.
Isn’t “em” supposed to be a better choice for this?

Gurdit - Em is harder to manage. Although detailed, this tutorial series is for beginners.

Siyabend:

Hello Small Potato. How can I add a logo to my blog? I tried to add an image to header division but it didnt worked. How can I add none database images into my layout? **By the way ,background-image works but I have already using background-image property for many tags.
Thanks .

If it can be a background image, do it. It’s better not to use inline images. If you must, look up the IMG tag to learn how to put in an inline image.

Riff:

Hello again, Mr Potato…

I’ve read most of your tutorials, but I didn’t find a way to customize the Read More.. how to cuztomize it?

And also i want to see the source of the function the_content(). Where is it placed?

Thanks

I don’t even know Riff. As for Read more, you can find it on WordPress.org if you look for the_content().

Riff:

Whoa…
Quick reply!!

Sigh..
All right, thanks..
Your tutorials are very great!!

Riff:

I’ve found it!

May I share it here, Mr Potato?
Everybody, if you want to customize the “More”, visit this:

http://codex.wordpress.org/Template_Tags/the_content

Hi, great tutorial. I’ve got this far but after this step of the tutorial my blog theme went down the pan.

As soon as I started messing with the padding and whatnot the sidebar dropped, the text seems to all float in the center, I even lost the link colors. What have I done wrong?

OK. I must have messed up this line of code:

h1{
font-family: Georgia, Sans-serif;
font-size: 24px;
padding: 0 0 10px 0;
}

I removed it, then typed it in again and it solved the problem. I’ll now continue. Great tutorial, I’m loving it.

jicoro:

best tutorial about wordpress theme in the whole world wide web..wowoweee

Eduardo Perez:

Hello,

First of all, this is ‘A GREAT TUTORIAL’. you make it look so easy !!!!.

I just have one question about this lesson:

when I added ‘p.postmetadata’ (step 5) to show the top border; i don’t see it on IE7; just on Firefox.

I will double verify, to see if I made any mistake on the css or the index.php…..

Kudos! for your work!

Eduardo Perez:

Ohhh I see….

Changing p.postmetadata to .postmetadata actually works on both browsers…!!!..

I hope this helps to someone.

fzeix hvpwjakqd bilwksp ngmr mjta smkiyd ablrksn

SP,

Once again I’d like to thank you for this tutorial. You have a great teaching style. You are very knowledgeable of the topic and you’re very enthusiastic. I can tell you had a lot of fun putting this together. This makes it very easy for students like me to learn.

Thanks again.

Ethan

Some Hume:

for p.postmetadata

How is the #ccc of border-top interpreted? I played around with it a bit an can’t figure out how it becomes gray.

Instead of typing every element in, like body,h1,h2, etc.., just use *, which selects everything.

[…] #8 How to Validate #9 Style.css and CSS Intro #10 hex Codes and Styling Links #11 Widths and Floats #12 Post Formatting and Miscellaneous #13 Styling Sidebar #14 Footer and Dividing Index #15 Sub-template Files #16 Comments […]

JohnPL:

i have problem with that part:

.post{
padding: 10px 0 10px 0;
}

we have added, using php, an individual digit to each post

<div class=”post”>

so how that CSS definition can works? how to name that class properly to fix it?

gordon brown:

I’ve said it once and I’ll say it again, BEST WORDPRESS TUT EVER!!!

Alistair Nel:

Shot buddy!!
When u get to this part of the tut thats when u start jumping around the room
-|!.L.E.D.G.E.N.D.!|-

Matt:

Great tutorial. Thanks!

[…] #8 How to Validate #9 Style.css and CSS Intro #10 hex Codes and Styling Links #11 Widths and Floats #12 Post Formatting and Miscellaneous #13 Styling Sidebar #14 Footer and Dividing Index #15 Sub-template Files #16 Comments […]

Haico:

Thank you very much for this tutorial! It’s very clear to me. Thanks!

headjog:

hi

thanks for this SP - very clear and helpful.

a quick point :

“By the way, I’m telling you to put this and that under or above this or that, but know that it’s optional. You can type/place your codes anywhere. The way I’m doing it is how I organize.”

be aware though that in css the last instance overrides any previous instance

e.g. if you put the css for removing all margins and padding from everything (body, h1-h6, blockquote, p) *at the bottom of the stylesheet* it would override any other values already set (try it and see0. it needs to go at the top of the stylesheet so that all values start out as 0 and any subsequent value changes have their intended effect.

here’s a great css resource, esp for newbs: http://www.sitepoint.com/subcat/css - their books are good too (and no i don’t work there ;)

thanks again

Reply
Comment Policy
  • Theme support questions should be posted at the support forums.
  • Name and Email are required. Email is never published.
  • You grant this site perpetual license to reproduce your words and name/website in attribution.
  • Inappropriate comments will be removed at my discretion.
Close
Powered by ShareThis