Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet">

<div class="wrapper">


    <h2 class="headline" id="main-headline">
      Frequent Questions about HTML, CSS and Javascript
    </h2>
    <p class="headline headline__text">
      Click the below tabs to expand the questionary.
    </p>

    <div id="FAQ">
      <div onclick="toggleOff(this)" class="oneFAQ">

        <div class="question">
          <span class="headline headline__med headline--bold">What is semantic HTML?</span>
        </div>

        <div class="answer">
          <p class="headline headline__text">Semantic HTML is a coding style. It is the use of HTML markup to reinforce the semantics or meaning of the content. For example: In semantic HTML <b> </b> tag is not used for bold statement as well as <i> </i> tag is used for italic. Instead of these we use <strong></strong> and <em></em> tags.</p>
        </div>
      </div>

      <div onclick="toggleOff(this)" class="oneFAQ">

        <div class="question">
          <span class="headline headline__med">What is JavaScript(JS)?</span>
        </div>

        <div class="answer show">
          <p class="headline headline__text">JavaScript is a lightweight, interpreted programming language with object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages.</p>
        </div>
      </div>

      <div onclick="toggleOff(this)" class="oneFAQ">

        <div class="question">
          <span class="headline headline__med">What is a style sheet?</span>
        </div>

        <div class="answer">
          <p class="headline headline__text">A style sheet is used to build a consistent, transportable, and well-designed style template. You can add these templates on several different web pages. It describes the look and formatting of a document written in markup language.</p>
        </div>
      </div>

      
    </div> <!-- FAQ -->

</div> <!-- wrapper -->
              
            
!

CSS

              
                body {
  font-family: 'Lato', sans-serif;
}

.wrapper {
  max-width: 960px;
  margin: 10px auto;
}


select {
  width: 100%;
  display: block;
  box-sizing: border-box;
  padding: 0 10px;
  height: 40px;
  margin-bottom: 15px;
  border: 1px solid #cdcdcd;
  outline: none;
}

.oneFAQ {
  margin: 0;
  border-radius: 4px;
  border-top: 1px solid gray;
  border-bottom: 1px solid gray;
}

.question {
  background-color: #ececec;
  padding: 7px 15px;
  cursor: pointer;
}

.answer {
  background-color: #fbfbfb;
  position: absolute;
  visibility: hidden;

  padding: 7px 15px;
}

.headline {
  font-size: 2.2rem;
}

.headline__med {
  font-size: 1.5rem;
}

.headline__text {
  font-size: 1.25rem;
}

.headline--bold {
  font-size: 1.5rem;
}

.show {
  position: relative;
  visibility: visible;
}

              
            
!

JS

              
                function toggleOff(e) {
  // Colasping all the FAQs items
  let AllAnswer = document.querySelectorAll(".answer");
  AllAnswer.forEach((answer) => {
    if (answer !== e) {
      answer = answer.classList;
      answer.remove("show");
    }
  });

  // Showing only the clicked FAQ item
  let answer = e.querySelector(".answer").classList;
  answer.contains("show") ? answer.remove("show") : answer.add("show");
}

document.addEventListener("DOMContentLoaded", (event) => {
  let headline = document.getElementById("main-headline");
  let FAQs = document.querySelectorAll(".oneFAQ");
  const FAQsArr = Array.from(FAQs);

  headline.innerHTML = `${headline.innerHTML} (${FAQsArr.length})`;
});

              
            
!
999px

Console