Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Create a Summary Element that can Expands but never Shrink using HTML ?

  • Last Updated : 26 Jul, 2021

It can be seen in many websites like reading more buttons containing a link. These things expand when the user clicks the read more link or button then after expanding there was no option for collapsing the expanded content. In this article, we will remove that collapsing option. We required two elements <details> and <summary> to create that kind of interface, by applying a CSS “display: none;” property.
This feature is not a good option but few developers asked to design this kind of interface by applying the CSS display:none; property. We can remove the collapsing option from summary

Below example illustrate the above approach:


details[open] summary {
    display: none;



<!DOCTYPE html>
        Create a details element that opens
        but never closes
        .container {
            text-align: center;
        h1 {
            color: green;
        details[open] summary {
            display: none;
    <div class="container">
            This paragraph will expand but not
            collapsed after expanding
            A Computer Science Portal for Geeks



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!