Tutorials

Latest Word » Tutorials » Styling Post Headings That Stick Out
Styling Post Headings That Stick Out

Styling Post Headings That Stick Out

Tags:

Recently, I’ve noticed a trend in blog post headings where it sticks out of its base layout. I would like to share this technique for those who would like to give their post headings a new style. One tip to keep in mind when designing this is to make sure it fits your target audience screen resolution size.

Note that this technique may vary depending on your design. My goal is for you to grasp the main concept in this tutorial so you can experiment and apply it to your own projects.

Post Heading That Sticks Out

Step 1. Wireframe – HTML

Start by visualizing the wireframe of how each post item will be laid out.

<div class="post">
	<div class="postheader">
		<!--Post Header Elements Goes Here-->
	</div>
	<!--Post Content Goes Here-->
</div>

Step 2. Styling Wireframe – CSS

Each post entry will be wrapped within the .post class. Since we are using absolute positioning on the .postheader, be sure to add enough top padding on .post so the post content does not overlap with the heading.

Post Heading That Sticks Out

.post {
	margin: 0; padding: 110px 20px 20px;
	float: left;
	width: 560px;
	position: relative;
}
.post .postheader {
	background: url(postheader_bg.gif) repeat-x;
	float: left;
	width: 600px;
	position: absolute;
	left: 0; top: 0;
}

Step 3. Post Header Wireframe – HTML

Now we’ll look closer at how each element will be placed within the .postheader.
Post Heading That Sticks Out

<div class="postheader">
	<span class="date"><strong>Oct</strong>25 <small>2009</small></span>
	<h2><a href="#">Styling Blog Post Headers with CSS</a></h2>
	<a href="#" class="comments">25</a>
	<p>
		<span>Category: <a href="#">CSS</a> | Tags: <a href="#">Headings</a>, <a href="#">Tutorials</a></span>
		By <a href="#">Soh Tanaka</a>
	</p>
</div>

Step 4. Styling Post Header – CSS

Date Style
The part that sticks out of the layout is the date. Set the positioning to absolute and pull it back -50px to the left.
Post Heading That Sticks Out

.date {
	background: url(date_bg.gif) no-repeat;
	width: 46px; height: 57px;
	float: left;
	padding: 3px 5px 3px 0;
	text-align: center;
	font-size: 1.8em;
	position: absolute;
	left: -50px; top: 0;
}
.date strong, .date small {
	font-size: 0.5em;
	text-transform: uppercase;
	display: block;
}

Comments Style
Similar to how we styled the date, we will use absolute positioning to push the comments block -10px to the top and -10px to the right.
Post Heading That Sticks Out

a.comments {
	position: absolute;
	right: -10px; top: -10px;
	background: url(comment_bubble.gif) no-repeat;
	width: 34px; height: 39px;
	padding: 7px 0 0;
	text-align: center;
	color: #fff;
	font-size: 1.6em;
	text-decoration: none;
}

Level 2 Heading Style
Since the comments area is bleeding over on top of the heading, make sure you have enough padding on the right side so it does not overlap. Set height and line-height to match so it can be vertically aligned. For those browsers that support text shadows, we can add a nice touch of letter press style using the text-shadow property.

.post .postheader h2 {
	margin: 0; padding: 0 25px 0 10px;
	font: normal 2.2em Georgia, "Times New Roman", Times, serif;
	height: 62px; line-height: 62px;
	text-shadow: 1px 1px 1px #cfeb7f;
}
.post .postheader h2 a {
	text-decoration: none;
	color: #222;
	display: block;
}

Auxiliary Information Style
The aux information will be wrapped in a paragraph tag. To accommodate for the background image, be sure to add 60px padding to the left. For the category and tag information, wrap it in a span which will be floated to the right.

.post .postheader p{
	font-size: 0.9em;
	background: url(author_bg.gif) no-repeat 10px bottom;
	height: 27px; line-height: 27px;
	margin: 0; padding: 0 10px 0 60px;
	color: #fff;
}
.postheader p a {color: #fff;}
.postheader p span {float: right;}

Post Heading That Sticks Out

Conclusion

Now that you know how this technique is achieved, check out some of the sites below for inspiration! If you have any questions, suggestions, or concerns, please don’t hesitate to let me know.

Usability Post
Post Heading That Sticks Out

Line 25
Post Heading That Sticks Out

Noupe
Post Heading That Sticks Out

From the Couch
Post Heading That Sticks Out

Koodoz
Post Heading That Sticks Out

Web Designer Wall
Post Heading That Sticks Out

Branded 07
Post Heading That Sticks Out

Related Posts

Author Bio

My name is Soh Tanaka and I am a Los Angeles based designer/front-end developer specializing in CSS driven web design with an emphasis on usability and search engine optimization. I also run a CSS Gallery which is updated daily with the best CSS websites from around the world. Come check it out!

You can learn more about me or Twitter  Follow me on twitter for more updates and resources!

Did You Enjoy This Post?

subscribe  Subscribe via RSS or by email to get all upcoming tutorials and articles delivered straight to you.

+ Add Comment35 Peeps Have Spoken Their Minds...

  1. FeryKloucek

    Nice tut again! I was searching for this one! For me very useful!

  2. Janko

    Great tutorial, and nice to see some live examples.

  3. fstephany

    I know that the current trend is to ‘real time’ but when you google something and find a post from “Sep 23″ I find really annoying not to know of which year…
    So designers, please, include the year of the blog post.

  4. Helder

    Great!

    Thank you for sharing with us

  5. Famba

    Thank you very much for the really usefull post!!

  6. Dmitry

    fstephany: Sometimes leaving the dates may be intentional. I’ve seen a presentation from Tim Ferris where he talks about removing dates on individual posts, and showing dates only on the front page of the blog where you can see the recent posts. This way when someone arrives from a Google search doesn’t get put off from reading an old article since they won’t know it.

    Might work for sites where content doesn’t really ‘age’ fast. On the other hand, I remember searching for Ruby on Rails plugins and finding a bunch of release posts with the plugin but no date, so I couldn’t tell whether this was the latest and greatest or whether it would even work with the latest release of Rails. Definitely need the year on technology/development related posts :)

    P.S. Great post Soh! Thanks for mentioning my site.

  7. Benga

    Very in insightful, it’s good to see what sort of creative ideas are out there.

    Benga creative

  8. Sneh Roy

    ooh very nice! This will come in handy for all the tweaks going on over at my blog right now :) Thanks!

  9. b0li

    great post :)

  10. Bluemag

    Nice post, very useful for me!

  11. fstephany

    @Dmitry: I totally agree!

    Thanks for the post Soh, really useful!

  12. Robert

    Thanks for the tutorial, I found it very useful.

  13. rich

    Very nice post. you broke everything down nicely. Will probably have to use this!

  14. Hassan

    If the heading was too long then it goes over the content. Could we use relative positioning to get the same effect, still have it inside the document flow?

  15. Soh

    You can take off the height / line height from the h2, then it should flow more naturally. If you go this route, just make sure your background image is able to accommodate for the vertical flexibility. A little bit of tweaking and it should be good to go :-) Thanks for pointing that out!

  16. AnnC

    Fantastic !!!

  17. Joseph Dickinson

    Excellent post. CSS, is one of the best things in web development I have learned!

  18. Janek

    Link to this post goes into my “CSS Gems” bookmarks folder.

  19. kekaku

    谢谢分享!
    Thanks for sharing!

  20. kekaku

    Do you want to study Chinese?

  21. Saurabh

    Good Information.. gone through few example and not all but bookmarked the page/blog for future reference.

  22. Rasul

    very nice

  23. STEFi

    Very useful piece of code. As Hassan wrote the same problem occur when you have more than 99 comments.

  24. Edwin

    oh thanks soh!

  25. jots

    This is cooool :). Thanks …

  26. Liminal Web Design Cornwall

    Nice tutorial, it one of those simple design touches that really lift the blog. Thanks.

  27. Long Island Web Design

    very useful post…. but I want to know that… Is there any CSS property to make font smooth in IE?

  28. Ebnat Syukur

    nice tutorial. thanks a lot

  29. Jesse Dawson

    Well laid out and explained. One note: a few of your “inspiration” sites are using a much-simpler negative margin technique to achieve a similar effect. Not always a viable solution and, per usual, there are some IE6 caveats, but well worth mentioning.

  30. ALEXA

    Thank you for sharing all of this wonderful information.

  31. sadri

    This is very fantastic

  32. Pinky

    I love this tutorial..it’s exactly what i need..
    thank you so much!
    wordpress is so fun!

  33. Dickenson Bay

    Nice post. Thanks for sharing this amazing post.
    This is very helpful for us.

  34. sanjay

    hi! nice tut! i’m here to learn, so im stickin’ with your site for awhile..and please give me some advice on my website, i a newbie so still learning through the way..hope you could suggest to make my site better. thanks man!

  35. Harridi

    I’m usually using margin-left instead left.
    which is better??

Speak Your Mind...

Post HTMLNeed to Post HTML Code? Use Postable to post code friendly html. *Wrap all html code in <pre></pre> tags.
Post HTMLNeed to Keep Updated with Comments? Subscribe to comments now.

CSS Gallery