- HTML Tutorial
- HTML Introduction
- HTML Editors
- HTML Basic
- HTML Comments
- HTML Elements
- HTML Attributes
- HTML Id & Classes
- HTML Skeletal Tags
- HTML Heading Tags
- HTML Paragraph Tag
- HTML Line Break Tag
- HTML Pre Tag
- HTML Anchor Tag
- HTML Image Tag
- HTML Horizontal Line Tag
- HTML Inline & Block
- HTML Inline
- HTML Block
- HTML LInks
- HTML Images
- HTML Formatting
- HTML Head
- HTML Head
- HTML Title
- HTML Meta Elements
- HTML Favicon
- HTML Style
- HTML List
- HTML Lists
- HTML Unordered List
- HTML Ordered List
- HTML Description List
- HTML Table
- HTML Tables
- HTML Table Headers
- HTML Table Styling
- HTML Table Colgroup
- HTML Form
- HTML Forms
- HTML Form Elements
- HTML Form Attributes
- HTML Input Types
- HTML Input Attributes
- HTML Form Actions
- HTML Semantic
- HTML Semantics
- HTML Graphics & Media
- HTML Canvas
- HTML SVG
- HTML Video & Audio
- HTML Plug-ins
- iFrames in HTML
- HTML Miscellaneous Tags
- HTML Code Tag
- HTML Entities
- HTML Quotation
- HTML Global Attributes
- HTML Obsolete Tags
- HTML Emojis
- HTML Symbols
- HTML Events
- HTML Colors
HTML Quotation
When building content-heavy websites, you often need to reference other sources. While it's tempting to just type quotation marks around your text, HTML provides specific semantic tags <q> and <blockquote> to handle this. Using these tags isn't just about appearance; it tells search engines and screen readers exactly where your original content ends and where someone else's begins.
<blockquote> instead of just indenting text with CSS. This helps screen readers announce to visually impaired users that the text is a quotation.
1. <q> Tag
The <q> element is your go-to for inline quotations. These are short snippets of text that stay within the flow of a paragraph. One of the most helpful features of the <q> tag is that modern browsers will automatically wrap the text in quotation marks for you, often adjusting the style of those marks based on the language of the page.
Syntax:
<q>Quoted text here</q>
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML Quotation Example</title>
</head>
<body>
<p>As Tim Berners-Lee famously said, <q>The Web as I envisaged it, we have not seen it yet.</q> and this remains true today.</p>
</body>
</html>
Output:
As Tim Berners-Lee famously said, "The Web as I envisaged it, we have not seen it yet." and this remains true today.
<q> tag. If you do this: <q>"Hello"</q>, the browser might render it as ""Hello"", resulting in double quotation marks.
cite attribute (e.g., <q cite="URL">) to provide a hidden link to the source. While users won't see it, it’s great for SEO and document metadata.
2. <blockquote> Tag
The <blockquote> element is designed for longer quotations or excerpts that deserve their own space on the page. Unlike the inline <q> tag, a blockquote is a block-level element, meaning it starts on a new line and takes up the full width available. By default, browsers apply a margin to the left and right to make it stand out visually.
Syntax:
<blockquote cite="https://source-url.com">
Quoted text here
</blockquote>
Example:
In professional web design, blockquotes are frequently used for client testimonials or highlighting key excerpts from articles.
<!DOCTYPE html>
<html>
<head>
<title>HTML Quotation Example</title>
<style>
blockquote {
font-style: italic;
color: #555;
border-left: 5px solid #7f06ff;
padding: 15px 25px;
margin: 20px 0;
background-color: #f9f9f9;
}
</style>
</head>
<body>
<h2>Developer Motivation:</h2>
<blockquote>
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
Martin Fowler
</blockquote>
</body>
</html>
Output:
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
Martin Fowler
(The text is indented, styled with a distinct purple left border and a light background.)
<blockquote> purely for visual indentation of non-quoted text. If you just want to indent a paragraph, use CSS margin-left or padding-left instead to keep your HTML semantically correct.
Comparison: <q> vs <blockquote>
Summary
<q>: Best for short, inline quotes. It handles quotation marks automatically, keeping your text clean and correctly punctuated.<blockquote>: Best for large chunks of borrowed text. It provides a clear visual and semantic separation from the rest of your content.- Attribution: Use the
citeattribute on both tags to point to the source URL for better SEO and document structure.