How do I toggle <p> with a html link using only css -


i been working while trying have link show , hide paragraph below it.

i need accomplish using css. paragraph must hidden on load , show once link clicked , hide again when link clicked again.

how can accomplish this?

<a …………………>my link</a> <p>sed ut perspiciatis unde omnis iste natus</p> 

i appreciate help..

short answer: need javascript.

after all, that's intended for: user interaction, among other cool things. css on other hand oriented towards presentation, interaction features limited (for example, responds hover action not click action in way expect it).

the idea comes mind using checkbox control click "states" , in css display based on status.

html:

<label><input type="checkbox">my link <p>sed ut perspiciatis unde omnis iste natus</p> </label> 

css:

input[type="checkbox"] {display: none;} input[type="checkbox"] + p {display:none; margin-left:1em;} input[type="checkbox"]:checked + p {display:block;} 

check out fiddle

however, solution not best cross-browser wise, go "javascript" ;)


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -