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

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -