Simple FAQ Section using HTML, CSS & JavaScript

Simple FAQ Section using HTML, CSS & JavaScript

Simple FAQ Section using HTML, CSS & JavaScript

In this article, I have shown you how to create a Simple FAQ Section using HTML CSS, and JavaScript. Earlier I shared with you the design of many more types of FAQ Accordion Section. This design has been created by Jquery. 

Here HTML and CSS are used for design and JQuery for implementation. The jQuery used here is absolutely simple you will understand very easily. HTML FAQ Section We see on different websites. 

We see this type of Accordion Section for many types of business, service, personal websites. Where some common questions and answers about the service or product are given in advance. So that it is not difficult to know the necessary information of the customer or user. 

FAQ Accordion HTML CSS

The design I have used here is absolutely responsive and ready. You can use it directly on your website. It is made of finished color flowers which further enhances the beauty. 

Four headings have been used here and information about it has been used. Which used HTML CSS to design and JQuery to implement. Below I have given a live preview that will help you to know how this FAQ Accordion Section works.

See the Pen
Untitled
by Foolish Developer (@foolishdevweb)
on CodePen.

As you can see above, this is a simple FAQ section that has four headings. There is a lot more information in those four headings. You can add many more headings of your choice here if you want. 

The background color of the headings in blue. When you click on it, an area will be created below it where more information can be found.

How to Create FAQ Accordion Section

To create this JavaScript FAQ Section you need to have a basic idea about HTML CSS and JavaScript. First, you create an HTML and CSS file. Even if you don’t create a javascript file here. You can add those JavaScript directly to the HTML file. 

I have not shared any tutorial here. I have already shared many such tutorials. So here I have just given the source code which you will copy and use in your work.

HTML Code ( index.html ):

The following code is the HTML code used to create this FAQ Section HTML CSS. Contains all types of text and information. You copy them directly and add them to your HTML file. Four headings and their information have been added here.

<!DOCTYPE html>
<html lang=“en”>
<head>
  <meta charset=“UTF-8”>
  <meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
  <meta http-equiv=“X-UA-Compatible” content=“ie=edge”>
  <title>Document</title>
  <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css”>
  <link href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css” rel=“stylesheet”>
  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js” charset=“utf-8”></script>
  <!– CSS file –>
  <link rel=“stylesheet” href=“style.css”>
</head>
<body>
   <section id=“faq”>
    <div class=“container faq”>
      <div class=“container”>
        <div class=“row”>
          <div class=“col-sm-12”>
            <div class=“accordions”>
              <!– 1st accordion menu –>
              <div class=“accordion-item”>
                <div class=“accordion-title” data-tab=“item4”>
                  <h3>Free DDOS Protection <i class=“fa fa-chevron-down”></i></h3>
                </div>
                <div class=“accordion-content” id=“item4”>
                  <p>
                    Unlike other providers who charge extra for DDoS protection, All of our VPS
                    servers comes
                  </p>
                </div>
              </div>
              <!– 2nd accordion menu –>
              <div class=“accordion-item”>
                <div class=“accordion-title” data-tab=“item2”>
                  <h3>What is Windows VPS? <i class=“fa fa-chevron-down”></i></h3>
                </div>
                <div class=“accordion-content” id=“item2”>
                  <p>
                    With a Windows VPS server, you will get a Remote Desktop connection within a few
                    minutes. You can run Windows applications such as IIS, SQL, Microsoft Exchange
                    or any software like Docking,
                  </p>
                </div>
              </div>
              <!– 3rd accordion menu –>
              <div class=“accordion-item”>
                <div class=“accordion-title” data-tab=“item3”>
                  <h3>Payment Options <i class=“fa fa-chevron-down”></i></h3>
                </div>
                <div class=“accordion-content” id=“item3”>
                  <p>
                    Unlike most other providers you don’t have to pay with just Credit Card or
                    PayPal. You can also
                  </p>
                </div>
              </div>
              <!– 4th accordion menu –>
              <div class=“accordion-item”>
                <div class=“accordion-title” data-tab=“item1”>
                  <h3>Why FutureRDP? <i class=“fa fa-chevron-down”></i></h3>
                </div>
                <div class=“accordion-content” id=“item1”>
                  <p>
                    Germany, Netherlands, and Canada. We have a range
                    of different solutions for different purposes such as SSD VPS and Storage
                    servers. All servers are equipped with RAID10 only SSD drives and FREE DDoS
                    Protection!
                  </p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
  <!– JavaScript–>
  <!–
    <script>
      Add javascript code
    </script>  
  –>
