# Inline CSS in forms, for real?

**URL:** <https://www.ruby-forum.com/t/inline-css-in-forms-for-real/185839>\
**Category:** Rails\
**Created:** [March 26, 2010, 11:43pm UTC](https://www.ruby-forum.com/t/inline-css-in-forms-for-real/185839 "2010-03-26T23:43:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [March 26, 2010, 11:43pm UTC](https://www.ruby-forum.com/t/inline-css-in-forms-for-real/185839/1 "2010-03-26T23:43:28Z")

</div>

So, I use a form helper and it works nicely. Then I look at the code  
and I find myself somewhat annoyed:

I obviously have no issue with hidden inputs, but WHY OH WHY are they  
inside a completely unnecessary div with completely unnecessary INLINE  
css?

With that being said, aside from a monkey patch, what’s the best way  
to override this helper to get rid of that junk?

---

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [March 27, 2010, 12:44am UTC](https://www.ruby-forum.com/t/inline-css-in-forms-for-real/185839/2 "2010-03-27T00:44:57Z")

</div>

cult hero wrote:

> So, I use a form helper and it works nicely. Then I look at the code  
> and I find myself somewhat annoyed:
> 
> I obviously have no issue with hidden inputs, but WHY OH WHY are they  
> inside a completely unnecessary div with completely unnecessary INLINE  
> css?

Well for one thing, the

 is not “completely unnecessary.” The HTML  
will not validate without it (or some other valid element. tags  
are now allowed to be direct children of tags.
## Output from W3C HTML validator:

Line 11, Column 52: document type does not allow element “input” here;  
missing one of “ins”, “del”, “h1”, “h2”, “h3”, “h4”, “h5”, “h6”, “p”,  
“div”, “address”, “fieldset” start-tag  
  
âœ‰  
The mentioned element is not allowed to appear in the context in which  
you’ve placed it; the other mentioned elements are the only ones that  
are both allowed there and can contain the element mentioned. This might  
mean that you need a containing element, or possibly that you’ve  
forgotten to close a previous element.

## One possible cause for this message is that you have attempted to put a block-level element (such as “

” or “

”) inside an inline  
element (such as “”, “”, or “”).

As for the inline style, I’m not sure if all that is necessary, but I’d  
venture to guess that Rails might be using some shared code in order to  
be more reusable. Having the extra styles doesn’t really hurt anything  
anyway AFAIK.

---

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [March 27, 2010, 1:13am UTC](https://www.ruby-forum.com/t/inline-css-in-forms-for-real/185839/3 "2010-03-27T01:13:01Z")

</div>

Ahhh. You and I are using different doc types.

A hidden fieldset makes more sense.

And the inline CSS doesn’t hurt anything per se, but if you’re a  
control freak about your HTML that’s a real eyesore and there’s no way  
in the configuration to do anything about a number of defaults like  
that.

---

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [March 27, 2010, 1:15pm UTC](https://www.ruby-forum.com/t/inline-css-in-forms-for-real/185839/4 "2010-03-27T13:15:12Z")

</div>

im aren’t expert in nothing, but I think the inline does not work in  
most current versions of browsers.  
Sorry about my bad english.xD

On 26 mar, 19:42, cult hero [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> With that being said, aside from a monkey patch, what’s the best way  
> to override this helper to get rid of that junk?

–  
Twitter[Coisas Pessoais & Importantes]: [http://twitter.com/Hugolnx](http://twitter.com/Hugolnx)  
Buzz[Coisas Importantes]: [http://www.google.com/profiles/hugoLnx#buzz](http://www.google.com/profiles/hugoLnx#buzz)  
Github: [HugoLnx (HugoLnx) · GitHub](http://github.com/HugoLnx)  
Google: [http://www.google.com/profiles/hugoLnx](http://www.google.com/profiles/hugoLnx)

---

<div class="post-metadata">

**Author:** ![cult\_hero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@cult\_hero](https://www.ruby-forum.com/u/cult_hero)\
**Post date:** [March 28, 2010, 4:09am UTC](https://www.ruby-forum.com/t/inline-css-in-forms-for-real/185839/5 "2010-03-28T04:09:15Z")

</div>

HugoLnx wrote:

> im aren’t expert in nothing, but I think the inline does not work in  
> most current versions of browsers.  
> Sorry about my bad english.xD

Where did you get that idea? I don’t know of any modern web browser that  
doesn’t support all the CSS in style=“margin:0;padding:0;display:inline”

The only thing I can think of that might be getting you confused is that  
some browsers (okay really only the stupid one that needs no  
introduction) would be “display: inline-block;” All modern browsers  
AFAIK support “display: inline;”
