Learn HTML

HTML: dd tag

Description of HTML dd tag

The HTML dd tag is used in conjunction with the dl tag to create a description list in HTML. The dd tag defines the description of an item in the list.

Here’s an example of how to use the dl, dt, and dd tags in HTML:

<dl>
<dt>HTML</dt>
<dd>Hyper Text Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
<dt>JS</dt>
<dd>JavaScript</dd>
</dl>

In this example, the dl tag creates a description list, and each term in the list is defined using the dt tag. The dd tag is used to define the description of each term. When rendered in a web browser, it might look something like this:

HTML Hyper Text Markup Language

CSS Cascading Style Sheets

JS JavaScript

Note that the dd tag should only be used in conjunction with the dl and dt tags to create a description list.


 

 

Syntax of HTML dd tag

The HTML <dd> tag is used to define a description or value in a description list (<dl>). The syntax of the <dd> tag is as follows:

<dl>
<dt>Term</dt>
<dd>Description or value</dd>
</dl>

Here, the <dt> tag is used to define the term being described, and the <dd> tag is used to define the description or value of the term.

Example:

<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language is the standard markup language used to create web pages.</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets is a style sheet language used for describing the presentation of a document written in HTML or XML.</dd>
</dl>

In this example, a description list is used to define two terms, “HTML” and “CSS”, along with their respective descriptions. The <dt> tags are used to define the terms, and the <dd> tags are used to define the descriptions.


 

Global Attributes

The <dd> tag is used in HTML to define the description of a term in a description list (<dl>). The <dd> tag does not have any unique attributes, but it does inherit global attributes from the HTML specification. Here are some of the global attributes that can be used with the <dd> tag:

  1. class: This attribute specifies one or more CSS classes for the element, allowing you to apply custom styles to the <dd> tag.
  2. id: This attribute specifies a unique identifier for the element, allowing you to target it with CSS or JavaScript.
  3. style: This attribute allows you to specify inline styles for the element, such as font size, color, or margin.
  4. title: This attribute provides additional information about the element, typically displayed as a tooltip when the user hovers over the element.
  5. lang: This attribute specifies the language of the element’s content, using a two-letter language code such as “en” for English or “es” for Spanish.
  6. dir: This attribute specifies the text direction of the element’s content, either “ltr” for left-to-right or “rtl” for right-to-left languages.

These global attributes can be used with the <dd> tag to provide additional information and customization for your web page. For example, you could use the class attribute to apply a custom background color to all the <dd> tags in a particular section of your page, or use the id attribute to target a specific <dd> tag with JavaScript to make it interactive. The title attribute can be used to provide helpful tooltips for users who may not be familiar with the terms being defined in the description list.

 

 

Event Attributes

The <dd> tag in HTML does not have any specific event attributes associated with it. However, it does inherit all the global event attributes defined in the HTML specification. These attributes can be used to define JavaScript functions to be executed when an event occurs on the <dd> element. Here are some of the global event attributes that can be used with the <dd> tag:

  1. onblur: This attribute is triggered when the element loses focus.
  2. onfocus: This attribute is triggered when the element gains focus.
  3. onclick: This attribute is triggered when the element is clicked.
  4. ondblclick: This attribute is triggered when the element is double-clicked.
  5. onmousedown: This attribute is triggered when the mouse button is pressed down on the element.
  6. onmouseup: This attribute is triggered when the mouse button is released over the element.
  7. onmousemove: This attribute is triggered when the mouse cursor moves over the element.
  8. onkeydown: This attribute is triggered when a key is pressed down while the element has focus.
  9. onkeyup: This attribute is triggered when a key is released while the element has focus.
  10. onsubmit: This attribute is triggered when a form is submitted, if the <dd> element is inside a form.

These event attributes can be used to create dynamic and interactive web pages. For example, you could use the onclick attribute to define a function that displays additional information when the user clicks on a <dd> element. Or you could use the onsubmit attribute to validate user input before submitting a form that includes <dd> elements. Keep in mind that event attributes should be used sparingly and with caution, as they can make your code more complex and difficult to maintain. It’s often better to use external JavaScript files and event listeners to keep your code organized and modular.

 

Other Attributes

The <dd> tag in HTML doesn’t have any unique attributes other than global and event attributes. However, it is often used in combination with other tags to provide additional information or context. Here are some examples of attributes that can be used with the <dd> tag when it is used in a description list (<dl>) with other tags:

  1. class: This attribute can be used to apply a custom CSS class to the <dd> element, allowing you to define custom styles for specific descriptions.
  2. id: This attribute can be used to provide a unique identifier for the <dd> element, which can be used for targeting with JavaScript or for linking to a specific description from other parts of the page.
  3. style: This attribute can be used to define inline styles for the <dd> element, such as font size, color, or margin.
  4. title: This attribute can be used to provide additional information about the description, typically displayed as a tooltip when the user hovers over the description.
  5. lang: This attribute can be used to define the language of the description’s content using a two-letter language code such as “en” for English or “es” for Spanish.
  6. dir: This attribute can be used to define the text direction of the description’s content, either “ltr” for left-to-right or “rtl” for right-to-left languages.
  7. xml:lang: This attribute can be used to define the language of the description’s content using an XML language code such as “en-US” for American English or “es-MX” for Mexican Spanish.
  8. translate: This attribute can be used to indicate whether the description’s content should be translated by the browser or not, using either the value “yes” or “no”.

These attributes can be used with the <dd> tag to provide additional information and customization for your web page. For example, you could use the class attribute to define a custom style for descriptions that contain important information, or use the id attribute to link to a specific description from other parts of the page. The title attribute can be used to provide additional information about the description, and the lang and dir attributes can be used to make the description more accessible for users who speak different languages or read from right-to-left.


 

Notes on HTML dd tag

