New Self New Life
No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
New Self New Life
No Result
View All Result
Home Softwares

HTML-Only Accordion [Article] | Treehouse Blog

by admin
3 years ago
in Softwares
HTML-Only Accordion [Article] | Treehouse Blog
Share on FacebookShare on Twitter


Accordions are everywhere in the net and cellular apps. They’re an effective way to indicate and conceal content material based mostly on person interplay and aren’t very onerous to construct however normally require a little bit of HTML, CSS and JavaScript. Do you know you can construct a easy accordion in simply seconds with solely HTML? Comply with alongside as I clarify how you can set this up!

The HTML accordion requires solely two HTML tags to get arrange. <particulars> and <abstract>. The essential code construction would appear to be this:

<particulars>
   <abstract></abstract>
<particulars>

The particulars HTML tag

The <particulars> tag acts as a wrapper for our accordion. All the content material on your accordion should go inside the <particulars> tag.

The abstract HTML tag

The <abstract> tag is normally used on your title. Earlier than the accordion is clicked, that is the content material that’s seen and can all the time stay seen.

Including content material to an accordion

So as to add content material to the accordion when the person clicks it’s fairly easy. Any content material beneath the <abstract> tags can be hidden by default. This content material may very well be something from some paragraph tags, an ordered record, pictures, hyperlinks, you title it. As soon as the person clicks the accordion, this content material can be seen.

Right here is a few fundamental content material:

<particulars>
   <abstract>
      <h1>Todo record:</h1>
   </abstract>
   <p>Examine</p>
   <p>Grocery Store</p>
   <p>Clear The Home</p>
</particulars>

Earlier than the person clicks, that is what the accordion will appear to be:

As soon as the person clicks:

Fairly cool, with just some strains of markup, we constructed a functioning accordion! As you’ll be able to see it’s not the very best wanting accordion on the market. No worries although, we will type it fairly simply!

The right way to Model an HTML Accordion

Styling your accordion may be very a lot as much as you and the way you’d like for it to look, however be happy to comply with alongside as I give just some fundamental stylings to the one we created above.

particulars {
    width: 250px;
    padding: 1rem;
    border-radius: 8px;
    background: white;
    box-shadow: 4px 4px 3px rgba(0,0,0,0.15);
}

To the particulars CSS rule, ive added a set width, some padding, a border-radius, background shade, and a few box-shadow. Subsequent we will type up our <abstract> tag.

abstract {
    cursor: pointer;
}
abstract h1 {
    show: inline;
    margin-left: 1rem;
    font-size: 1.25rem;
}

Very first thing you’ll discover is I gave our abstract a cursor: pointer. That is simply so the accordion seems that it may be clicked to the person.

I then give some fundamental stylings to the h1 component in order that it may well stay on the identical line as our caret that comes with the accordion menu by default. Some margin and a bigger font-size has been added as nicely.

Lastly, we will type the paragraph tags we added by writing the next:

particulars p {
    margin-left: 1.75rem;
    opacity: 0.7;
}

And that’s about it. We now have a a lot cooler wanting accordion!

I hope you loved establishing an accordion with simply HTML with me. Be happy to tell us should you’d prefer to see how you can construct a good nicer accordion with HTML, CSS, and JavaScript subsequent!

Till subsequent time, have enjoyable and glad coding!



Source link

Tags: AccordionArticleBlogHTMLOnlyTreehouse
Previous Post

Microsoft Dev Box preview allows developers to create on-demand workstations

Next Post

What Do Travelers Desire Out of Their Vacation?

Related Posts

User Guide For UnoPim PDF Generator
Softwares

User Guide For UnoPim PDF Generator

by admin
May 31, 2025
Infragistics Ultimate 25.1 includes updates across several of its UI toolkit components
Softwares

Infragistics Ultimate 25.1 includes updates across several of its UI toolkit components

by admin
May 29, 2025
Qt bridges the language barrier gap
Softwares

Qt bridges the language barrier gap

by admin
May 28, 2025
Find the Best Rust Software Developers for Your Project
Softwares

