Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

charles liscomb
charles liscomb
2,074 Points

Accordion not working

Hi, I cant seem to get the accordion to work. Here's my code

<!doctype html>
<html lang="en">
  <head>
    <title>Pure CSS Accordion</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="accordian.css"/>
  </head>
  <body>
    <div class="tab-group">
      <div class="tab">
        <input id="tab-one" type="radio" name="tabs"/>
        <label for="tab-one">Lable One</label>
            <div class="tab-content">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
            </div>
       <div class="tab">
        <input id="tab-two" type="radio" name="tabs"/>
        <label for="tab-two">Lable Two</label>
            <div class="tab-content">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
            </div>
       <div class="tab">
        <input id="tab-three" type="radio" name="tabs"/>
        <label for="tab-three">Lable Three</label>
            <div class="tab-content">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
            </div>
      <div class="tab">
        <input id="tab-four" type="radio" name="tabs"/>
        <label for="tab-four">Lable Four</label>
            <div class="tab-content">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
            </div>
    </div>
  </body>
</html>
.tab-group {
  margin:0 auto;
  max-width: 40em;
  width: 100%;
}

.tab {
  position: relative;
  width: 100%;
}

.tab input {
  position: absolute;
  left: 0;
  top: 0;
  z-index: -999;
}

.tab label {
  background: #72d2c6;
  color: #fff;
  display: block;
  font-weight: bold;
  line-height: 3;
  padding-left: .5em;
  margin-bottom: .5em;
  transition: letter-spacing .55s;
}

.tab input: focus + label,
.tab label: hover {
  background: #85d8ce;
  letter-spacing: 1px;
}

.tab-content {
  max-height: 0;
  overflow: hidden;
  transition: all .35s;
}

.tab-content p {
  margin: 1em 0;
}

.tab input: checked ~ .tab-content {
  max-height: 6.25em;
}

1 Answer

Alex Gervais
Alex Gervais
5,290 Points

You forgot to close 4 of your

elements.

Add

</div>
</div>
</div>

right above your

tag.