Skip to main content
Kathryn - Pasadena CA
Known Participant
May 23, 2025
Answered

Collapse a headline?

  • May 23, 2025
  • 3 replies
  • 3119 views

I have this page I'm working on: https://www.bassett.net/pages/david.shtml - yes I know I need to redo my website to make it responsive, but no time at preset. What I want to do, is to have the items under each headline be collapsd unless they click on a plus or arrow to open the content.

 

Example of what I have in mind: https://liquiddeath.com/pages/faq

 

I tried following along https://www.youtube.com/watch?v=Zgqbbg3EW7Q, that uses https://www.w3schools.com/howto/howto_js_accordion.asp, but had issues on exactly where the segments of code would go, in relation to the code already there.

 

Is it even possible when using a page with shtml? I have a vague memory from year ago that there was a way to have my interior part of the page pull in an htm, but I'm not sure if it's my imagination or not. I WAS able to make an htm/html that worked from the YouTube.

 

I'm using Dreamweaver 21.4 and Windows 10.

This topic has been closed for replies.
Correct answer Nancy OShea

You placed your Accordion panel inside a floated <div> that's only 500px wide.  Remove the float and width.

#left {
float: left;
width: 500px;
margin-left: 50px;
margin-right: 0%;
}

 

3 replies

noah 43
Participating Frequently
April 16, 2026

Yes — it’s absolutely possible, even with .shtml.

.shtml only affects server-side includes (SSI); on the frontend it behaves like normal HTML, so JavaScript accordion/collapse will work fine.

Simple solution (no libraries needed)

Add this where your content is:

 

<button class="accordion">Section Title</button>
<div class="panel">
<p>Your hidden content here</p>
</div>

Then before </body>:

 

<script>
document.querySelectorAll(".accordion").forEach(btn => {
btn.addEventListener("click", () => {
btn.classList.toggle("active");
let panel = btn.nextElementSibling;
panel.style.display = panel.style.display === "block" ? "none" : "block";
});
});
</script>

And basic CSS:

 

<style>
.panel { display: none; }
</style>

Notes:

  • Placement matters → HTML where content is, JS before </body>
  • Works in Dreamweaver and Windows 10 without issues
  • If your YouTube example worked in .html, it will work the same in .shtml

👉 Your idea of loading .htm inside .shtml is correct (SSI #include), but not required for this feature.

Kathryn - Pasadena CA
Known Participant
May 23, 2025

I'm satified now with https://www.bassett.net/pages/AccordianSample.html

So the remaining question is why isn't  https://www.bassett.net/pages/david2.shtml  full width of the white area? Hopefully, I figure it out while waiting for a response, but... just in case.

Nancy OShea
Community Expert
Community Expert
May 23, 2025

Your Accordion Panel is 100% width.

.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 20px;
transition: 0.4s;

}

 

When Accordions are placed inside other containers, they are constrained to the maximum width of the parent element, whatever that may be -- 25%, 50% or 75% of screen width.

 

 

Nancy O'Shea— Product User & Community Expert
Nancy OShea
Community Expert
Nancy OSheaCommunity ExpertCorrect answer
Community Expert
May 23, 2025

You placed your Accordion panel inside a floated <div> that's only 500px wide.  Remove the float and width.

#left {
float: left;
width: 500px;
margin-left: 50px;
margin-right: 0%;
}

 

Nancy O'Shea— Product User & Community Expert
Kathryn - Pasadena CA
Known Participant
May 23, 2025

Hmm, I figured out the include, I knew I'd used it before - it's in the sidebar. So, since posting original post, I've now included https://www.bassett.net/pages/AccordianSample.html

 

When pulling that page up in browser, the content uses the whole width. But when including it in https://www.bassett.net/pages/david2.shtml, it only uses about 25% of the available width. Why is that?

 

While waiting for an answer, I'll experiment on adding an image like a plus sign.