Styling Blog Comments: Correct Markup and Free Examples

One of the important and unavoidable features on every blog are guest comments. In this article you can read about proper comments section HTML and also download some FREE comments css examples.

Written by Alen Grakalic on: 29 Sep, 2009

One of the important and unavoidable features on every blog are guest comments. You want your readers to get involved and post comments, it tells you how much they're interested in the topic and are willing to have their say. The thing that will invite users to read and post comments on your blog is taking the extra effort in styling comments properly and make them more readable.

comments examples

Download Free Examples

Proper Comments Section Markup

We will start at the beginning, with HTML code. Let's see what the comments really are. Basically it is a list of users remarks about certain topic. More so, that list has a chronological component since users post their comments one after another, no mixing here... So, the choice for the HTML element we'll use with comments is pretty obvious – we're going with ordered list <li>.

Comments has meta data that is common for each entry. Things like commenter's name, url, date when he or she wrote it etc. are info that helps us follow the comment “timeline". Apart from this meta data we have the comment content itself. We can then say that each comment has 2 separate sections: comment meta data and comment body.
Let's translate all of this into HTML. We said that we're using ordered list for comments:

<ol class="comments">
	<li></li>
</ol>

I used class although you can easily go with ID. I doubt that there will be a situation where you'll have 2 or more comment lists on on page.
Next, the meta data we mentioned. We have:

  • gravatar (this is optional really...)
  • commenter's name
  • commenter's homepage
  • the date when comment was posted

When you look at it like that, you can say that this is a list of meta data. Because they have no particular order (we can move them around as we please) we're using unordered list <ul>. For the comment body we are using simple <div>. That is more than suitable in this case. DIVs mark up the divisions or sections of the document which comment body most certainly is.
Now our comment's markup looks like this:

<ol class="comments">
	<li>
	<ul class="meta">
	<li><img src="path-to-gravatar.gif" alt="Author's name" /></li>
	<li><a href="url-to-authors-homepage.html">Author's name</a></li>
	<li>posted on date-goes-here</li>
	</ul>
	<div class="body">Comment text goes here...</div>
	</li>
</ol>

Note that we combined author's url and his name into one list item.

To gain even more control add class names for each of the items in meta data list

<ul class="meta">
	<li class="image"><img src="path-to-gravatar.gif" alt="Author's name" /></li>
	<li class="author"><a href="url-to-authors-homepage.html">Author's name</a></li>
	<li class="date">posted on date-goes-here</li>
</ul>

Some of you might want to take somewhat different way and put all of those meta data into one sentence. In that case we will use paragraph <p> instead of unordered list <ul>:

<ol class="comments">
	<li>
	<p class="meta"><img src="path-to-gravatar.gif" alt="Author's name" /> On date-goes-here <a href="url-to-authors-homepage.html">Author's name</a> wrote:</p>
	<div class="body">Comment text goes here...</div>
	</li>
</ol>

Styling the Comment Section

We'll start with basic styling, setting up margins and paddings for comment list:

.comments{
	margin:1em 0;
	padding:0;
	}
.comments li{
	margin:0;
	padding:0;
	list-style:none;
}

If we choose to use unordered list for meta data we might want to reset the default styling for that list as well:

.comments .meta, .comments .meta li{
	margin:0;
	padding:0;
	list-style:none;
	}

Style 1

Free comment css

.comments, .comments ul, #comments li{
	margin:0;
	padding:0;
	list-style:none;
	}
.comments li{
	margin:1.5em 0;
	position:relative;
	font-size:13px;
	}
.comments a{color:#5a7981;text-decoration:none;}
.comments a:hover{color:#555;}
.comments .meta{
	padding-bottom:32px;
	background:url(01/bg_comments1.gif) no-repeat 0 100%;
	}	
.comments .meta li{
	margin:0;
	display:inline;
	font-size:12px;
	color:#777;
	position:static;
	}	
.comments .meta .author{
	font-size:14px;
	font-weight:bold;
	}	
.comments .meta img{
	position:absolute;
	left:28px;
	top:68px;
	z-index:100;
	border:1px solid #bfd5da;
	}	
.comments .body{
	padding:10px 28px 20px 100px;
	background:url(01/bg_comments2.gif) no-repeat 0 100%;
	min-height:58px;
	}	

Click here to see the demo.

Style 2

Free comment css

.comments, .comments ul, #comments li{
	margin:0;
	padding:0;
	list-style:none;
	}
.comments li{
	margin:1.5em 0;
	position:relative;
	font-size:13px;
	}
.comments a{color:#89c140;text-decoration:none;}
.comments a:hover{color:#555;}
.comments .meta{}	
.comments .meta li{
	margin:0;
	display:inline;
	font-size:13px;
	color:#777;
	position:static;
	}	

.comments .meta .image{display:none;}	
.comments .meta .author{
	float:left;
	font-weight:bold;
	padding-left:35px;
	line-height:36px;
	background:url(02/ico_comments.gif) no-repeat 0 50%;
	}
.comments .meta .date{
	float:right;
	color:#999;
	font-style:italic;
	font-size:11px;
	line-height:36px;
	}	
.comments .body{
	clear:both;
	padding:20px 20px;
	background:#fff url(02/bg_comments.gif) repeat-x;
	}	

Click here to see the demo.

Style 3

Free comment css

.comments, .comments ul, #comments li{
	margin:0;
	padding:0;
	list-style:none;
	}
.comments li{
	margin:1.5em 0;
	position:relative;
	font-size:13px;
	background:url(03/bg_comments.gif) no-repeat 0 0;
	overflow:hidden;
	}
.comments a{color:#5a7981;}
.comments a:hover{color:#555;text-decoration:none;}
.comments .meta{
	float:left;
	display:inline;
	width:100px;
	}	
.comments .meta li{
	background:none;
	margin:0;
	}	
.comments .meta .date{
	color:#999;
	font-size:11px;
	}	
.comments .meta img{
	border:1px solid #bfd5da;
	}	
.comments .body{
	float:left;
	display:inline;
	width:425px;
	padding:1em 0;
	margin-left:47px;
	}	

Click here to see the demo.

Style 4

Free comment css

I used only one image for this example so it can be easily customized.

.comments, .comments ul, #comments li{
	margin:0;
	padding:0;
	list-style:none;
	}
.comments li{
	margin:1.5em 0;
	position:relative;
	font-size:13px;
	background:url(04/bg_comments.gif) no-repeat 0 0;
	overflow:hidden;
	}
.comments a{color:#edecd8;text-decoration:none;}
.comments a:hover{color:#fff;}
.comments .meta{}	
.comments .meta li{
	margin:0;
	display:inline;
	color:#777;
	background:none;
	}	
.comments .meta .image{display:none;}	
.comments .meta .author{
	float:left;
	font-weight:bold;
	padding-left:40px;
	line-height:39px;
	margin-bottom:10px;
	}
.comments .meta .date{
	float:right;
	color:#fff;
	font-style:italic;
	font-size:11px;
	line-height:39px;
	margin-right:12px;
	}	
.comments .body{
	clear:both;
	padding:10px 28px 40px 28px;
	background:#fff url(04/bg_comments.gif) no-repeat 0 100%;
	}

Click here to see the demo.

Alen Grakalic Alen Grakalic is a designer, developer and a passionate standardista with large experience in all types of front-end work. Started to get involved with web in 1999. and turned freelance in 2005., the same year he started Css Globe. Alen's work has been featured on numerous css galleries including famous Css Zen Garden official list.

Most recent blog updates

Comments

  1. Jasmin Halkic on 29 Sep, 2009 wrote:

    Very nice article. Thank you.
  2. Antonio on 29 Sep, 2009 wrote:

    Thank you, very useful hints.
  3. Nik Makhov on 1 Oct, 2009 wrote:

    Great article, thank you very much, I've just translated it into Russian, for our web-masters page - http://web-grower.ru/razmetka-dlya-kommentariev-v-bloge.html
  4. Liam on 1 Oct, 2009 wrote:

    These are great but being a bit of a Wordpress noob can you tell me how to setup the third example in my Wordpress blog? I assume I can copy and paste the css over the default comment css however I'm confused as what to do in the comments.php file?
  5. Quicken Websites on 2 Oct, 2009 wrote:

    Great! Easy and very well put) Thank you for your great job!
  6. Sean on 2 Oct, 2009 wrote:

    This will come in handy on my next blog design project.
  7. Roberto on 2 Oct, 2009 wrote:

    Wow, great work! Thank you for sharing.
  8. Mike Tok on 5 Oct, 2009 wrote:

    Thank you for sharing your idea . At least now I got a reference to read if I'm facing problem coding the comments template.. Hope to see more articles from you in the future.
  9. Jack Bremer on 6 Oct, 2009 wrote:

    You didn't mention about putting nofollow in there too!
  10. TheBigO on 11 Oct, 2009 wrote:

    Good article.
  11. School Grant Help on 15 Oct, 2009 wrote:

    your idea helped me in clearing my questions.... thanks
  12. rapid4me on 19 Oct, 2009 wrote:

    Markup is still a dark horse for me, I am thus to get any info about it. Your post is well written and easily understtod. thank you!
  13. Bank on 21 Oct, 2009 wrote:

    you should use it on this site...
  14. Autonomy on 24 Oct, 2009 wrote:

    Ha! Word, @Bank - that is a great point. This site could use Alen's advice.
    Thanks for the article.
  15. Rachit Bhargava on 27 Oct, 2009 wrote:

    heyy dude its a great blog...
    just keep goin...

    Rachit Bhargava
    Google
  16. Skech on 30 Oct, 2009 wrote:

    Thanks. Your post helped me a lot.
  17. Rahul - Web Guru on 16 Nov, 2009 wrote:

    Thanks for the styles, have downloaded my copy of the examples.

    Cheers.
  18. Torbjoern Karlevid on 17 Dec, 2009 wrote:

    Errors found while checking this document as XHTML 1.0 Transitional!
    http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Ftemplatica.com%2Farticles%2Fcomments%2F01.html

    Sorry! We found the following errors (1)
    http://jigsaw.w3.org/css-validator/validator?profile=css21&warning=0&uri=http%3A%2F%2Ftemplatica.com%2Farticles%2Fcomments%2F01.html
  19. shoaib hussain on 21 Dec, 2009 wrote:

    awesome n cool n grabbing the blue one with bubble in it,.
  20. hizlindir on 22 Dec, 2009 wrote:

    thank you for information
  21. hizlindir on 22 Dec, 2009 wrote:

    sorry. l wrote my web site adress mistake. :D again thanks
  22. Nick Matyas on 7 Jan, 2010 wrote:

    Really wonderful post. this blog is awesome.
    Posts with more information will be great.

    Webroyalty
  23. Deaf school on 12 Jan, 2010 wrote:

    is still a dark horse for me, I am thus to get any info about it. Your post is well written and easily understtod. thank you!
  24. Custom Stickers on 18 Jan, 2010 wrote:

    Great blog and great information thanks for share this coding information.
  25. Promotional Giveaways on 23 Jan, 2010 wrote:

    It's really very strange thing that you have such a great site and blog. But you don't update it. This is my first visit here. You should update this awesome blog.
  26. Valentine Sms on 27 Jan, 2010 wrote:

    yah i like it thanks and keep postings.
  27. Funny text messages on 27 Jan, 2010 wrote:

    its really very nice and informative posting thanks for sharing this with us...
  28. volkan on 30 Jan, 2010 wrote:

    I think it is a bit complicated but I've liked.
    it is better if you check it again.
    It is well liked as summarized
  29. sanem on 30 Jan, 2010 wrote:

    I congratulate you for this blog.
    I've really enjoyed.
    I sincerely thank you again
  30. aceite de onagra on 31 Jan, 2010 wrote:

    great post, very interesting and informative.
    i enjoy reading your blog and your templates too
    thanks
  31. Wine Shaker on 4 Feb, 2010 wrote:

    nice post , thanks for help my question!
  32. warren farrell on 5 Feb, 2010 wrote:

    great blog posting..thanks for share coding info.....
  33. Jamal on 19 Feb, 2010 wrote:

    Good article had doubt on markups to use for commenting, this has made it clear. Wonder if there will be an update for threaded comments markup!
  34. Serguei Panfilov on 24 Feb, 2010 wrote:

    Alen, thanks a lot for sharing these nice styles. I'm impressed, so now I'm following you on Twitter and subscribed to your RSS feed.
  35. Zhenden on 26 Feb, 2010 wrote:

    I congratulate you for this blog.
    I've really enjoyed.
    I sincerely thank you again
  36. henden on 26 Feb, 2010 wrote:

    nice post , thanks for help my question!
  37. hendenoy on 26 Feb, 2010 wrote:

    great post, very interesting and informative.
    i enjoy reading your blog and your templates too
    thanks
  38. john on 1 Mar, 2010 wrote:

    cool
    Finance Tips.
  39. Rick on 1 Mar, 2010 wrote:

    I know this is such an awesome blog, i loved this post, styling blog comments can be quite hard sometimes. Finding great resources like this blog is very rare.

    Check out this other resources I love.
    Gana Dinero.
    Google Maps Directions.
    Mapquest Driving Directions.
  40. Big R on 1 Mar, 2010 wrote:

    I was looking for this code a long time ago, thanks!

    Peliculas Online Gratis.
    Krugerrand Coins.
    Descargar Google Earth Gratis.
  41. battletoad on 1 Mar, 2010 wrote:

    Great info, thanks for the code!

    Debt Consolidation Loans.
    Financial Planning.
    0 Credit Cards.
  42. juansuarez on 1 Mar, 2010 wrote:

    thanks for the info, I wish had found this code earlier when i started blogging


    Traductor Gratis Google.
    Make Money Online.
    Making Money Online.
    Messenger Gratis.
  43. littlejuan on 1 Mar, 2010 wrote:

    thanks!


    rocky quotes.
  44. Nike Air yeezy on 2 Mar, 2010 wrote:

    ugg retailers
    Nike Air yeezy
  45. suarezcolvert on 3 Mar, 2010 wrote:

    Great site and information! Styling blog comments can be tricky sometimes

    Make Money.
    How to Make Money Fast.
  46. zhendn on 4 Mar, 2010 wrote:

    thanks for the info, I wish had found this code earlier when i started blogging
  47. Penny Stocks on 4 Mar, 2010 wrote:

    it’s really an interesting article. superb… for reading it, Nice article. Thank you
  48. ramalho on 4 Mar, 2010 wrote:

    Hi WEB Family,


    Great article and is very useful.

    Thanks for sharing
  49. facebook application development on 5 Mar, 2010 wrote:

    great article shearing with us thanks.
  50. facebookguru on 5 Mar, 2010 wrote:

    Hey! you are give a very good info about code it's really interesting, it's very helpful for us.
  51. rick on 9 Mar, 2010 wrote:

    great info, great examples, thanks

    gana dinero.
    Round Table.

Post a comment

Join the club now

Access all templates for only $24 per year! No hidden fees - Limited time offer

Buy individual templates for as low as $5!

What's Templatica anyway?

Templatica is a membership based template club where you get full access to all templates in the css template gallery for a single and very affordable annual fee of $24!
Yup, that's right! All of this plus all of the templates released within one year from the day you join. No extra cost, no hidden fees!
You also have a possibility of purchasing a single template for as low as $5.

Why is the fee so low?

I wanted to make premium templates available to as many of you as possible. Templates are not only meant for commercial but for educational purpose as well. I would like you to join, download templates, analyse the code and hopefully learn something new.
For those who'd like to test the quality of the templates I suggest my single template purchase option.

What Templatica Offers?

Templatica offers static design templates with valid XHTML and CSS. All templates are tested in Firefox Win, IE7, IE6, Opera on Windows as well as Safari and Firefox on Mac.
Templates are highly customizable. The download package for each template includes HTML, CSS, JavaScript files and related images.