Reputation: 6105
The <q>
element for short quotes adds quotation marks to the text:
<p><q>This is a quote.</q></p>
Can you tell me how this is advantageous to simply using quote characters (i.e. " ") directly within a paragraph?
<p>"This is a quote."</p>
One could style it specially, but it seems like one could use a <span>
element for that too, so what's the main advantage(s) of the <q>
element?
Upvotes: 8
Views: 2136
Reputation: 201588
It is not advantageous. On the contrary, it means that the presence and type of quotation marks will depend on the browser; the q
element has a sad history.
I don’t think anyone has presented any actual benefits of using “semantic” markup instead of quotation marks, which are just punctuation marks comparable to periods and commas. There has been a lot of talk about things that programs could do, upon encountering q
, and little if any efforts in really making them do something with it (apart from adding quotation marks in rendering).
Using real quotation marks instead, you can control the exact symbols used, such as “American” vs. ‘British’ vs. « French » vs. ”Finnish” vs. »different Finnish» according to content language. There is normally no reason to let this depend on browser handling of markup like q
or on CSS, any more than you should use markup and CSS to terminate your sentences instead of just using full stop (“.”).
However, in the rare case where you wish to make the device for indicating quotations depend on styling (so that it can be changed in a centralized manner just by changing a style sheet), you can use the span
element, e.g.
<span class=q><span class=qm>“</span>This is a quote.<span class=qm>”</span></span>
Then you could change the rendering to italic without quotation marks by setting
.q .qm { display: none; }
.q { font-style: italic; }
Using span
, which has no default rendering features, you avoid the problems of inconsistent implementations of q
.
Upvotes: 1
Reputation: 165971
The reason to use it is mainly semantic. The specification makes it clear that the <q>
element has a very specific semantic meaning (emphasis added):
The q element represents some phrasing content quoted from another source... Content inside a q element must be quoted from another source...
The q element must not be used in place of quotation marks that do not represent quotes; for example, it is inappropriate to use the q element for marking up sarcastic statements.
If you use a <p>
element, you do not have the same semantic meaning. However, the spec also points out that this is acceptable:
The use of q elements to mark up quotations is entirely optional; using explicit quotation punctuation without q elements is just as correct.
Upvotes: 3
Reputation: 14446
The idea is that any computer program parsing the page would know that it represents a quote. It's the same reason you use <li> instead of just dashes and <br>.
Upvotes: 0
Reputation: 31481
The advantage is in the semantic markup. Your browser may show them similarly, but other tools (such as a screen reader) may interpret and present them much more differently.
Upvotes: 2
Reputation: 253318
The main advantage of using the q
element is the potential semantic meaning it adds to the content, it describes the content as being a quote. It also allows browsers with the locale information to style the quotation marks appropriately for that region, "
for most English-speaking regions, «
and »
for Spain and France, and so on, appropriate for the user's language settings. In theory, at least.
Upvotes: 13