</body>
</html>

CSS Code ( style.css ):

The following codes are the CSS codes used to design it. Above we have added all the information using HTML code. Now all this information has been designed by CSS code. 

You copy the code and add it to your CSS file. Rename your CSS file to style.css. I have already attached the CSS file to the HTML file.

.accordions {
width: 80%;
margin: 100px auto;
}
.accordions h3 {
text-align: center;
font-weight: bold;
font-family: “Roboto”, sans-serif;
}
.accordion-item {
background-color: #0b3791;
border-radius: 5px;
color: #ffffff;
margin-bottom: 20px;
border: 1px solid #100e34;
}
.accordion-item .accordion-title {
cursor: pointer;
padding: 20px;
transition: transform 0.4s ease-in-out;
}
.accordion-item .accordion-title.active-title {
background-color: #100e34;
color: #ffffff;
}
.accordion-item .accordion-title h3 {
font-weight: 700;
margin: 0;
justify-content: space-between;
font-weight: bold;
font-size: 18px;
display: flex;
}
.accordion-item .accordion-title i.fa-chevron-down {
transform: rotate(0);
transition: 0.4s;
}
.accordion-item .accordion-title i.fa-chevron-down.chevron-top {
transform: rotate(-180deg);
color: #fa5019;
}
.accordion-item .accordion-content {
display: none;
line-height: 1.7;
color: #100e34;
padding: 20px;
background-color: #ffffff;
border-radius: 0 0 5px 5px;
}
.accordion-item .accordion-content.active {
display: block;
}
.accordion-item .accordion-content p {
margin: 0;
font-size: 16px;
font-family: “Nunito Sans”, sans-serif;
}
.details {
background: #dce1f2;
}
.details .detailed_info {
margin: 50px auto;
}
.details img {
margin: 0 auto;
display: block;
}
.details h3 {
font-weight: bold;
font-size: 20px;
font-family: “Poppins”, sans-serif;
}
.details p {
font-size: 16px;
line-height: 1.5em;
font-family: “Nunito Sans”, sans-serif;
}
.details ul li {
font-size: 16px;
line-height: 1.7em;
font-family: “Nunito Sans”, sans-serif;
}

JavaScript Code:

Now is the time to implement this simple FAQ Section with the help of Jquery. We have already done all the design work. Now jQuery is used here. If you do not understand jQuery then you can see other designs made by me. 

I have already shared many HTML FAQ Section tutorials created using JavaScript. Copy the following JavaScript and add it to the HTML file. You can create separate JavaScript files if you want.

 
  $(document).ready(function () {
    $(“.accordion-title”).click(function (e) {
      var accordionitem = $(this).attr(“data-tab”);
      $(“#” + accordionitem)
        .slideToggle()
        .parent()
        .siblings()
        .find(“.accordion-content”)
        .slideUp();
      $(this).toggleClass(“active-title”);
      $(“#” + accordionitem)
        .parent()
        .siblings()
        .find(“.accordion-title”)
        .removeClass(“active-title”);
      $(“i.fa-chevron-down”, this).toggleClass(“chevron-top”);
      $(“#” + accordionitem)
        .parent()
        .siblings()
        .find(“.accordion-title i.fa-chevron-down”)
        .removeClass(“chevron-top”);
    });
  });

Hopefully using the above codes you have learned how to create an FAQ Accordion Section. If there is any difficulty then you can definitely let me know by commenting. I have already shared many more such tutorials using different types of programming code.