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?
Explanation: According to AP style, a question mark is inside quotation marks if that part is the question and outside the quotation marks if the whole sentence is a question. (The same rule applies to exclamation marks and dashes. Periods and commas always go inside quotation marks.)
Commas and periods always go inside the quotation marks in American English; dashes, colons, and semicolons almost always go outside the quotation marks; question marks and exclamation marks sometimes go inside, sometimes stay outside.
The same rule applies to titles and words used in a special sense or for emphasis. Use double quotation marks (“”) around a direct quote. A direct quote is a word- for-word report of what someone else said or wrote. You use the exact words and punctuation of the original.
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.
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.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With