Find the Best Rust Software Developers for Your Project

by admin
May 26, 2025
Verification framework uncovers safety lapses in open-source self-driving system
Softwares

Verification framework uncovers safety lapses in open-source self-driving system

by admin
May 23, 2025
Next Post
What Do Travelers Desire Out of Their Vacation?

What Do Travelers Desire Out of Their Vacation?

Grim Reaper Vocalist Steve Grimmett Has Died at 62

Grim Reaper Vocalist Steve Grimmett Has Died at 62

  • Trending
  • Comments
  • Latest
Anant Ambani wedding: Celebs, wealthy elite attend lavish billionaire festivities – National

Anant Ambani wedding: Celebs, wealthy elite attend lavish billionaire festivities – National

March 1, 2024
10 really good gadgets that cost less than $100 – TechCrunch

10 really good gadgets that cost less than $100 – TechCrunch

December 17, 2021
Every Kathryn Hahn Film Performance, Ranked

Every Kathryn Hahn Film Performance, Ranked

December 24, 2022
Best Coding Practices For Rest API Design

Django Form | Data Types and Fields

June 9, 2023
Advancement in predicting software vulnerabilities

Advancement in predicting software vulnerabilities

May 21, 2022
Most Useful Gadgets in 2021 – Nogentech.org

Most Useful Gadgets in 2021 – Nogentech.org

July 29, 2021
Deployment Diagrams Explained in Detail, With Examples

Deployment Diagrams Explained in Detail, With Examples

August 11, 2021
The 8 Most Underrated Mayhem Festival Bands, Year by Year

The 8 Most Underrated Mayhem Festival Bands, Year by Year

May 19, 2021
‘The Black Phone 2’ Dials In Some Ominous Teasers

‘The Black Phone 2’ Dials In Some Ominous Teasers

May 31, 2025
Nicola Peltz Beckham shares cryptic Instagram story amid ongoing rumours of a Beckham family feud

Nicola Peltz Beckham shares cryptic Instagram story amid ongoing rumours of a Beckham family feud

May 31, 2025
THE PHOENICIAN SCHEME Hilariously Quriky and One of Wes Anderson’s Best Movies — GeekTyrant

THE PHOENICIAN SCHEME Hilariously Quriky and One of Wes Anderson’s Best Movies — GeekTyrant

May 31, 2025
Mama June and Daughters Address Family Feud, Money Dispute and Raising Chickadee’s Kid

Mama June and Daughters Address Family Feud, Money Dispute and Raising Chickadee’s Kid

May 31, 2025
Insane Clown Posse Name Favorite Rock Bands, Best Nu-Metal Rapper

Insane Clown Posse Name Favorite Rock Bands, Best Nu-Metal Rapper

May 31, 2025
The Clipse’s ‘Ace Trumpets’: The 12 Best Lines

The Clipse’s ‘Ace Trumpets’: The 12 Best Lines

May 30, 2025
Google Maps falsely told drivers in Germany that roads across the country were closed

Google Maps falsely told drivers in Germany that roads across the country were closed

May 30, 2025
Indigenous Sex Worker Drama Seventeen Begins Production, Unveils Cast

Indigenous Sex Worker Drama Seventeen Begins Production, Unveils Cast

May 30, 2025
New Self New Life

Your source for entertainment news, celebrities, celebrity news, and Music, Cinema, Digital Lifestyle and Social Media and More !

Categories

  • Celebrity
  • Cinema
  • Devices
  • Digital Lifestyle
  • Entertainment
  • Music
  • Social Media
  • Softwares
  • Uncategorized

Recent Posts

  • ‘The Black Phone 2’ Dials In Some Ominous Teasers
  • Nicola Peltz Beckham shares cryptic Instagram story amid ongoing rumours of a Beckham family feud
  • THE PHOENICIAN SCHEME Hilariously Quriky and One of Wes Anderson’s Best Movies — GeekTyrant
  • Home
  • Disclaimer
  • DMCA
  • Privacy Policy
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites. slotsfree  creator solana token

No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites.

slot machine casino games online