views:

346

answers:

2

I used to just use p and span elements for this... but I'm always pushing to use the right elements, and this is something I haven't really thought about before with regard to testimonials.

This is what I had in mind

<div class="testimonial">
 <blockquote>i love your products</blockquote>
 <span>Jim Testimonial-giver</span>
</div>

Does that look like the best way to do this? Is there a best practise? I looked at how the W3C markup testimonials on their site, and they have done it like this:

<blockquote>
 <p>
  <a id="aptest" name="aptest">Applied Testin.....</a>
  <br />
  <span class="QuoteAttr">-- Shane P. M...</span>
 </p>
</blockquote>

Should I just copy how the W3C did it, after all shouldn't they be correct?

+4  A: 

Use the cite tag:

<div class="testimonial">
 <blockquote>i love your products</blockquote>
 <cite>Jim Testimonial-giver</cite>
</div>

Also I would probably do it like this:

<blockquote class="testimonial">
  i love your products
  <cite>Jim Testimonial-giver</cite>
</blockquote>

Just to make it slightly more semantic and clearly tie the citation with the quote. Divs should only be necessary for structural things.

Rex M
Thanks Rex ... I can't believe I forgot the cite element!
alex
Do you think if there's a bunch of them, they should go in an unordered list?
alex
@alex I do love unordered lists :) I am leaning towards yes myself, but I wouldn't frown at not using them in this particular case.
Rex M
+3  A: 

The Mozilla.org style guide seems to prefer using q for the quotation and <cite> for the author, wrapped in a <blockquote> or a <div> with an appropriate class. HTML 5 seems to strongly frown on using <cite> for people's names; it says that it should only be used for the titles of works.

Following that model, perhaps something like this:

<blockquote class="testimonial">
  <q>I love your products!</q>
  <cite>Jim Testimonial-giver</cite>
</blockquote>

Or if you don't want to use <cite>, then:

<blockquote class="testimonial">
  <q>I love your products!</q>
  <span class="quote-attribution">Jim Testimonial-giver</span>
</blockquote>
Brian Campbell
It's a bit of a quibble, but I'm going to disagree here - the q element is not supported in IE, and since there's no need to distinguish between the contents of the q and any other element (it's the only - and primary - block of text in blockquote), it seems superfluous.
Rex M
The q element is supported in IE 8. It depends on whether you want to insert the quotes or not, and whether you want them to display in earlier versions of IE. The nice thing about the q element is that you can get properly nested smart quotes if you set your your :before and :after selectors.
Brian Campbell