Last Updated: December 26, 2018
·
2.711K
· shageman

Showing and hiding conditional HTML without Javascript

Have you ever filled out an address form that had a checkbox for “my shipping address differs from my mailing address”? When you click that box a conditional form part gets revealed that allows you to enter another address. We had to build something very similar the other day and stumbled on a neat way to make the conditional part show and hide with CSS only.

Here is how:
http://pivotallabs.com/conditional-html-forms-without-javascript/

2 Responses
Add your response

This technique is really good for drop down menus that should work without JavaScript!

over 1 year ago ·

thomaslindstr_m how do I get it to work with drop downs?

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside