If you are a Web designer or developer, you know that styling forms with CSS is a huge pain. Not only are browser inconsistencies rampant in form elements, but it is very difficult to get an advanced form to layout correctly, both visually & semantically. To alleviate these issues and to help designers / developers avoid unwanted stress, I took a crack at developing “RMSforms”, a CSS forms framework. To apply it to your forms, simply download the RMSforms CSS Stylesheet, link to it from your HTML and apply the correct classes to the HTML structure described below and you will be on your way to creating complex CSS-based, tableless, flexible forms with ease.
Download RMSforms-v0.5.css
View Examples / Reference Sheet
RMSforms v0.5 was tested in IE6 – 7, Firefox 3 & Google Chrome. More testing is to come.
It is validated using XHTML STRICT doctype
The HTML
“RMSforms”, CSS forms framework is based off a very simple HTML structure:
<fieldset>
<legend></legend>
<ul class="form [modifier]">
<li><label class="[label modifier]"></label><input/></li>
</ul>
</fieldset>
The Beauty of the Un-ordered List
Un-ordered lists are a great tool for grouping form elements together because they make sense semantically and provide for the level of flexibility needed to style a form effectively.
In essence, a web-based form is a LIST of form fields with coresponding labels that are grouped together visualy based on their association to each other. In the HTML structure of RMSforms, the <ul> provides a container for the list of all related labels / form fields and the <li> provides a container for the grouping of the individual <label> / form field combinations. In more complex forms, a <label> can often times be used to distinguish not only just one <input>, but a "nested form" that has a series of labels / form fields. With the the <ul><li> structure, nesting a form is very easy.
Other CSS form techniques use <p> tags, <div> tags, and line breaks to group individual labels & form field combinations together. I think these grouping methods leave a lot to be desired as far as flexibility and semantics. In my opinion, line breaks should be avoided whenever possible, <p> tags should only be used when presenting a paragraph, and although <div> tags would work, your html code would get real sloppy in an advanced form.
The CSS
In every web-based form there are two layout orientations that can be used to display the relationship between a <label> and it’s corresponding form field; horizontal or vertical. The same is true for the visual orientation of the <label> / form field groupings to one another. This simple concept is the basis for the class names being used within the “RMSforms” framework.
The allmighty “form” class
Each top-level form <ul> in the "RMSforms" html structure has a base class of “form” applied to it. This class establishes a basic visual relationship between the elements within the form, sets a background-color and provides some outer padding.
<ul class=”form”></ul>
The Modifier Classes
The most important classes defined in the "RMSforms" stylesheet are the “form modifiers”. These are 3 letter classes that modify the visual relationship between the <li>, <label>, and <input> elements respectively.
The first letter in the modifier class names describes the orientation of the <LI> tags in the form <ul>, the second letter describes the orientation of the <LABEL> tags in he form <ul> and the third letter describes the orientation of the form fields within the form <ul>. The 3 letters that make up the modifier class names are “H”, “V” and “I”
- H = Horizonal Block
- V = Vertical Block
- I = Inline
A list of all the form modifier classes:
- vvv – Vertical <li>, Vertical <label>, Vertical form fields
- hvv – Horizontal <li>, Vertical <label>, Vertical form fields
- hii – Horizontal <li>, Inline <label>, Inline form fields
- hhh – Horizontal <li>, Horizontal <label>, Horizontal form fields
- vii – Vertical <li>, Inline <label>, Inline form fields
- vhh – Vertical <li>, Horizontal <label>, Horizontal form fields
Usage Example…
The class “hvv” describes a form with <li> tags that are layed out horizontally and <label> tags which are vertical block elements that sit on top of vertical block form field tags.
<ul class=”form (default form class) hvv (form modifier)“></ul>
To view this example in html, take a look at the RMSforms example page
Label Modifiers
Often times, you may want the visual orientation between a <label> and form field tags to vary within a form. For example, if one of your labels in a “VHH” form has a lot of text in it, you may want it to sit on top of it’s corresponding form field rather than to the left of it. This is where the label modifiers come into play. Label modifiers are used to override the classes placed on the form <ul> and should be applied to <label> elements within a form. The exiting label modifiers are classes:“v” or “h”.
Form Nesting
One of the advantages to this form framework is the ability to nest form <ul> tags without a problem. In many advanced forms, problems pop up when needing to incorporate multiple <label> / form field combinations within one grouping. Using the form modifier classes, simply nest a form <ul> with the appropriate modifier applied to it within an <li> and you’re all set.
Why Not Just Use Tables?
Ah, the great question. Why not just use tables? Wouldn’t be a lot easier? Yes it would, but, being a semantic Web design nut, I believe tables should only be used in html to describe tabular data. If your not too concerned with html semantics, it is a very plausible solution for the laying out forms.
Comments, Suggestions and Modifications Are More Than Welcome.
"RMSforms" CSS Forms framework is a work in progress. The goal of this project is to make form styling as simple as possible. There are probably many scenarios in that I didn’t account for, or bugs that I have not come across. If you have any questions, comments or ways to improve this framework please post them up or contact me directly. I look forward to hearing from you!
Updates: 6/16/2011
- Added “list-item modifier: inline” (line 125): Adding class=”inline” to any <li> in a form will convert all inputs and labels contained in that list-item to inline elements. This is helpful when you have a form where a group of form elements needs to be displayed horizontally within one list item of a form laid out vertically.
- Separated “theme styles” from the framework styles in the Examples / Reference Sheet : This was done so that no generic font or layout styles are contained in the framework, making it easier to implement.








