input[type=text] CSS selectors

611 views
Skip to first unread message

Joe Lencioni

unread,
Nov 18, 2010, 11:47:36 AM11/18/10
to mod-pagespeed-discuss
I have some CSS that specifically targets text type input elements
using input[type=text]. Since mod_pagespeed removes the type="text"
from my HTML, these CSS styles are no longer applied. Since CSS does
not allow for a does-not-equal attribute selector (input[type!=radio|
checkbox|submit|etc]) and I don't want to target all input elements,
what is the best way to target these types of inputs? Should I give
them a class of text or is there a way to specifically disable this
particular optimization that mod_pagespeed performs without disabling
an entire category of optimizations?

Running mod_pagespeed 0.9.8.1-215.

Joshua Marantz

unread,
Nov 18, 2010, 1:04:23 PM11/18/10
to mod-pagesp...@googlegroups.com
Can you given an HTML fragment or a URL?

mod_pagespeed should not take your working HTML/CSS and make it stop working.  If you give a working example that mod_pagespeed breaks, then we will fix the problem ASAP and also send you a temporary workaround.

Thanks!
-Josh

Shawn Ligocki

unread,
Nov 18, 2010, 1:43:34 PM11/18/10
to mod-pagesp...@googlegroups.com
This is a known risk of elide_attributes that Matthew found. We need to add this to the elide_attributes documentation.

I think Matthew found a way to edit your CSS to fix this.

-Shawn

Matthew Steele

unread,
Nov 18, 2010, 2:01:39 PM11/18/10
to mod-pagesp...@googlegroups.com
Yes, this is a known issue with elide_attributes. You can, of course,
simply turn that single filter off in your Apache configuration,
using:

ModPagespeedDisableFilters elide_attributes

If you'd prefer to keep it, however, I believe you can work around the
problem by changing your CSS by replacing rules such as:

input[type="text"] { ... }

with:

input:not([type]), input[type="text"] { ... }

This will match if type="text", or if the type attribute is not present at all.

Joe Lencioni

unread,
Nov 19, 2010, 10:36:07 AM11/19/10
to mod-pagespeed-discuss
Awesome guys, thanks for the fast response!

On Nov 18, 1:01 pm, Matthew Steele <mdste...@google.com> wrote:
> Yes, this is a known issue with elide_attributes.  You can, of course,
> simply turn that single filter off in your Apache configuration,
> using:
>
>   ModPagespeedDisableFilters elide_attributes
>
> If you'd prefer to keep it, however, I believe you can work around the
> problem by changing your CSS by replacing rules such as:
>
>   input[type="text"] { ... }
>
> with:
>
>   input:not([type]), input[type="text"] { ... }
>
> This will match if type="text", or if the type attribute is not present at all.
>
>
>
>
>
>
>
> On Thu, Nov 18, 2010 at 1:43 PM, Shawn Ligocki <sligo...@google.com> wrote:
> > This is a known risk of elide_attributes that Matthew found. We need to add
> > this to the elide_attributes documentation.
> > I think Matthew found a way to edit your CSS to fix this.
>
> > -Shawn
>
> > On Thu, Nov 18, 2010 at 1:04 PM, Joshua Marantz <jmara...@google.com> wrote:
>
> >> Can you given an HTML fragment or a URL?
> >> mod_pagespeed should not take your working HTML/CSS and make it stop
> >> working.  If you give a working example that mod_pagespeed breaks, then we
> >> will fix the problem ASAP and also send you a temporary workaround.
> >> Thanks!
> >> -Josh
>
> >> On Thu, Nov 18, 2010 at 11:47 AM, Joe Lencioni <joe.lenci...@gmail.com>
Reply all
Reply to author
Forward
0 new messages