Search code examples
xhtmlmarkupsemantic-markupquotations

What is the best way to markup a testimonial in XHTML?


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 practice?

I looked at how the W3C markup testimonials on their site, and they have used...

<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?


Solution

  • 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.