Before I go to the (monolithic) effort of starting a project using this, how is it affected by prior inclusion of a reset stylesheet (say, Yahoo’s, or Meyer’s) ? Does it hold up, or does it require heavy modification?
Keryn, Good question! After testing it out with Eric Meyer’s latest reset stylesheet, Beyond the default styles applied to the fieldset and legend elements, everything seems to stay in tact very well.
super!!!
Great Work!
Looks good in Opera 9.64 too!
How about styling error messages on individual fields?
Great work! I love your form framework!
Hi Randy, thanks a ton for this uber cool CSS Framework. It’s so easy to plug it to my existing app without breaking anything, including the existing CSS frameworks. Look forward to the next version.
I like it very much, if you want to get it adopted more easily by people, consider to make it work well with JQuery and promote it as a “JQuery form plugin”.
Lots of people who use JQuery look for form plugin.
Pingback: Heti események | I build websites
excellent work!!
Great idea, will definitely be giving this a spin, thanks!
I really appreciate sharing your approach with us. Thanks for that!
BUT: Apart from a list (imo) not being the semanticaly correct markup to wrap a form in (i personally prefer using a combination of fieldsets to group elements and divs/spans for layout), your approach lacks semantical and meaningfull naming of CLASSES (as almost all CSS Frameworks do).
You COULD add meaningfull classnames additionaly but that would make your forms much more bloated.
As for me I’ll keep thinking about every form and it’s structure (as i do for every element in the markup) and leave the frameworks alone until someone thinks of a better way to automize CSS layouts or HTML5 and CSS3 finally are supported well across all Browsers (which would make extra elements useless).
I recommend reading about microformats and semantic class naming here:
http://www.w3.org/QA/Tips/goodclassnames
http://woork.blogspot.com/2008/11/css-coding-semantic-approach-in-naming.html
Nice work — it would be nice to see this up on a code repository like GitHub or Google code.
Interesting, I’ll definitely take a look at this!
You should be using the “for” attribute in the labels (along with an “id” attribute in the inputs)
Pingback: links for 2009-12-27 « riverrun meaghn beta
Pingback: A CSS Framework For Styling Forms: RMSforms | Free Web Resources
Pingback: RMSforms, framework CSS para crear forms de forma semántica y sencilla | CSSBlog ES
Pingback: CSS Forms Framework – RMSforms – Daily interesting stuffs
Hmmm, very interesting . . .
Pingback: RMSforms by WebBlogs – By Imad El Anis – Senior UI Engineer
Good post. Thanks!
Pingback: A CSS Framework For Styling Forms: RMSforms :: Graficznie
Pingback: RMSforms - CSS Framework For Styling Forms | denbagus blog
Pingback: Descubrimientos del 23 Diciembre 2009 | Blog de unique3w
Pingback: RMSForms, framework CSS orientado a formularios | Recursos para Diseñadores Gráficos y Web | Creativos Online
Pingback: RMSforms: Framework CSS para formularios | Omeyas Web
Saved me a load of browser issues. thanks!
Pingback: 10 CSS Frameworks To Style Your Designs Ajax Help W3C Tag
Outstanding article.
O.o Another guy with the initials and nickname “RMS”? I’ll bet that if RMSforms becomes widely used its name will produce confusion similar to that which persists around JavaScript. “Wait, it’s not licensed with the GPL or even LGPL? How can you have the nerve to put Richard Stallman’s name on it?!?”
!(JavaScript instanceof Java)
!(RMSforms in RichardStallman)
yay! I love this! why not implementig this in blueprint? creating forms is such a mess – RMSforms is a great take on mastering it! thanks a lot!
Pingback: 25 Frameworks CSS gratuit pour les développeurs web et les designeurs | Blog Wajdi HSEN
Pingback: An Ultimate Roundup of HTML / CSS Frameworks | Greepit
Agreed with Juan – if you know your forms, you would either be using labels with for=”" or you’d be wrapping your controls within labels.
This is pretty fundamental to how forms are designed to work, and a bit of a glaring omission.
I like the vhi idea though! Might have to borrow that :)
@Dave Stewart: I think keeping labels separate from the form controls makes more sense semantically. It seems like more of a personal preference than anything.
The reason I omitted the “for” attribute in the “example/reference sheet” is because the labels have no context. The purpose of the example was to show the html structure. I didn’t think it would be helpful to add in blank attributes.
But, you’re right, the “for” attribute should be used in all labels.
Pingback: 7 Form Frameworks To Help Manage Your Forms Easily | Web Designer Aid
Pingback: 29 Free CSS Frameworks and Tools for Web Developers - Tools you really have to know - Best webmaster tools
I’ll try it a soon as possible..
Pingback: CSS Form Templates, Tools & Services
Pingback: CSS Form Templates, Tools & Services // Web Developers articles, tutorials, help
Pingback: 30+ Best CSS Forms | Best Wordpress Host
Pingback: 27 CSS Frameworks for website development | DesignerPush
This css framework is my favourite. One thing was missing for me; compound controls. That is; controls made up of more than one control, like a time selector, made up with two combo boxes (hour and min.).
I solved this on my own. Like this
I changed the HTML like this
and in CSS I changed all “input” to “.input”. I disabled style definitions for “select” and “textarea”. And it worked, supporting the compound controls.
NOTE: there some other minor changes in CSS
Pingback: Website
Pingback: RMSforms – A flexible CSS Forms Framework to Help Style Those Pesky Forms