Copied successfully!
Introduction to <dl>
The <dl>tag in HTML stands for "Description List" and is used to create a list of terms and their descriptions. This tag is particularly useful when you want to display a list of items along with their corresponding details or explanations. The <dl>element is commonly used in conjunction with two other tags: <dt>(Description Term) and <dd>(Description Definition).
Copy to clipboard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Styled Description List Example</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Frequently Asked Questions</h1>
<dl class="faq-list">
<dt>What is the return policy?</dt>
<dd>Our return policy lasts 30 days. If 30 days have gone by since your purchase, unfortunately, we can’t offer you a refund or exchange.</dd>
<dt>How do I track my order?</dt>
<dd>You can track your order using the tracking number provided in the confirmation email or by logging into your account on our website.</dd>
<dt>Do you ship internationally?</dt>
<dd>Yes, we offer international shipping to most countries. Shipping rates and delivery times will vary based on the destination.</dd>
<dt>How can I contact customer service?</dt>
<dd>You can contact our customer service team via the contact form on our website or by calling our toll-free number: 1-800-123-4567.</dd>
</dl>
</div>
</body>
</html>
Copy to clipboard
/* General Styles */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f8f9fa; /* Light gray background for the page */
color: #333;
margin: 0;
padding: 20px;
}
.container {
max-width: 800px; /* Max width for the content container */
margin: 0 auto; /* Center the container */
background-color: #fff; /* White background for the container */
padding: 30px; /* Padding inside the container */
border-radius: 10px; /* Rounded corners for the container */
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
}
h1 {
text-align: center; /* Center the heading */
color: #007bff; /* Blue color for the heading */
margin-bottom: 25px; /* Margin below the heading */
font-size: 2em; /* Larger font size for the heading */
}
/* Description List Styles */
.faq-list {
margin: 0; /* Remove default margin */
padding: 0; /* Remove default padding */
list-style-type: none; /* Remove default list styling */
}
.faq-list dt {
font-weight: bold; /* Bold font for terms */
font-size: 1.2em; /* Slightly larger font size for terms */
margin-top: 20px; /* Margin above each term */
color: #007bff; /* Blue color for terms */
position: relative; /* Position for the custom icon */
padding-left: 25px; /* Padding to accommodate custom icon */
}
/* Custom Icon for Each Term */
.faq-list dt::before {
content: "❓"; /* Custom question mark icon */
position: absolute; /* Position relative to the term */
left: 0; /* Align to the left */
color: #007bff; /* Blue color for the icon */
font-size: 1.2em; /* Match font size with term */
}
.faq-list dd {
margin-left: 25px; /* Indent descriptions */
margin-bottom: 15px; /* Space below each description */
color: #555; /* Dark gray color for descriptions */
line-height: 1.6; /* Increase line height for readability */
background-color: #f1f1f1; /* Light gray background for descriptions */
padding: 15px; /* Padding inside each description */
border-radius: 5px; /* Rounded corners for descriptions */
}
/* Responsive Design */
@media (max-width: 600px) {
.container {
padding: 20px; /* Adjust padding for smaller screens */
}
.faq-list dt {
font-size: 1.1em; /* Adjust term font size */
}
.faq-list dd {
font-size: 0.95em; /* Adjust description font size */
}
}
Global Attributes
Attributes | Description |
---|---|
accesskey | Specifies a shortcut key to activate or focus an element. |
autocapitalize | Controls whether and how text input is automatically capitalized. |
class | Specifies one or more class names for the element, allowing CSS styling and JavaScript manipulation. |
contenteditable | Specifies whether the content of an element is editable or not. |
contextmenu | Specifies a context menu for the element. |
dir | Defines the text direction. Possible values are "ltr" (left-to-right), "rtl" (right-to-left), and "auto". |
draggable | Specifies whether an element is draggable. Possible values are "true" or "false". |
enterkeyhint | Specifies the action label or icon to be shown for the enter key on virtual keyboards. |
hidden | Indicates that the element is not yet, or is no longer, relevant. The browser does not display elements that have the `hidden` attribute set. |
id | Specifies a unique identifier for the element. |
inputmode | Provides a hint to browsers for which virtual keyboard configuration to use when editing this element or its descendants. |
is | Allows you to specify the type of custom element. |
lang | Specifies the language of the element's content. |
nonce | A cryptographic nonce ("number used once") that can be used by Content Security Policy (CSP) to determine whether or not a given fetch will be allowed to proceed. |
part | Specifies the element’s part in the shadow DOM. |
slot | Assigns a slot in a shadow DOM shadow tree. |
spellcheck | Indicates whether the element is subject to spell checking. |
style | Provides inline CSS styling for the element. |
tabindex | Specifies the tab order of the element. |
title | Adds extra information about the element, displayed as a tooltip when hovering over the element. |
translate | Specifies whether the content of the element should be translated. Possible values are "yes" or "no". |
HTML Attributes | Global Attributes | Event Attributes |
---|---|---|
To view the full list | To view the full list | To view the full list |
elements | |||||
---|---|---|---|---|---|
<dl> | Yes | Yes | Yes | Yes | Yes |
Improve Our Platform
Did you find what you were looking for?
Learn how to contribute.Last updated on by our contributors.
View this page on GitHub• Report an issue with this content