FAQ accordion using HTML, CSS, JavaScript

In this tutorial we will learn how to create a FAQ accordion using HTML, CSS and JavaScript.
Basic JavaScript Toggling.
Music:
Track: N3WPORT - Castle (feat. Leila Pari) [NCS Release]
Music provided by NoCopyrightSounds.
Watch: • N3WPORT - Castle (feat... ​
Free Download / Stream: ncs.io/NCastle
Track: Jo Cohen & Sex Whales - We Are [NCS Release]
Music provided by NoCopyrightSounds.
Watch: • Jo Cohen & Sex Whales ...
Free Download / Stream: ncs.io/jcswweare
Thank You for Watching.
#htmlcss #accordion

Пікірлер: 85

  • @TochiEmenine
    @TochiEmenine Жыл бұрын

    A code that actually works, thank you. Really straightforward and short.

  • @Dreamingofrainbows
    @Dreamingofrainbows Жыл бұрын

    this tutorial was amazing, wow, I've learned so many new things and also new tricks about what I've used before, amazing! thank you, I'll be coming back for more tutorials!

  • @salentipy
    @salentipy2 ай бұрын

    This is a wonderful video! I'm just learning JavaScript and watching it done line-by-line is EXTREMELY helpful! Thank you!

  • @mozcoder
    @mozcoder8 ай бұрын

    Thank you for share this amazing video, you helped-me very much.

  • @al4n250
    @al4n2509 ай бұрын

    Fantastic video. I will for sure use some of the tricks that you have used.

  • @okolipeace774
    @okolipeace774 Жыл бұрын

    Thank you for this tutorial, it's really helpful and amazing. I learnt so much from it

  • @efekanefe442
    @efekanefe442 Жыл бұрын

    Thanks for the max-height trick i was trying to send my answers upwards with translateY and negative margin top values :D Finally making accordion components with animations. Have a nice day

  • @mudasarhussain2907
    @mudasarhussain29072 жыл бұрын

    A.o.A! Ur effort is really helpful for us,thanks alot

  • @wetsand7379
    @wetsand73792 жыл бұрын

    thank you, this was really simple to follow.

  • @catalinamarziali9786
    @catalinamarziali9786 Жыл бұрын

    Thank you very much! This tutorial was so helpful

  • @alexiscrespo1783
    @alexiscrespo17832 жыл бұрын

    Nice video !!! Good job bro, thanks !

  • @doneilchapman1542
    @doneilchapman15429 ай бұрын

    Really nice tutorial

  • @tasneemayham974
    @tasneemayham9747 ай бұрын

    THANK YOU THAT WAS REALLLYY COOOLL!!!!!!!!!

  • @londonching3343
    @londonching3343 Жыл бұрын

    Thank you bro, great video

  • @nikolanidzeks
    @nikolanidzeks Жыл бұрын

    Awesome job !

  • @jaspar797
    @jaspar797 Жыл бұрын

    Great, thank you very much!!

  • @abdulwaarithkehinde955
    @abdulwaarithkehinde955 Жыл бұрын

    Really nice tutorial. Very simple to follow. Thanks a lot for this.

  • @godmodeloss9345
    @godmodeloss93452 жыл бұрын

    Thank you! You're help me! ;)

  • @vivek5147
    @vivek51473 жыл бұрын

    Plz source code

  • @sephyrion9207
    @sephyrion92072 жыл бұрын

    @Developer Empire Thank you, all of it looks very good! Can you suggest a few excellent resources from where one could learn about SVG and advanced CSS? One of your lines there in CSS (line 65 I believe,) looks advanced to me, so I'd like to learn.

  • @swapnildhiman2032
    @swapnildhiman2032 Жыл бұрын

    Thanks it is really help full

  • @xayrullayevzafar
    @xayrullayevzafar Жыл бұрын

    Thank you very much!

  • @ob5804
    @ob5804 Жыл бұрын

    What if height of ech content is different?? Could you make a video when we 2-3 accordions js??

  • @ThisIsAbrarKhan
    @ThisIsAbrarKhan2 жыл бұрын

    How can we implement in blogger template

  • @hadiqadimi9540
    @hadiqadimi95408 ай бұрын

    very good thank you

  • @ayubitv03
    @ayubitv0316 күн бұрын

    Thank you bro..

  • @khasanboyerkinov
    @khasanboyerkinov7 ай бұрын

    thank you bro

  • @alexandrarudman1478
    @alexandrarudman1478 Жыл бұрын

    Alguien puede decirme los códigos para que abra solo 1 respuesta, al darle clic que se oculte la anterior.????

  • @aimbotcz8033
    @aimbotcz80338 ай бұрын

    thank you so much man😭

  • @2kproductions1
    @2kproductions1 Жыл бұрын

    thanks man👏👏

  • @dhanalakshmip1645
    @dhanalakshmip164510 ай бұрын

    Thakyou so so muchhhhhhh😍😍😍😍

  • @carlosz1858
    @carlosz18583 жыл бұрын

    thanks bro, u helped me so much

  • @mudasarhussain2907

    @mudasarhussain2907

    2 жыл бұрын

    Can uh help me bro?

  • @lilyyeh8607
    @lilyyeh86072 жыл бұрын

    thank you~~!

  • @mountmidia6780
    @mountmidia6780 Жыл бұрын

    Thank you!

  • @atulcodex7730
    @atulcodex77302 жыл бұрын

    Thank you :)

  • @bennisa8102
    @bennisa8102 Жыл бұрын

    Mine has more space between the title and the paragraph regardless of what margin or padding I try to use. Can someone help? The code is the same. Trust me. I've checked.

  • @user-cj6mo4en7i
    @user-cj6mo4en7i2 ай бұрын

    thank you so much

  • @akidzul7748
    @akidzul77483 жыл бұрын

    this helped so much, thank you! but can anyone explain why my arrow is only appearing half :( its like a half-v and looks more like a backslash for some reason. i think i followed the code closely but still couldnt determine what went wrong..would love to get some insight on this!

  • @Ditzj

    @Ditzj

    Жыл бұрын

    I had the same. Depends on your background. I had a white background, and then the white SVG line obviously disappears and the only part remaining is the black fill of the triangle. You would need to set: stroke="black" (or any color you need) and fill="transparant" (in the path options) to get rid of the small black triangle. The way it was shown here, it will only look good on a black background.

  • @ezajhossain

    @ezajhossain

    Жыл бұрын

    @@Ditzj thank you ❤️

  • @yskthegamer9033

    @yskthegamer9033

    Жыл бұрын

    @@Ditzj where exactly is "fill" ?

  • @Ditzj

    @Ditzj

    Жыл бұрын

    @@yskthegamer9033 as an example:

  • @shivanand0297
    @shivanand0297 Жыл бұрын

    nice

  • @sofaking6642
    @sofaking66422 жыл бұрын

    good shiz

  • @user-ig1wv4ev3y
    @user-ig1wv4ev3y9 ай бұрын

    thanks :)

  • @cotnegviniashvili5019
    @cotnegviniashvili50192 жыл бұрын

    can u give source cod?

  • @adnan8465
    @adnan84652 жыл бұрын

    thank you bro ,you have earned my respect

  • @sanadelayan688

    @sanadelayan688

    2 жыл бұрын

    Quick question was it responsive to you or not

  • @alini9749
    @alini9749 Жыл бұрын

    thanks

  • @ferni777
    @ferni777 Жыл бұрын

    can you please upload the source code?

  • @Techno_2709
    @Techno_27098 ай бұрын

    source code pls

  • @maridurai6178
    @maridurai61783 ай бұрын

    What this design name

  • @shardulpandey3
    @shardulpandey32 ай бұрын

    svg is not showing

  • @pawpawqwertyuiop
    @pawpawqwertyuiop9 ай бұрын

    под музычку норм)

  • @skillscrib6434
    @skillscrib6434 Жыл бұрын

    Do you have a document where i can copy this code both Html and css

  • @aidonline51

    @aidonline51

    10 ай бұрын

    please i need it too

  • @mudasarhussain2907
    @mudasarhussain29072 жыл бұрын

    But 1thing which can't understand (where is "active,s class ")plz help me

  • @Ditzj

    @Ditzj

    Жыл бұрын

    class=active get's set in the javascript when you click on the specific div-element

  • @jewelofnile2424
    @jewelofnile2424 Жыл бұрын

    Why do You set max 300? How do You know how much text everyone uses? For me it's bad example of accordion because it's not for future projects where you could have more text.

  • @adriancygan9391

    @adriancygan9391

    10 ай бұрын

    set max to fit-content

  • @vanshkhera206
    @vanshkhera2062 жыл бұрын

    is it responsive??

  • @AmirHossein_x86

    @AmirHossein_x86

    2 жыл бұрын

    yes,was

  • @Ludo045
    @Ludo0452 жыл бұрын

    i just dont fucking get it.. we have the same structure yet it doesnt work in my project..

  • @andressmendess

    @andressmendess

    Жыл бұрын

    me either, did you get it?

  • @yeyintaung9839

    @yeyintaung9839

    Жыл бұрын

    @@andressmendess I don't get it either. I copied the exact same thing and it still isn't working

  • @saidibra9231
    @saidibra92312 жыл бұрын

    when you click on another one is not closing ,?

  • @adnan8465

    @adnan8465

    2 жыл бұрын

    you are right, other remains open

  • @Ditzj

    @Ditzj

    Жыл бұрын

    It would have to look like this: faq.addEventListener("click", () => { if(!faq.classList.contains("active")){ faqs.forEach(faq => { faq.classList.remove('active'); })} faq.classList.toggle("active"); }); So check if the current clicked on FAQ is already active. If not, then remove the active class from all items, otherwise just toggle the active state.

  • @saidibra9231

    @saidibra9231

    Жыл бұрын

    @@Ditzj thank you

  • @lifeisbeautifu1
    @lifeisbeautifu12 жыл бұрын

    Thank you

  • @lolerkapich
    @lolerkapich Жыл бұрын

    gj

  • @kickdoe6793
    @kickdoe6793 Жыл бұрын

    The solution is not bad, but if you do not know the final maximum height, then difficulties arise here, if you specify the maximum height in auto, then the animation stops working, I still have not found solutions to this issue, if someone has a solution, please share

  • @hedikharouf297

    @hedikharouf297

    Жыл бұрын

    You can set the max-height to fit-content ( .faq.active .answer{max-height: fit-content;}

  • @kickdoe6793

    @kickdoe6793

    Жыл бұрын

    @@hedikharouf297 When you specify this property, the animation stops working.

  • @zxero69

    @zxero69

    7 ай бұрын

    I know I'm late, but if you want to do it without set max-height then u should put transform translateY(-100%) instead, and overflow hidden. Then for active class just bring back translate to 0

  • @HussnainHussnain-tu8ny
    @HussnainHussnain-tu8ny Жыл бұрын

    send me code html css js

  • @eliezer2987

    @eliezer2987

    9 ай бұрын

    send me code please

  • @syediqbalahmed3176
    @syediqbalahmed31763 жыл бұрын

    vulu ... ocay ...

  • @ryanjasperavendano2994
    @ryanjasperavendano2994 Жыл бұрын

    souce code :>>

  • @Duckergg.j
    @Duckergg.j Жыл бұрын

    It doesn't work 👎

  • @MusicRachael136
    @MusicRachael1362 жыл бұрын

    not a good tutorial!

  • @angelablanca7456
    @angelablanca74562 жыл бұрын

    Thank Youuuu

  • @user-co8br6ry7b
    @user-co8br6ry7b5 ай бұрын

    const faqs = document.querySelectorAll(".faq"); faqs.forEach(faq => { const question = faq.querySelector(".question"); const answer = faq.querySelector(".answer"); question.addEventListener("click", () => { if (faq.classList.contains("active")) { faq.classList.remove("active"); answer.style.maxHeight = null; } else { // закрытие других активных блоков faqs.forEach(otherFaq => { if (otherFaq.classList.contains("active")) { otherFaq.classList.remove("active"); otherFaq.querySelector(".answer").style.maxHeight = null; } }); faq.classList.add("active"); answer.style.maxHeight = answer.scrollHeight + "px"; } }); }); added hiding inactive blocks