Home >Web Front-end >CSS Tutorial >How Can I Show and Hide Divs with Clicks Using Only CSS and HTML?

How Can I Show and Hide Divs with Clicks Using Only CSS and HTML?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-30 16:51:11813browse

How Can I Show and Hide Divs with Clicks Using Only CSS and HTML?

Show Hide Divs on Click Using CSS and HTML

Achieving collapsible headers similar to those in jQuery Mobile is possible without using jQuery. Here are five examples that demonstrate how to do so:

1. Using Detail and Summary Tags (Pure HTML)

HTML5's detail and summary tags offer a simple solution for this problem, eliminating the need for styling or scripting:


  <summary>Collapse 1</summary><br>  <p>Content 1...</p><br></details><br><details><br>  <summary>Collapse 2</summary><br>  <p>Content 2...</p><br></details>

The above is the detailed content of How Can I Show and Hide Divs with Clicks Using Only CSS and HTML?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn