How to highlight author comments in Blogger
Highlighting author comments help readers differentiate them from readers’ comments. This is especially useful, for example, when a reader come back to check on a reply to his/her question. Highlighting your reply/answer, will make it easier to spot. Remember, making things easier for your readers is a good thing.
And in line with that statement, if you are using Blogger/blogspot, I’m going to make it easier for you to highlight your comments.
Most author-comments-highlighting tips attempt to highlight by changing the comment box background color. The code for this is actually quite simple, but to make it applicable to all blogger templates, that’s a bit complicated. This is because the codes for comments section varies –different class names, different id names or different way of styling. And to make it even worse, some templates don’t even have comment (display) box.
So, comments background color is out. What we are going to highlight is what every comment section have –the comment itself. So we’ll be highlighting the comment text, not all, just the author’s.
Now let’s do this,
- Login to your to your Blogger account.
- Go to Dashboard > Design > Edit HTML.
- Back up your template.
- Tick the Expand Widget Templates checkbox on top right of the HTML window.
- In the code window, look for this code:
<b:if cond='data:comment.isDeleted'> <span class='deleted-comment'><data:comment.body/></span> <b:else/> <p><data:comment.body/></p> <b:include data='comment' name='commentDeleteIcon'/> </b:if>
The code responsible for displaying comments is
<p><data:comment.body/></p>
in line 4. (There is similar code in line 2. Leave that one alone, it’s for deleted comments.) - Now replace the code in line 4 with this (just copy & paste):
<!--author comments highlight Start--> <!--http://www.bloggersentral.com --> <b:if cond='data:comment.author == data:post.author'> <p style='color: limegreen; font-weight:bold;'><data:comment.body/></p> <b:else/> <p><data:comment.body/></p> </b:if> <!--author comments highlight End-->
- Here is the result, tested on this blog:
The highlighting is applied by the<p style="color: limegreen; font-weight:bold;">
inline styling. You can style the text any way you want. For example, to italicize, just addfont-style:italic
. Separate each property with a semicolon.
As for the text color, replacelimegreen
with your preferred color. You can use CSS Colornames or Hex color code. Hex color code must be preceded by a pound (#) sign, e.g. #FFD700. - Click Save Template.
- Finish. Enjoy!
Do say something, please use the comments below.
75 comments to "How to highlight author comments in Blogger"
Woah thank you! I was looking for this!
You're welcome. I'm happy to see it in action on your blog.
Come again for more tips.
cant do it. zzz. tried about 3 times. doesn't work for me.
Hi ░♥si lampu neon♥░,
I guess your 4th try works :). I see it working in your blog.
Thanks for dropping by.
Thanks for this, it worked like a charm!
My pleasure Andrea.
thanks... this helped. Cheers !
You're welcome Pushpinder Singh Bagga.
Stick around for more tips and hacks.
Thanks. it's great (meme ganah)
Khairi,
Glad you like it. Beyeh
I have not been able to get this to work. I am having a very hard time to a lot of thing to work with my template. I did get the numbering to work though.
never mind I did get it to work. I was looking at a post that I hadn't commented on.
Thankyou
http://mobilethemesworld.blogspot.com/
Wow, thank you so much...
Kelly, TheShadow, Angel,
You're welcome...
Thanks again, You are really teaching me how to do this whole html thing... Or at least to feel like I know what I am doing! so thanks!
Many many thanks for the post. I was tired looking for the solution & finally I stumbled upon this post.
I just saw "Now It's Your Turn To Say Something" above the comment box. Can you reply how to to do it so that I can customize my own message.
Thanks & Regards
hey, it is me again. i found the solution for my previous question.
thanks & cheerss
@Remodelaholic
My pleasure.
Nah...HTML is not that hard to begin with. Those remodeling thing you do, now that is something
@Amar V
Don't orget to come back.
I looked all over and couldn't find this. Thanks so much for such great info!!
www.cait-theblessedlife.blogspot.com
@cait
You're welcome. Next time come here first :)
I changed the code, and my comments as the author don't display any any changes, but are working fine.
Do some templates just not allow the highlighting?
@Jessica
It's working...but you I see numbers 1236...78.
You don't want that, lose the numbers by clicking the <> icon on top right corner of the code, a window will pop up, copy the raw code from there.
Thank you so much for all the tips & tricks.
Is there another color we can use besides limegreen? I've tried changing to pink, green, olive, etc and it doesn't show any changes.
@Shel at Dreamy Nest
Refer to CSS Colornames for a list of color names and their equivalent hex codes.
Thank you Greenlava.
I've fixed the code using both the hex values AND the name of the color and I still can't get it to work. What am I doing wrong?
I've substitued the word IndianRed with it's hex value of #CD5C5C too. No luck.
Tried posting the code and couldn't.
@Shel at Dreamy Nest
To post your code here, replace < and > symbols with [ and ].
Ok - thanks, Greenlava:
[b:if cond='data:comment.isDeleted']
[span class='deleted-comment'][!--author comments highlight start--]
[!--http://bloggersentral.blogspot.com --]
[b:if cond='data:comment.author == data:post.author']
[p style='color:#CD5C5C; font-weight:bold;'><data:comment.body/][/p]
[b:else/]
[p][data:comment.body/][/p]
[/b:if]
[!--author comments highlight end--]
[/span]
@Shel at Dreamy Nest
I see the problem now. Your styling applies to deleted comments! :)
Your original code (before adding the hack) should be like so:
[b:if cond='data:comment.isDeleted']
[span class='deleted-comment'][data:comment.body/><b:include data='comment' name='commentDeleteIcon'/]
[/b:if]
you applied the code to the first comment.body, which is for deleted comment.
The correct one is the second comment.body, the one enclosed in [p][/p] tags.
p.s. I'm revising the instructions, to make it clearer.
Thank you so much! I just tried fixing it and apparently I've goofed my whole coding up in the comments section. I also tried adding numbering and the hack to add more than 200 comments. Yup, I've created a mess. My fault entirely. I am code-challenged. Sorry. I'll see if I can figure out how to fix it all and start over later.
Your instructions are awesome!!!! I love this place!!! Thank you!!
Works like a charm =).
this is the simplest author highlight i've come across. thanks so much.
Works great! Thank you!
@John
@Mon
@Sandy at Teacup Lane
You're welcome. Thanks you for the feedbacks :)
hey greenlava it did not work for me proper......i posted ur code but whn i try publishing the comments, the user comment half went...and wht ever reply in comment i posted came twice ...so this is the problem what to do......
@raj
You have to REPLACE the existing code with the code in step 6.
hi
i can find
the code
in my html
@.::: Princess MOMOY :::.
Have you ticked the Expand Widget Templates checkbox?
Hello, my comments are now showing twice. Once in green, then in black. How do I fix this problem? thanks
@Selina Loves Love
It looks okay now.
This is great - it's the least complicated one I've found and works even if you're using a third-party template because you're only replacing a single line of code.
One question, though. I'd prefer to highlight the author's NAME rather than the comment itself. Could this be tweeked to do this?
@Billy
Instead of [p][data:comment.body/][/p], you want to apply the changes to
[a expr:href='data:comment.authorUrl' rel='nofollow']
Thanks, Greenlava!
Sorry to mither, Greenlava, but when I try to do as you instructed I get the dreaded error message "Template cannot be sparsed properly. must be closed with the relevent closing tag"
I put the block of code in the new place, but surely the instances of in that code should be replaced with too?
Anyway, no matter what I do my template doesn't seem to like where I'm trying to put it. Any ideas?
@Billy
Did you not replace [ and ] with < and >?
Thanks for your patience, Greenlava. I didn't really need to replace [ and ] with < and > because all I was doing was replacing the [a expr:href='data:comment.authorUrl' rel='nofollow'] line with your original block of code (which already uses < and > ).
Let me just go through this again. Are you saying that to highlight the author's NAME as opposed to their actual POST, I need to replace: [a expr:href='data:comment.authorUrl' rel='nofollow'] with that block of code in step 6 from your original instructions?
I did this, and had no instances of [ and ], but I still got the 'template cannot be sparsed properly' message.
@Billy
Replace this:
[a expr:href='data:comment.authorUrl' rel='nofollow']
with this:
[b:if cond='data:comment.author == data:post.author']
[a style='color: limegreen; font-weight:bold;' expr:href='data:comment.authorUrl' rel='nofollow']
[b:else/]
[a expr:href='data:comment.authorUrl' rel='nofollow']
[/b:if]
Nope. So sorry, Greenlava, but that still didn't work. I replaced all the [] with the correct morethan/lessthan symbols, but I'm still getting this error message:
"Your template could not be parsed as it is not well-formed. Please make sure that all XML elements are closed properly.
XML error message: Element type "a" must be followed by either attribute specifications, "morethan" or "/morethan>". (the code obvioulsy doesn't say "morethan", but as you know those symbols don't show up in comments)
I tried closing the a tag with the relevent closing tag as instructed, but still got the error message.
Never mind, you've wasted enough trying to help me now. It must be because I'm using a third party templte.
Thanks for all your help.
@Billy
My bad. I left out the data tag. I was looking at my heavily tweaked template :)
Let's start over...
Replace this:
[a expr:href='data:comment.authorUrl' rel='nofollow'][data:comment.author/][/a]
with this:
[b:if cond='data:comment.author == data:post.author']
[a style='color: limegreen; font-weight:bold;' expr:href='data:comment.authorUrl' rel='nofollow'][data:comment.author/][/a]
[b:else/]
[a expr:href='data:comment.authorUrl' rel='nofollow'][data:comment.author/][/a]
[/b:if]
YAY!
Thank you so much, Greenlava! You've been incredibly patient and helpful :)
Now just to lose that awful limegreen ;)
It's okay, I know how to do that :)
Oh, Crap!
I've just noticed that this changed the color of my (author) name, but that it completely deleted the name of the other commentors??
This is the comment code as it stands since applying your latest changes.
--------------------------------------
[b:if cond='data:comment.authorUrl']
[b:if cond='data:comment.author == data:post.author']
[a expr:href='data:comment.authorUrl' rel='nofollow' style='color: #000099; font-weight:normal;'][data:comment.author/][/a]
[b:else/]
[a expr:href='data:comment.authorUrl' rel='nofollow'][data:comment.author/][/a]
[/b:if]
[/b:if]
----------------------------------------
Can you see from that why it's deleting the name of the other commentors?
Sussed it!!
I just needed to add CSS styling for the relevent class:
.comment-author a { color: red !important; }
Hey I just wanted to say thanks so much for the information. It was simply and straight to the point. And most of all IT WORKED.
Thanks Again.
http://www.pcosdiaries.com
Like! Like! Like!
:) thnx green lava
@Haz Issac
Thanks
Howdy, its me again~ Im totally loving your webpage. ITs THE MOST RELIABLE for me :)
I cant seem to find [p][data:comment.body/][/p] in my HTML at all, and I have already clicked expand widget..Any idea how to do it? Thankksss :D
@sheena
Use the search function (by pressing Ctrl+F) to find data:comment.body
Yes, that's how I searched. It doesn't have data:comment.body at all.
Thank you for such working trick....
Hi there, I have found the link, It was hidden due to my template settings I guess. Anyway, Could you teach me how to change the VISITORS font? I want to change the font color to this : #00005C, for both the name and the comment body. I also want to make it bold typefont. Could you please send me the css for it? thank you
@Sheena
Go to Design > Template Designer > Advanced >Add CSS and add this snippet:
ol.commentlist li .comment-author, ol.commentlist li p {
color: #00005C;
font-weight:bold;
}
Thank you For the post its very intresting
reallyyy thx !!!! i made it!!
but if i want bold and italic in the same time.. HOWS? :)
@Sha-na.Szied
Replace the code in line 4 with this:
[p style='color: limegreen; font-weight:bold;font-style:italic;']
It works !! Thank you so much :)
Another great tutorial! I was hoping to change the background color but this is great too.
I've been tweaking my blog all day and yours are always the tutorials I end up using because they are well written and most of all... they work! :)
Thanks :)
Cathy
www.sidetrackemom.net
Love it! ALways a rush when a hack works the first time. Thank you!
Good Blog, nice
:D thnks :D
Here is the simple trick to highlight threaded author comments on blogger - http://www.webspeaks.in/2012/05/highlight-threaded-author-comments-on.html
Hi! You have helped me several times before, maby you can help me one more time?
I while back I changed my html code so that my comments were bold. It worked great. But after blogger changed so that you now can comment on comments, the functions of author highlight vanished. The code (which I got from you) is still there, but its not working.
I tried to change the colour of my comments as well ( I had black before), but that didn't work either..
Is there a way to fix it? I would like my comments to be black and bold, or (but this might be impossible) the entire comment to have a different coloured background, like light gray or so..
Many thanks!
PS. I will of course, as previous times, make a donation if you can take the time to help. DS
@Karin E Jansson
I'm planning to write a tutorial on this subject (highlighting author's comment in Blogger threaded comments), but since you asked I might as well give you the code here:
Here it is:
<script src='http://code.jquery.com/jquery-latest.js'></script>
<!-- author comments highlight Start -->
<div id='bsACHL'>
<script>
$(document).ready(function(){
$('cite.blog-author').parents('.comment-block')
.css({'border':'solid #dddddd 1px','background':'#f1f1f1','padding':'10px'});
$('#bsACHL').parents('.HTML').css('display','none');
});
</script>
</div>
<!-- author comments highlight End -->
Copy the code and paste it in a HTML/Javascript gadget.
You can change the background color by replacing #f1f1f1 with your own.
And I need feedback, please tell me if it works (or not).
Yey, it works!! Thank you!!!
Post a Comment
We love to hear from you! Leave us a comment.
To ensure proper display, HTML/XML/Javascript need to be escaped first using this escape tool.