<section>
  <h2 class="title">FAQs</h2>
  
  <div class="faq">
    <div class="question">
      <h3>What is JavaScript?</h3>
      
      <svg width="15" height="10" viewBox="0 0 42 25">
        <path d="M3 3L21 21L39 3" stroke="white" stroke-width="7" stroke-linecap="round" />
      </svg>
    </div>
    <div class="answer">
      <p>
        Lorem ipsum dolor, sit amet consectetur adipisicing elit.
      </p>
    </div>
  </div>
  
    <div class="faq">
    <div class="question">
      <h3>What is JavaScript?</h3>
      
      <svg width="15" height="10" viewBox="0 0 42 25">
        <path d="M3 3L21 21L39 3" stroke="white" stroke-width="7" stroke-linecap="round" />
      </svg>
    </div>
    <div class="answer">
      <p>
        Lorem ipsum dolor, sit amet consectetur adipisicing elit.
      </p>
    </div>
  </div>
  
    <div class="faq">
    <div class="question">
      <h3>What is JavaScript?</h3>
      
      <svg width="15" height="10" viewBox="0 0 42 25">
        <path d="M3 3L21 21L39 3" stroke="white" stroke-width="7" stroke-linecap="round" />
      </svg>
    </div>
    <div class="answer">
      <p>
        Lorem ipsum dolor, sit amet consectetur adipisicing elit.
      </p>
    </div>
  </div>
</section>
/*--------------------- Google fonts ------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

*
{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body
{
  font-family: 'Poppins', sans-serif;
  background: #1c1c1c;
  color: #ffffff;
}

section
{
  min-height: 100vh;
  width: 80%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.title
{
  font-size: 3rem;
  margin: 2rem 0;
}

.faq
{
  max-width: 700px;
  margin-top: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #fff;
  cursor: pointer;
}

.question
{
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.question h3
{
  font-size: 1.8rem;
}

.answer
{
  max-height: 0;
  overflow: hidden;
  transition: max-height 1s ease-in-out;
}

.answer p
{
  padding-top: 1rem;
  line-height: 1.6;
  font-size: 1.4rem;
}

.faq.active .answer
{
  max-height: 300px;
}
const faqs = document.querySelectorAll(".faq");

faqs.forEach(faq => {
  faq.addEventListener("click", () => {
    faq.classList.toggle("active");
  })
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.