HTML 09 - Quotations

emanlee發表於2024-05-18

Quotations in HTML allow you to include and format quoted text within your web content. HTML provides tags such as <blockquote>, <q>, <cite>, <address>, <bdo> and <abbr> to structure and style quotes.

These tags help maintain proper formatting and semantics /sɪˈmæntɪks/, enhancing the presentation and meaning of quoted content on web pages. Incorporating quotes is essential for conveying information accurately and providing a well-organized reading experience for users.

Quotation tag (<q>)

We use <q> tag, to add short quotation marks in HTML. And if we want to quote for multiple lines, use <blockquote> tag.

We can also use the cite attribute inside the <blockquote> tag to indicate the source of the quotation in URL form.

Syntax

Following is the syntax for the <q> tag.

<q>The content to be quoted</q>

Example

Following is the example program for the <q> tag.

<!DOCTYPE html>
<html>
<head>
   <title>HTML Quotation tag</title>
</head>
<body>
   <p>DLF stands for <q>Delhi Land and Finance</q></p>
   <p>Delhi Land and Finance is one of the largest commercial real estate developer in India.</p>
</body>
</html>

Example

In the example below, we used <q> tag on a particular text inside the <h1> tag.

<!DOCTYPE html>
<html>
<head>
   <title>HTML u tag</title>
</head>
<body>
   <h1>Welcome to <q> INDIA </q> Kids.</h1>
</body>
</html>

The "<blockquote>" tag

The <blockquote> tag is to indicate long quotations. It should contain only block-level elements within it and not just plain text. It specifies a section quoted from another source and contains only block-level elements.

We can also use the cite attribute inside the <blockquote> tag to indicate the source of the quotation in URL form.

Syntax

Following is the syntax for the <blockquote> tag.

<blockquote>The multiple line content to be quoted </blockquote>

Example

Following is the example program for the <blockquote> tag.

<!DOCTYPE html>
<html>
<head>
   <title>HTML blockquote tag</title>
</head>
<body>
   <p>DLF stands for Delhi Land and Finance</p>
   <blockquote>Delhi Land and Finance is one of the largest commercial real estate developers in India. It is also engaged in the business of generation of power provision of maintenance services hospitality and recreational activities life insurance and retail chain outlets. Its internal business includes the development business and rental business. The development business of the Company is involved in the sale of residential spaces select commercial offices and commercial complexes. The company has a unique business model with earnings arising from development and rentals. </blockquote>
</body>
</html>

Example

Following is the example program when we use cite attribute inside the <blockquote> tag.

<!DOCTYPE html>
<html>
<head>
   <title>HTML blockquote tag</title>
</head>
<body>
   <h1>Tutorialspoint</h1>
   <p>Here is a quotation from Tutorialspoint’s official website</p>
   <blockquote cite="https://www.tutorialspoint.com">Join our millions of loyal visitors to access our free Text Library. From programming languages and web development to data science and cybersecurity, our masterfully crafted Tutorials will help you master any technology or concept from scratch.</blockquote>
</body>
</html>

Example

Following is the example program when we changed the style of <blockquote> tag by using CSS.

<!DOCTYPE html>
<html>
<head>
   <title>HTML blockquote tag</title>
   <style>
      blockquote {
         margin-left: 0;
      }
   </style>
</head>
<body>
   <h1>Tutorialspoint</h1>
   <p>Here is a quotation from Tutorialspoint’s official website</p>
   <blockquote cite="https://www.tutorialspoint.com">Join our millions of loyal visitors to access our free Text Library. From programming languages and web development to data science and cybersecurity, our masterfully crafted Tutorials will help you master any technology or concept from scratch.</blockquote>
</body>
</html>

The "<cite>" tag

The <cite> tag in HTML is used to reference the title of a creative work, such as a book, movie, or song, within the content. It provides semantic meaning to the citation. Here's a coding example −

<!DOCTYPE html>
<html>
<head>
   <title>Cite Tag Example</title>
</head>
<body>
   <p>The information is sourced from <cite>The Elements of Style</cite> by Strunk and White.</p>
</body>
</html>

In this example, '<cite>' is used to indicate the title of the referenced book.

The "<address>" tag

The <address> tag in HTML is used to define the contact information for the author or owner of a document. It often includes details such as an email address, physical address, or other relevant contact information. Here's an example −

<!DOCTYPE html>
<html>
<head>
   <title>Address Tag Example</title>
</head>
<body>
<address>
   Contact us at: <a href="mailto:info@example.com">info@example.com</a><br>
   Visit us at: 123 Main Street, Cityville
</address>
</body>
</html>

In this example, the '<address>' tag is used to provide contact information, including an email link and a physical address.

The "<bdo>" tag

The <bdo> tag in HTML, bdo stands for Bi-Directional Override, is used to override the current text direction. It is commonly used in situations where the default text direction needs to be changed, such as for displaying text from right to left. Here's an example −

<!DOCTYPE html>
<html>
<head>
   <title>Bi-Directional Override Example</title>
</head>
<body>
   <p>This text will go left to right.</p>
   <p><bdo dir="rtl">This text will go right to left.</bdo></p>
</body>
</html>

In this example, the text within the '<bdo>' tag is displayed from right to left, overriding the default left-to-right direction.

The "<abbr>" tag

The <abbr> tag in HTML is used to define abbreviations or acronyms. Here's an example −

<!DOCTYPE html>
<html>
<head>
   <title>Abbreviation Tag Example</title>
</head>
<body>
   <p>My best friend's name is <abbr title="Abhishek">Abhy</abbr>.</p>
</body>
</html>

In this example, <abbr> is used to abbreviate the name "Abhishek" to "Abhy," and the 'title' attribute provides the full description of the abbreviation.