Here are some important notes on the <dd> tag in HTML:

  1. The <dd> tag is used in combination with the <dt> tag to create a description list (<dl>). The <dt> tag is used to define the term or name of the description, while the <dd> tag is used to define the description itself.
  2. The <dd> tag should only be used within a <dl> element. If used outside of a <dl> element, it may not be recognized by the browser or may have unintended styling or formatting.
  3. The <dd> tag is a block-level element, meaning it takes up the full width of its parent element and creates a new line after it. If you want to display multiple descriptions on the same line, you can use the display: inline-block; CSS property.
  4. The content of a <dd> element can include any valid HTML elements, such as text, images, links, and other elements.
  5. The <dd> tag doesn’t have any specific attributes unique to it, but can inherit global and event attributes from the HTML specification.
  6. The <dd> tag is often used in combination with other tags, such as the <dl> and <dt> tags, to provide additional information and context for the content on a web page.
  7. It’s important to use semantic HTML tags such as <dd> whenever possible, as it helps to improve the accessibility and search engine optimization (SEO) of your web page. Semantically correct HTML helps search engines better understand the content of your web page, and can make it easier for people using assistive technologies like screen readers to navigate and understand the content.
  8. Finally, it’s always important to test your HTML code in different browsers and devices to ensure it is rendering correctly and providing a good user experience for all users.

    Browser Compatibility

    The HTML dd tag has essential support with the following browsers:

    1. Chrome
    2. Internet Explorer (IE)
    3. Opera
    4. Safari (WebKit)
    5. Firefox (Gecko)
    6. Android
    7. Firefox Mobile (Gecko)
    8. Edge Mobile
    9. Opera Mobile
    10. Safari Mobile

     

    Examples

     


     

    HTML 4.01 Transitional Document

    Here’s an example of using the <dd> tag in HTML 4.01 Transitional:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Example of using the dd tag in HTML 4.01 Transitional</title>
    </head>
    <body>
    <h1>Animal Kingdom</h1>
    <dl>
    <dt>Mammals</dt>
    <dd>A group of animals that feed their young with milk produced by mammary glands.</dd>
    
    <dt>Birds</dt>
    <dd>A group of animals characterized by feathers, beaks, and wings, and capable of flight.</dd>
    
    <dt>Reptiles</dt>
    <dd>A group of animals characterized by scaly skin, cold blood, and the ability to lay eggs on land.</dd>
    </dl>
    </body>
    </html>

    In this example, we’ve created a list of animal categories using a <dl> element, with each category defined using a <dt> tag and a <dd> tag. The <dt> tag defines the category name, while the <dd> tag defines a short description of the category.

    Note that HTML 4.01 Transitional doesn’t include the HTML5 semantic elements like <section>, <article>, and <aside>, so we’re using the <dl> element to create a list of term-description pairs. The <dd> tag is used to define the descriptions for each category.

    When this code is rendered in a web browser, it will display as a formatted list with each category followed by its corresponding description. The <dd> tags will be displayed as block-level elements, taking up the full width of their parent <dl> element.

    Again, note that the example above doesn’t include any custom attributes or styles for the <dd> tag, but you could add them as needed using the global and event attributes or custom attributes like class and id.


     

     

    XHTML 1.0 Transitional Document

    Here’s an example of using the <dd> tag in an XHTML 1.0 Transitional document:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Example of using the dd tag in XHTML 1.0 Transitional</title>
    </head>
    <body>
    <h1>Famous Painters</h1>
    <dl>
    <dt>Leonardo da Vinci</dt>
    <dd>An Italian Renaissance artist and inventor best known for his painting, the Mona Lisa.</dd>
    
    <dt>Pablo Picasso</dt>
    <dd>A Spanish artist who co-founded the Cubist movement and is widely considered one of the most influential artists of the 20th century.</dd>
    
    <dt>Vincent van Gogh</dt>
    <dd>A Dutch artist who is famous for his vivid, expressive paintings and his struggles with mental illness.</dd>
    </dl>
    </body>
    </html>

    In this example, we’ve created a list of famous painters using a <dl> element, with each painter defined using a <dt> tag and a <dd> tag. The <dt> tag defines the painter’s name, while the <dd> tag defines a short description of their work or legacy.

    Note that we’re using an XHTML 1.0 Transitional doctype, which allows for both HTML and XHTML elements and attributes. The <dd> tag is an XHTML element, and we’ve included the XHTML namespace declaration in the <html> tag.

    When this code is rendered in a web browser, it will display as a formatted list with each painter followed by their corresponding description. The <dd> tags will be displayed as block-level elements, taking up the full width of their parent <dl> element.

    Again, note that the example above doesn’t include any custom attributes or styles for the <dd> tag, but you could add them as needed using the global and event attributes or custom attributes like class and id.


     

     

    XHTML 1.0 Strict Document

    Here’s an example of using the <dd> tag in an XHTML 1.0 Strict document:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Example of using the dd tag in XHTML 1.0 Strict</title>
    </head>
    <body>
    <h1>Popular Programming Languages</h1>
    <dl>
    <dt>Python</dt>
    <dd>An interpreted, high-level, general-purpose programming language known for its simplicity, readability, and wide range of applications.</dd>
    
    <dt>JavaScript</dt>
    <dd>A programming language that is commonly used to create interactive web pages and web applications.</dd>
    
    <dt>C++</dt>
    <dd>A general-purpose programming language that is widely used in the software industry and known for its performance and efficiency.</dd>
    </dl>
    </body>
    </html>

    In this example, we’ve created a list of popular programming languages using a <dl> element, with each language defined using a <dt> tag and a <dd> tag. The <dt> tag defines the language name, while the <dd> tag defines a short description of the language.

    Note that we’re using an XHTML 1.0 Strict doctype, which only allows for XHTML elements and attributes that conform to strict XML syntax. The <dd> tag is an XHTML element, and we’ve included the XHTML namespace declaration in the <html> tag.

    When this code is rendered in a web browser, it will display as a formatted list with each programming language followed by its corresponding description. The <dd> tags will be displayed as block-level elements, taking up the full width of their parent <dl> element.

    Again, note that the example above doesn’t include any custom attributes or styles for the <dd> tag, but you could add them as needed using the global and event attributes or custom attributes like class and id.


     

    XHTML 1.1 Document

    Here’s an example of using the <dd> tag in an XHTML 1.1 document:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Example of using the dd tag in XHTML 1.1</title>
    </head>
    <body>
    <h1>World Capitals</h1>
    <dl>
    <dt>Paris</dt>
    <dd>The capital and most populous city of France, known for its cultural landmarks, fashion, and cuisine.</dd>
    
    <dt>Tokyo</dt>
    <dd>The capital and largest city of Japan, known for its high-tech industry, fashion, and entertainment.</dd>
    
    <dt>Mexico City</dt>
    <dd>The capital and largest city of Mexico, known for its rich history, architecture, and cuisine.</dd>
    </dl>
    </body>
    </html>

    In this example, we’ve created a list of world capitals using a <dl> element, with each capital defined using a <dt> tag and a <dd> tag. The <dt> tag defines the city name, while the <dd> tag defines a short description of the city.

    Note that we’re using an XHTML 1.1 doctype, which only allows for XHTML elements and attributes that conform to strict XML syntax. The <dd> tag is an XHTML element, and we’ve included the XHTML namespace declaration in the <html> tag.

    When this code is rendered in a web browser, it will display as a formatted list with each world capital followed by its corresponding description. The <dd> tags will be displayed as block-level elements, taking up the full width of their parent <dl> element.

    Again, note that the example above doesn’t include any custom attributes or styles for the <dd> tag, but you could add them as needed using the global and event attributes or custom attributes like class and id.

    About the author

    Home4Cloud