Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryWebsite Development and Maintenance

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Responsive Forms; A Simple Way

A special challenge for responsive pages is forms.

Depending on the design of the form, it may need to be redesigned for small or large screen widths. Different designs can be published for different widths with @media tags.

Unless it's really necessary, let's just do it simple. Let's just bypass the added steps of @media tags.

This article describes a simple form design that's responsive to any screen width without needing a redesign.

The Responsive Form Concept

Here's the simplicity of it:

  • Form labels are above form text fields.

  • Form text fields have width:100%; CSS definitions.

  • Optionally, to prevent the form from getting wider than a certain width, put the form into a div with a max-width property. (Example: max-width:600px;)

An Example

The example contains all of the above responsive form concept points.

Name:

Email:

The form widens and narrows according to the width of the screen — with the maximum width determined by the enclosing div.

The Source Code

Here's the source code of the above example. The CSS styles are colored blue. They are inline styles and may be transferred to a style sheet.

<div style="max-width:625px;">

<form onsubmit="alert('Not a live form');return false">

<p>
Name:<br>
<input type="text" style="width:100%;">
</p>

<p>
Email:<br>
<input type="text" style="width:100%;">
</p>

<p>
<input type="button" value="Submit" style="width:100%;" onclick="alert('Not a live form');return false">
</p>

</form>

</div>

That's all there's to it. It's a truly simple responsive web page form design.

(This article first appeared in Possibilities ezine.)

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC