Build Tabs Using HTML/CSS In Only 12 Minutes

Поділитися
Вставка
  • Опубліковано 26 сер 2024
  • 🚨 IMPORTANT:
    Learn CSS Today Course: courses.webdev...
    Tabs are one of the most common forms of navigation on a website, but they can be tricky to implement correctly. In this video I will show you exactly how to create tabs using HTML, CSS, and JavaScript as quickly as possible. We will cover how to switch tabs when clicked, how to indicate which tab is selected and much more. I will also be explaining every line of code as I write it so you can see exactly why everything works.
    📚 Materials/References:
    GitHub Code: github.com/Web...
    CodePen Code: codepen.io/Web...
    🧠 Concepts Covered:
    - How to create tabs in HTML/CSS/JS
    - How to hide/show elements on click
    - How to move classes between elements
    - Using data attributes to dynamically select elements
    🌎 Find Me Here:
    My Website: webdevsimplifi...
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/Web...
    CodePen: codepen.io/Web...
    #HTMLTabs #WDS #CSSTabs

КОМЕНТАРІ • 188

  • @CustardyRhubarb
    @CustardyRhubarb 4 роки тому +25

    I love these short tutorials on specific tasks - it's a great way to learn.

  • @AnnieTaylorChen
    @AnnieTaylorChen 5 років тому +19

    a few years ago I wanted something like this so bad, but had no idea how to do that on wordpress. It's actually pretty easy if you can code. :) Coding is truly empowering!

    • @WebDevSimplified
      @WebDevSimplified  5 років тому +18

      Coding really is great. It gives you super powers to create anything you can think of.

    • @yolo-mb4cy
      @yolo-mb4cy 5 років тому +1

      @@WebDevSimplified truth spoken

    • @acesgndec2535
      @acesgndec2535 3 роки тому +1

      @@WebDevSimplified Very True

  • @bluffer8352
    @bluffer8352 3 роки тому +4

    This was very well explained, thank you.
    Few things for feedback:
    Could've used *{} for the padding and margin that needed to be removed, it might have made more sense to do it the way you did though.
    Not everyone is so familiar with arrow functions, that's only part of this that I got confused as I don't use.

  • @mobile_genshin
    @mobile_genshin Рік тому +1

    Wow, any request I make while studying web dev, this channel has an answer, amazing👏

  • @elguneliko8658
    @elguneliko8658 3 роки тому +1

    i did it on my own way and i am happy.It is around 10 week i started work on java script Your videos helps me so much

  • @wanharaziz3055
    @wanharaziz3055 4 роки тому +6

    At 6:37 my code is not running although I have copied exactly the same thing u have written sir. Please help you are really incredible!

    • @petra9313
      @petra9313 2 роки тому

      It is the same for me

  • @macrepman4098
    @macrepman4098 Рік тому +5

    You should explain it slower, for people trying to follow along it's difficult to understand what you're doing when you're basically talking like you're reviewing for yourself instead of teaching.

  • @bikramchettri9405
    @bikramchettri9405 5 років тому +5

    Superb tutorial very helpful indeed

  • @user-lx7os4is7w
    @user-lx7os4is7w 8 місяців тому

    Very Well Explained every things one by big support dear!

  • @hallie342
    @hallie342 4 роки тому +3

    I’m not really understanding the JavaScript part of this. Do you by any chance know any good beginner resources for that?

  • @fu2201
    @fu2201 2 роки тому

    This guy is a robot, he does not blink

  • @propZone-DE
    @propZone-DE Місяць тому

    Very good explaination 👍

  • @sabuein
    @sabuein 2 роки тому

    Again, thank you, Kyle.

  • @dainah105
    @dainah105 Рік тому

    you're a legend thank you

  • @alejo_3d_art
    @alejo_3d_art 4 роки тому +1

    Thank you... Even I don't know yet any of Js I could make it work. Great job

    • @ehsmetlemcen
      @ehsmetlemcen 4 роки тому

      you can also check this awesome animated tabs ua-cam.com/video/d9MW5nPIgSk/v-deo.html

  • @3060PlayZ
    @3060PlayZ 3 роки тому +1

    Thanks so much! I made them look way cooler!

  • @brunobrasil3419
    @brunobrasil3419 8 місяців тому

    Thanks a lot, bro!

  • @mesteme
    @mesteme 4 роки тому +3

    0:34 "…which when we highlight over them, it's just going to hover a little colour" 😃I have e friend who sometimes inverts words like that

  • @Jayjay-cg2in
    @Jayjay-cg2in 5 років тому +3

    Great video kyle!

  • @michawojciechowski827
    @michawojciechowski827 2 роки тому

    Thank you. I need this in my project.

  • @TheType1Ninja
    @TheType1Ninja 3 роки тому +1

    Dude, you are amazingly helpful. Thank you.

  • @DiegatusStudios
    @DiegatusStudios 4 роки тому +1

    Thank you so much for this! It works perfectly!

  • @Garfield2142
    @Garfield2142 4 роки тому

    Great place to start. Thanks!

  • @danielschmitt5750
    @danielschmitt5750 4 роки тому +1

    I totally forgot about data attributes. Thanks for reminding me ;-)

  • @clilsneor624
    @clilsneor624 3 роки тому +1

    Really clear and great tutorial, thanks a lot!

  • @kronstadt662
    @kronstadt662 3 роки тому

    Thank you, you saved my life...the code work perfect

  • @fabriziotofanelli
    @fabriziotofanelli 5 років тому +2

    amazing content as usual.... just missed one little thing... a hash on url... so I could send to someone the right place instead to say to her where to click ... what you think? =)

    • @WebDevSimplified
      @WebDevSimplified  5 років тому +1

      That is a great point. This would be a good thing to add on yourself since it isn't too difficult, but does test quite a lot of JavaScript skills.

    • @yolo-mb4cy
      @yolo-mb4cy 5 років тому

      Tell me what u found out then

    • @colinzervas
      @colinzervas 3 роки тому

      Do you have an example of this somewhere? I’ve been looking and cannot find this and am looking for this exact functionality so that if I share a link with someone it will open the correct tab. Thank you in advance!

  • @73dines
    @73dines 5 років тому +2

    Very well done.
    Thanks!

  • @patrickmohrmann6540
    @patrickmohrmann6540 3 роки тому

    Very nice videos. I just stumbled recently across them

  • @AlexIvanov-uh1yz
    @AlexIvanov-uh1yz 2 роки тому

    thx kayl, easy and fast!

  • @shehariyarbacker8456
    @shehariyarbacker8456 4 роки тому +2

    Hello Sir your tutorial is really wonderful. If I want to add another layer of tabs say inside each of the home, pricing or about how do I tweak the code to achieve that. For example in Pricing I would like to add a product category list and each list having certain products. Is it achieved by nesting further loops?

    • @DiegatusStudios
      @DiegatusStudios 4 роки тому +1

      Same question here

    • @andyli2927
      @andyli2927 2 роки тому

      from what i understand, i think you can somehow try to figure out a way to maybe remove the other target tabs? when you click on pricing. Then after clicking on pricing you set the other tabs you want on the pricing tabs, visible. these are just my fundamentals, not exactly sure how to code it Lol. give it a try though, same for me

  • @MontyKsycki
    @MontyKsycki 4 роки тому

    Thank You Very Much for Sharing!!! Very Much Appreciated!!! :) 🙏 🙏 🙏 🙏 🙏

  • @heavydirtysoul1491
    @heavydirtysoul1491 4 роки тому +1

    great tutorial, thank you

    • @ehsmetlemcen
      @ehsmetlemcen 4 роки тому

      you can also check this awesome animated tabs ua-cam.com/video/d9MW5nPIgSk/v-deo.html

  • @nestanettamiru2987
    @nestanettamiru2987 Рік тому +1

    Pls do it , step by step

  • @DailyIntern
    @DailyIntern 5 років тому +1

    You are awesome. The way you type i wish i can do it too.

  • @robertbiljaka665
    @robertbiljaka665 4 роки тому +2

    I can't change a tab. I'm only looking at the home tab content.
    Pls help!!!

    • @kontanchis2263
      @kontanchis2263 3 роки тому

      if u need help, use the github code, is in the descripiton

  • @pipepi4888
    @pipepi4888 4 роки тому

    gracias por el video. Eres lo mejor. Cuídate mucho

  • @hectorlgg
    @hectorlgg 4 роки тому

    Excelente, aprendi bastante... Thanks.

    • @ehsmetlemcen
      @ehsmetlemcen 4 роки тому

      you can also check this awesome animated tabs ua-cam.com/video/d9MW5nPIgSk/v-deo.html

  • @ramlynjaysaure3601
    @ramlynjaysaure3601 Рік тому

    thanks

  • @hectorPerez-qf1ho
    @hectorPerez-qf1ho 2 роки тому

    thanks, wonderfull tuto

  • @blakecraft9506
    @blakecraft9506 4 роки тому

    THANK YOU SO MUCH! IM DEFINITELY SUBSCRIBING!😊

  • @carlosvalenciah8306
    @carlosvalenciah8306 3 роки тому

    thank you senior,

  • @roanmaravillo8342
    @roanmaravillo8342 3 роки тому

    Thankyou Kyle thumbs up

  • @deevagh
    @deevagh 4 роки тому

    this is awesome. Thank you !

    • @ehsmetlemcen
      @ehsmetlemcen 4 роки тому

      you can also check this awesome animated tabs ua-cam.com/video/d9MW5nPIgSk/v-deo.html

  • @walmartbag777
    @walmartbag777 2 роки тому +1

    Build Tabs Using HTML/CSS In Only 12 Minutes. Me when the: JS

  • @zainulkhan8381
    @zainulkhan8381 2 роки тому

    Can someone please explain me this line
    const target = document.querySelector(tab.dataset.tabTarget)
    he said that tabTarget will target your HTML I am not able to understand what is the use of dataset and tabTarget else the whole code is clear

  • @thatomhp1238
    @thatomhp1238 2 роки тому

    hi i tried adding more than 3 tabs but the other tabs dont show any content ihave placed

  • @conexoesind6478
    @conexoesind6478 3 роки тому +1

    Any thoughts on having these tabs automatically loop with varied timer like a carousal and also clickable at same time. How could it be made to show automatically? Please help Kyle or anyone else who is reading this comment. Thanks

  • @rohanphadnis6812
    @rohanphadnis6812 2 роки тому

    i want to have multiple of these tab sections on one page, but when i just copy and paste the code, it gets messed up. How do i fix this?

  • @blakecraft9506
    @blakecraft9506 4 роки тому +5

    Um, it's not working. 🤔

    • @kontanchis2263
      @kontanchis2263 3 роки тому +1

      just use the github code, is in description

  • @tochimclaren
    @tochimclaren 29 днів тому

    What is th different between: .class[data-attribute] and [data-attribute].class

  • @dallasshelby6501
    @dallasshelby6501 2 роки тому

    How can I make this work when nesting the tabs? I tried changing data-tab-target to idata-tab-target and it would work. apparently, I cannot change data-tab-target. If I do the querySelector returns null. Please help.

  • @tomasgrudny2870
    @tomasgrudny2870 2 роки тому

    Having some trouble with the tab content not appearing on any of the tabs apart from the first one. Any idea what could be wrong?

  • @VincentOldMark
    @VincentOldMark 4 роки тому

    hey how do you style each data-tab-content individually thanks for your help

  • @basharawwad5451
    @basharawwad5451 Рік тому

    Thanks a lot for this great tutorial, actually I have one problem, I followed all the steps shown in this video, but when I click the tab, the content will appear once and immediately will disappear. I check the debugging in console and found the active class is added but then it is removed. I do not know what is causing this problem. Any Idea?
    Thanks in advance

  • @eliasblankenburg1497
    @eliasblankenburg1497 2 роки тому

    Is it possible to add a transition between the text changes?

  • @konstantinkkk8397
    @konstantinkkk8397 3 роки тому +1

    pls chage heading of your video. You use html/css/js

  • @scubet2094
    @scubet2094 3 роки тому

    could you help me a little bit, at 3:58 for the query selection, you use a square bracket in the code line ("[data-tab-target]"), why is this done I cant find any answers online

  • @icemayne
    @icemayne Рік тому

    does is automatically update? i have everything typed in as you and the website wont load

  • @OrincyWhyteDesigns
    @OrincyWhyteDesigns 2 роки тому

    Omg thank you !!!
    Only think I’m blanking on is at 4:34, What is the tab.dataset.tabTarget? Why was it written like that? 🤔

    • @zainulkhan8381
      @zainulkhan8381 2 роки тому

      Did you got the answer ? I asked the same doubt you can check the recent comment

  • @ultronsam1214
    @ultronsam1214 2 роки тому

    I did the same you did. The console be telling that tabs.forEach is not a function. Did I go wrong with something?

  • @Epanyo
    @Epanyo 2 роки тому

    One question like how to use pictures as tabs?

  • @Xx_YourM0M_xX
    @Xx_YourM0M_xX 2 роки тому

    Amazing

  • @aroundjavascript1454
    @aroundjavascript1454 4 роки тому

    Thank you so much

    • @ehsmetlemcen
      @ehsmetlemcen 4 роки тому

      you can also check this awesome animated tabs ua-cam.com/video/d9MW5nPIgSk/v-deo.html

  • @bssgiridhar
    @bssgiridhar Рік тому

    Make a poll with realtime pie chart result same webpage using html css javascript

  • @C_Ariss
    @C_Ariss 5 років тому +1

    Hello, I am trying to create my first ever test website. Generally is it good practise to have all tab content information in the one HTML file and use data attributes (like in this video) to show the content you want to see, based on the tab you have clicked on, or is it best to have separate HTML files for the separate tab page content and use a refs to select them? Sorry if its a daft question but I have seen it done both ways, and don't know the benefits of either yet.

    • @WebDevSimplified
      @WebDevSimplified  5 років тому +2

      It depends. If you have a small amount of highly related content then tabs are a good idea, but it is more complex to create so if you have lots of differing content such as an about and home page then doing separate HTML pages is probably best.

    • @C_Ariss
      @C_Ariss 5 років тому

      @@WebDevSimplified thank you Kyle :) i will go with separate HTML pages for now, just so its less on one page for me to look at whilst i'm still getting use to everything. Been working on this nearly an hour and only just finished my nav bar!

    • @WebDevSimplified
      @WebDevSimplified  5 років тому +1

      @@C_Ariss Separate pages is almost always the right answer so that is a good choice.

  • @jgeurts8343
    @jgeurts8343 Рік тому

    Hey Hey. I have a question. I already build a base of the website and wanted to implement this into it. But i have no idea how i could get the base that i already had into the Home tab? do you have a video for that or a short Turtorial?

  • @fb7230
    @fb7230 2 роки тому

    I have done this in Vs Code, but could not get it to work. So I tried to debug the code in VS code and could not get that to work. Is it possible to debug this lesson in Vs code, and if so, what are the appropriate extensions and settings (especially for json if any). thanks

  • @Hyper-pixel-official
    @Hyper-pixel-official 2 роки тому +1

    hello, i have written all of my css and javascript code but I,m not able to click on any tabs. I have done everything you showed in the video step by step, but I'm still not able to click on stuff. Any help from you OR the community would be very much appreciated.(If this video is still relevant) Thanks for the video btw.(the code is not working here 6:37)

    • @tomasgrudny2870
      @tomasgrudny2870 2 роки тому

      Same issue

    • @Hyper-pixel-official
      @Hyper-pixel-official 2 роки тому

      i was able to fix the issue while watching your "how to create responsive navbar" video. thanks @ Web Dev Simplified

  • @vitamax3777
    @vitamax3777 4 роки тому

    hi! how we can change the color of tabs?
    For exaple:
    first-tab->bacground: red ,
    and second-tab->background: green.
    If tab is active it should be different background color

    • @WebDevSimplified
      @WebDevSimplified  4 роки тому

      You just need to use CSS to do that. You can apply a background-color to them and use classes to add different styles to different tabs.

  • @KenCoppola
    @KenCoppola 3 роки тому

    I'm trying to implement this in Angular 12. Is there a way to use the tab.dataset.tabTarget in Angular? I keep getting property dataset does not exist on type Element.

  • @GamerKittyEuphoric
    @GamerKittyEuphoric Рік тому

    I need this with CSS / HTML only for sites who block Script

  • @user-cu1zj3wr1d
    @user-cu1zj3wr1d 5 місяців тому

    why do i need to use the data tab why just using css to do all stuff ?

  • @omergunes56
    @omergunes56 2 роки тому +1

    Yes html and css only + javascript

  • @RGW-p4s
    @RGW-p4s 2 роки тому

    i did everything like in the video but i can not select between tabs. can somebody say why?

  • @joseluisnm8499
    @joseluisnm8499 Рік тому

    Awesomee

  • @adomwest6117
    @adomwest6117 2 роки тому

    I thought we were not supposed to use the H1 to stylize multiple items?

  • @BurstFlare
    @BurstFlare 2 роки тому

    Hi, question. Is there a way to have tabs influence stuff outside of them somehow? Like, for example, changing the background color of a div that exists outside of the tabs depending on which tab is open?

  • @sirdeeq_wada
    @sirdeeq_wada 2 роки тому

    Did everything you did and still didn't achieve my goal. The pricing and about tab doesn't click and only the home tab shows.

  • @yourfellowmuslimyagi2065
    @yourfellowmuslimyagi2065 4 роки тому

    Thank you

    • @ehsmetlemcen
      @ehsmetlemcen 4 роки тому

      you can also check this awesome animated tabs ua-cam.com/video/d9MW5nPIgSk/v-deo.html

  • @youtubexviii8894
    @youtubexviii8894 2 роки тому +1

    why isnt JS in the Titel

  • @arazturk2690
    @arazturk2690 3 роки тому

    that was perfect

  • @randomvidoes
    @randomvidoes 3 роки тому

    Make a video on HTML 6 and CSS 4.

  • @arpitbharadwaj8799
    @arpitbharadwaj8799 3 роки тому

    what is tab.dataset.tabTarget???

  • @Bangtan4Life13
    @Bangtan4Life13 4 роки тому

    can I used this in forumfree?

  • @UnknownUser-ts1sw
    @UnknownUser-ts1sw 3 роки тому

    when I try to replace [data-tab-content] using class it doesn't work but why?
    anyone?

  • @nafismolla5946
    @nafismolla5946 3 роки тому

    just a quick question why is the # needed for the data attribute names

  • @charlesxavier77
    @charlesxavier77 5 років тому

    Awesome, I was actually really looking for 1 of those. I didnțt really get the tab.dataset.tabTarget, especially the tabTarget. Will you do a carousel tutorial? Like the bootstrap one? There is no tutorial for that. I built one but I canțt make it start over and move on a set time.

    • @WebDevSimplified
      @WebDevSimplified  5 років тому +1

      The idea of a carousel is on my list of ideas but it is pretty low right now.

    • @maksymantoshkin2896
      @maksymantoshkin2896 5 років тому +4

      node.dataset is built in property for each DOM node. It is an object containing every attribute that begins with data- of an actual hard-coded DOM element in camelCase. For example will have property div.dataset.lolLol

    • @charlesxavier77
      @charlesxavier77 5 років тому

      @@maksymantoshkin2896 ooo so the data-tab-target turn into tabTarget?

    • @maksymantoshkin2896
      @maksymantoshkin2896 5 років тому +2

      @@charlesxavier77 Yes, indeed!

    • @charlesxavier77
      @charlesxavier77 5 років тому

      @@maksymantoshkin2896 ty

  • @ColePerrine
    @ColePerrine 4 роки тому

    What are the odds you have this written out somewhere that I can just copy-paste because I have to be fucking up somewhere. As soon as I get to the display: block; part it stops working for me

  • @alternativerey5127
    @alternativerey5127 3 роки тому

    wonderful

  • @abigailtesfaye3122
    @abigailtesfaye3122 3 роки тому

    8:27

  • @TK-oj7id
    @TK-oj7id 3 роки тому

    how do i use this on notepad++

  • @digitalsols
    @digitalsols 4 роки тому +1

    Nice

  • @cherry-lp8yq
    @cherry-lp8yq 4 роки тому +3

    OMG, this is so complicated :'( :'(. no, it's not I just don't know about the data attribute.

  • @renzgamingmeister830
    @renzgamingmeister830 2 роки тому

    click is not working for me :/

  • @nurlanhuseynov1807
    @nurlanhuseynov1807 4 роки тому

    Thanks

  • @darios8564
    @darios8564 4 роки тому

    How would you make proper links to those tabs so we can achieve following:
    1. We can send direct link to certain tab
    2. We can refresh tab it doesn't switches back to default active tab
    Thank you!

  • @nirozanananr3188
    @nirozanananr3188 4 роки тому

    Super dude

    • @ehsmetlemcen
      @ehsmetlemcen 4 роки тому

      you can also check this awesome animated tabs ua-cam.com/video/d9MW5nPIgSk/v-deo.html

  • @abdulrahmanemad1484
    @abdulrahmanemad1484 3 роки тому

    nice!

  • @chirilcugureanu1853
    @chirilcugureanu1853 4 роки тому

    Wow, with this method you can create a single website with more tabs, which can look like a navbar and make someone think this is a one page application 😆