Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
HTML

HTML: Use Details & Summary for Collapsible Content

- 24.07.26 - ErcanOPAK

📂 Details & Summary = Collapsible Content

Long content needs organizing. Details & Summary creates collapsible sections. Clean, semantic, accessible.

📝 Details & Summary Basics

<details>
    <summary>Click to expand</summary>
    <p>This content is hidden until you click.</p>
    <ul>
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
    </ul>
</details>

<!-- Open by default -->
<details open>
    <summary>Already open</summary>
    <p>This content is visible by default.</p>
</details>

<!-- Nested details -->
<details>
    <summary>Main Section</summary>
    <details>
        <summary>Sub Section 1</summary>
        <p>Nested content...</p>
    </details>
    <details>
        <summary>Sub Section 2</summary>
        <p>More nested content...</p>
    </details>
</details>

🎯 Practical Examples

<!-- FAQ Section -->
<div class="faq">
    <details>
        <summary>What is your return policy?</summary>
        <p>We offer 30-day returns on all items. Just contact support.</p>
    </details>
    <details>
        <summary>How long does shipping take?</summary>
        <p>Standard shipping takes 3-5 business days.</p>
    </details>
    <details>
        <summary>Do you ship internationally?</summary>
        <p>Yes, we ship to over 50 countries worldwide.</p>
    </details>
</div>

<!-- Accordion with custom styling -->
<style>
details {
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    padding: 10px;
}
summary {
    cursor: pointer;
    font-weight: bold;
}
summary::marker {
    color: #3498db;
}
details[open] summary {
    color: #3498db;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}
details[open] {
    background: #f8fafc;
}
</style>

<!-- JavaScript control -->
<script>
const details = document.querySelectorAll('details');
details.forEach(detail => {
    detail.addEventListener('toggle', function() {
        if (this.open) {
            console.log('Opened:', this.querySelector('summary').textContent);
        }
    });
});

// Programmatically open/close
detail.open = true; // Open
detail.open = false; // Close
</script>

<!-- Details Tips -->
- Use for FAQ sections
- Use for accordion menus
- Use for collapsible sidebars
- Use for read more sections
- Use for settings panels

💡 Details Tips

  • Use for FAQ sections
  • Use for accordion menus
  • Use for collapsible sidebars
  • Use for read more sections
  • Use for settings panels

“Details & Summary creates clean collapsible content. No JavaScript needed. Essential for organizing content.”

— Web Developer

Related posts:

HTML5 Video Autoplay Failing? — The REAL Browser Requirement

HTML5 Video Autoplay Failing? — The REAL Browser Requirement

HTML: Use Robots Meta Tag to Control Search Engine Crawling

HTML: Use Robots Meta Tag to Control Search Engine Crawling

HTML: Use Tables for Tabular Data

HTML: Use Tables for Tabular Data

Views: 8

Post navigation

CSS: Master Font Sizing for Responsive Typography
JavaScript: Use Destructuring for Clean Assignment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (981)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (653)
  • Add Constraint to SQL Table to ensure email contains @ (609)
  • Average of all values in a column that are not zero in SQL (570)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (547)
  • Find numbers with more than two decimal places in SQL (475)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit
  • SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs
  • C#: Fix an Enum HasFlag Returning True for the Zero Value
  • WordPress: Fix Featured Images Vanishing After a CDN Migration
  • Photoshop: Fix Content-Aware Fill Smearing a Repeating Pattern
  • Asp.Net Core: Fix Antiforgery Tokens Rejected Behind a Reverse Proxy

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (981)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com