Re: [css-d] style attribute with display: none on style tag
2011-12-12 13:08, Joergen W. Lang wrote: I've come across some sites that use the following code in the head section: style type=text/css style=display:none It would be interesting to see some sample URLs, as that could let us find out why they are doing that. I suspect it is there to either a) prevent people from exposing their code How would it do that? The contents of style elements aren't displayed on the page by default, and they can be inspected using View Source. The style attribute does not affect the latter at all, and regarding the former, display: none is the default. b) prevent search engines from seeing their code How would it do that? They don't interpret styles at all. Is there any documentation of this? In HTML 4.01, a style attribute is disallowed in a style element. In HTML5 drafts, it is allowed, as it is for any element. There is nothing special here, it means the same as for any other element. But browser behavior varies. By default, browsers behave as if display: none were in effect for style elements - and they may even have such a rule in their actual browser style sheet. If you set the display property to some _other_ value, then the style sheet may become visible. Using style=display: block in a style element makes the style visible on my Firefox. On IE, I need to additionally set display: block for the head element. Cf. to appendix D of CSS 2.1 spec which says head{ display: none } ( http://www.w3.org/TR/CSS2/sample.html ) One _possible_ use for style type=text/css style=display:none would be to prevent rendering of one style element's contents in a context where it would otherwise be rendered, e.g. under the influence of head, style { display: block; } Yucca __ css-discuss [css-d@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] style attribute with display: none on style tag
Am 12.12.11 12:48, schrieb Jukka K. Korpela: 2011-12-12 13:08, Joergen W. Lang wrote: I've come across some sites that use the following code in the head section: style type=text/css style=display:none It would be interesting to see some sample URLs, as that could let us find out why they are doing that. http://www.quirksmode.org/ http://www.thecssninja.com/demo/css_chameleon/ I suspect it is there to either a) prevent people from exposing their code How would it do that? The contents of style elements aren't displayed on the page by default, and they can be inspected using View Source. The style attribute does not affect the latter at all, and regarding the former, display: none is the default. html, head, style { display: block !important; } shows exactly this rule in Safari 5/Mac. I *guess* you could also use jQuery to move and change DOM nodes. But that's not the core question. b) prevent search engines from seeing their code How would it do that? They don't interpret styles at all. Google states differently (http://tinyurl.com/bst65zf). They say that Using CSS to hide text might get the site perceived as untrustworthy. So I conclude they must have a way to read and interpret styles. (You could block external style sheets via robots.txt but internal/inline styles could still be read.) Is there any documentation of this? In HTML 4.01, a style attribute is disallowed in a style element. In HTML5 drafts, it is allowed, as it is for any element. There is nothing special here, it means the same as for any other element. But browser behavior varies. By default, browsers behave as if display: none were in effect for style elements - and they may even have such a rule in their actual browser style sheet. If you set the display property to some _other_ value, then the style sheet may become visible. Using style=display: block in a style element makes the style visible on my Firefox. On IE, I need to additionally set display: block for the head element. Cf. to appendix D of CSS 2.1 spec which says head { display: none } ( http://www.w3.org/TR/CSS2/sample.html ) Similarly in Safari (see above). One _possible_ use for style type=text/css style=display:none would be to prevent rendering of one style element's contents in a context where it would otherwise be rendered, e.g. under the influence of head, style { display: block; } Acknowledged. It would make things a little tougher to add !important the the style attribute: style type=text/css style=display: none !important; / And even that could be overridden by a suffiently specific user style sheet (need to restart Safari be be effectice). Still wondering why anybody would use display: none on a style tag, Jørgen __ css-discuss [css-d@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] style attribute with display: none on style tag
Am 12.12.11 15:42, schrieb Jukka K. Korpela: 2011-12-12 15:50, Joergen W. Lang wrote: style type=text/css style=display:none It would be interesting to see some sample URLs, as that could let us find out why they are doing that. http://www.quirksmode.org/ http://www.thecssninja.com/demo/css_chameleon/ I don't see any style element on either of those pages. That is indeed very strange. Apparently my mobile phone provider does some optimizations of the page source (removing unneeded whitespace, etc.). But that attribute still makes no sense. Crystal ball, anyone? (Getting the same pages via a different connection does not show the attribute, btw.) [snip Google stuff] Still wondering why anybody would use display: none on a style tag, In addition to the case I outlined, there's also the possibility of wanting to override normal (i.e., not !important) user style sheet rules. Someone might want to have user style sheet that makes some normally invisible content visible... here's a demo: http://www.cs.tut.fi/~jkorpela/styles/show.html (The demo has only author style sheets of course, but you can imagine - or test - how the Showing style stylesheet works as a user stylesheet.) Agreed. That's what I meant by prevent people from exposing their code. Sorry for the misunderstanding. Jørgen __ css-discuss [css-d@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/