q tag (XHTML 1.1)

short inline quotation

Topics

The q tag is, just like the blockquote tag, used for displaying quotes. The difference is that the blockquote tag is for long quotes which spans more than one line, while the q tag is for short, one-line quotes. The tag can be used like this:

<q>This is merely a short quote!</q>

The result looks like this in your browser:

 

This is merely a short quote!

 

As you can probably see, the browser automatically puts quotes around the tag. If you have a quote inside a quote, the browser will handle this too:

<q>This is merely a <q>short, he said</q> quote!</q>

Resulting in:

 

This is merely a short, he said quote!

 

The cool thing about it is that you can use the lang attribute to specify the language of the quote. By doing so, the browser will respect the specified language's rules for quotations, which can differ quite a bit. For instance, like this:

<q lang="en-us">This is merely a <q lang="en-us">short, he said</q> quote!</q>

The cite attribute

The cite attribute can be used for specifying a source URL for the quote. For instance, here is a quote from Google, where we use the cite attribute to specify the page where we found it:

<q cite="http://www.google.com/corporate/">Google's mission is to organize the world's information and make it universally accessible and useful.</q>

Once again, it's up to the browser how to render this extra information, and most browsers chooses not to render it at all. That doesn't mean it's not useful though - the value might be picked up by search bots etc.

Attributes

Attribute Deprecated Required Description
cite  URI for source document or msg 
class  space-separated list of classes 
dir  direction for weak/neutral text 
id  document-wide unique id 
lang  language code 
style  associated style info 
title  advisory title 

Events

Event Description
onclicka pointer button was clicked 
ondblclicka pointer button was double clicked 
onkeydowna key was pressed down 
onkeypressa key was pressed and released 
onkeyupa key was released 
onmousedowna pointer button was pressed down 
onmousemovea pointer was moved within 
onmouseouta pointer was moved away 
onmouseovera pointer was moved onto 
onmouseupa pointer button was released 



© htmlpedia.net 2008 - 2012