Publish in HTML Tutorial el 25/05/2025 15:35
The
<q>
tag in HTML is used to define a short inline quotation. Browsers usually render the content inside this element with quotation marks around it, making it an ideal choice for including quoted text within paragraphs or other inline elements without breaking the flow of the document.
This element also supports the
cite
attribute, which allows you to specify the source URL of the quotation. While the quotation marks are automatically added by the browser, developers can further style the
<q>
element using CSS for more visual control.
To use the
<q>
element, simply wrap the quoted text inside the opening and closing tags:
This will display as a short quote wrapped in quotation marks by default:
This example shows how to use the
<q>
element inside a paragraph to denote a short quote.
In this example, we apply some custom CSS to make the quote stand out visually.
This example demonstrates how to dynamically insert a quote using JavaScript inside a
<q>
element.
This example adds a dynamic attribution link based on the quote shown, demonstrating how JavaScript can interact with the
<q>
element's
cite
attribute.
This final example uses JavaScript to randomly select and display a quote from a predefined array of quotes each time the page loads.
cite
attribute to reference the source of the quote, even if it's just a placeholder.
<q>
with
<blockquote>
for longer citations that require paragraph-level structure.
<q>
element using CSS to enhance readability or match your site's design language.
<q>
elements unless necessary; use sparingly to maintain semantic clarity.
<q>
element using JavaScript, just like any other HTML element.
The
<q>
element is a powerful tool for marking up inline quotations with semantic meaning. By understanding its usage and styling options, you can enhance both the accessibility and presentation of quoted content on your website.
The <style> HTML element contains style information for a document, or part of a document. ...
The <strong> element is used to indicate that its content has strong importance, seriousnes...
The <span> element is an inline container used to mark up a part of a text or document. Unl...
The <source> element is used to specify multiple media resources for media elements like &l...
The <small> element is used to represent side-comments and small print, typically for discl...
HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...