These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:08 pm Advanced search

extended browser support for conditional comments.

Do you think the HTML spec should do something differently? You can discuss spec feedback here, but you should send it to the WHATWG mailing list or file a bug in the W3C bugzilla for it to be considered.

extended browser support for conditional comments.

Postby Xdega » Sat May 07, 2011 2:30 pm

I really like the idea of conditional comments for more than just ie. With several popular browsers on the market including many mobile devices, I think this would be great for setting specific CSS specially tuned for each browser WITHOUT the need of work arounds via scripting. What do you guys think?
Xdega
<h2>
 
Posts: 124
Joined: Tue Mar 01, 2011 6:30 pm
Location: USA

Re: extended browser support for conditional comments.

Postby Xdega » Sat May 07, 2011 5:44 pm

Just to clarify, what I am talking about is a simple conditional i n the html markup without half a page of javascript. Example:
Code: Select all
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->


but instead of "IE 6" have the following:
webkit ver#
moz ver#
o ver#
and maybe even a conditional for mobile devices? all without the use of scripting. As we all should know, it is possible to turn off client side scripting thus defeating the purpose. I think that a html element for compatibility in this ever more connected age would be very useful.
Xdega
<h2>
 
Posts: 124
Joined: Tue Mar 01, 2011 6:30 pm
Location: USA

Re: extended browser support for conditional comments.

Postby zcorpan » Sun May 08, 2011 6:58 pm

Would be better to have browsers behave the same so that you don't need to do different things for different browsers.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Re: extended browser support for conditional comments.

Postby JAB Creations » Sun May 08, 2011 7:53 pm

zcorpan wrote:Would be better to have browsers behave the same so that you don't need to do different things for different browsers.


So in other words if you wish to do fancy stuff that's cutting edge and requires different code across browsers you're going to need that huge chunk of JavaScript code. :wink:
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Re: extended browser support for conditional comments.

Postby Xdega » Sun May 08, 2011 10:10 pm

All browsers can (and should) have their own "special features". Greatly helps evolve the web when browsers bring innovative ideas to the table.

Using multiple CSS and conditionals, you could create a page that will use a generic layout in unknown browsers, "filters" in IE, "transitions" in webkit browsers and an entirely different style sheet for mobile devices. Then say later down the road IE wants to support transitions, then you could simply edit the IE.CSS to use "transitions" (known to have much better performance), WITHOUT having to resort to JS hacks. The beauty of this is that it allows you to tweak CSS styles for individual browsers if you will.

This could make the experience unique based on the browser the user chooses and in very few lines of clean markup.

This shouldn't require Client or even Server Side scripting to accomplish. A web browser should know its name, and thus should be able to look for markup addressed to it (while ignoring markup addressed to a different browser).
Xdega
<h2>
 
Posts: 124
Joined: Tue Mar 01, 2011 6:30 pm
Location: USA

Re: extended browser support for conditional comments.

Postby zcorpan » Mon May 09, 2011 7:17 am

You can just put all vendor extensions to CSS in the same style sheet. Unknown declarations are ignored.

you could create a page that will use a generic layout in unknown browsers, "filters" in IE, "transitions" in webkit browsers

That sounds like discriminating againt non-IE and non-WebKit users. I wouldn't recommend it.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Re: extended browser support for conditional comments.

Postby Xdega » Mon May 09, 2011 3:05 pm

Not so much discrimination, more so catering for different ways of rendering the markup. I also think that it is much better to have separate CSS tailored for optimal compatibility. Let's not also forget that conditional comments could also be used to give the end user content specific to their browser.

Ex: if IE, then download file A. If Webkit, then download B. Also, don't get too hung up on the browser names. It us purely for the purpose of illustrating the concept.
Xdega
<h2>
 
Posts: 124
Joined: Tue Mar 01, 2011 6:30 pm
Location: USA

Re: extended browser support for conditional comments.

Postby zcorpan » Mon May 09, 2011 3:52 pm

Why is the User-Agent request header not good enough for the purpose of giving different styles/content to different browsers?
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Re: extended browser support for conditional comments.

Postby Xdega » Mon May 09, 2011 4:23 pm

I think this article nails the bullsseye: http://www.conditional-css.com/advanced

One particular issue he addresses is that the user agent us sometimes changed by the user for whatever reason.

Great article that compliments my idea.
Xdega
<h2>
 
Posts: 124
Joined: Tue Mar 01, 2011 6:30 pm
Location: USA

Re: extended browser support for conditional comments.

Postby Xdega » Mon May 09, 2011 4:24 pm

One thing to also note is that the author of the above article rightly clarifies that the rendering engine should be the target of the conditional.
Xdega
<h2>
 
Posts: 124
Joined: Tue Mar 01, 2011 6:30 pm
Location: USA

Re: extended browser support for conditional comments.

Postby zcorpan » Mon May 09, 2011 4:30 pm

Is there a reason to believe that the user wouldn't also change the "user agent" for conditional comments?

That article says
It should be noted that if all browsers were to correctly implement the CSS specifications released by the W3C there would be no need for Conditional-CSS.

I think this is what we should aim for instead of spending time on specifying and implementing various ways to work around bugs (which will themselves probably have bugs too and can't be used in currently used browsers anyway).
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Re: extended browser support for conditional comments.

Postby JAB Creations » Mon May 09, 2011 5:14 pm

Z, in IE conditional comments aren't subjective to the user agent so I'm guessing that's why Xdega would like them in place of using JavaScript to determine compatibility.

If anything I like what Opera already has, the window.opera object. I think a reasonable feature would to have non-user agent dependent DOM object properties with the engine name (e.g. Gecko, KHTML, Presto, Trident, WebKit) and then the version however I have to criticize WebKit's build numbers so I would prefer the Safari browser version number and even that is subjective since Chrome shares the WebKit engine. Right here and right now the JavaScript object detection is the only truly reliable means to determine the browser engine and version reliably even if someone is spoofing their user agent.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Re: extended browser support for conditional comments.

Postby Xdega » Mon May 09, 2011 8:10 pm

zcorpan wrote:That article says
It should be noted that if all browsers were to correctly implement the CSS specifications released by the W3C there would be no need for Conditional-CSS.

I think this is what we should aim for instead of spending time on specifying and implementing various ways to work around bugs (which will themselves probably have bugs too and can't be used in currently used browsers anyway).

I completely agree with that, but as the article goes on to say:
However, CSS bugs are a fact of life for web-developers and are often extremely frustrating. Conditional-CSS offers us a simple solution to overcome these problems.

And sadly, the guy is right on the money.

If we could simply ask for 100% compliance of one single item (conditional comments) we could thus give the developer the power to solve many rendering issues as they see fit without hacks and workarounds.
Xdega
<h2>
 
Posts: 124
Joined: Tue Mar 01, 2011 6:30 pm
Location: USA

Re: extended browser support for conditional comments.

Postby Xdega » Mon May 09, 2011 8:18 pm

Also, another thing to note is the ability to run scripts for browsers that may not be able to support new elements without being told how.
Much like the small conditional comment I utilize on one of my websites to assist with rendering new elements in IE 8
Code: Select all
<!--[if lte IE 8]>
         <script>
         // HTML 5 entities for IE.
         document.createElement("article");
         document.createElement("footer");
         document.createElement("header");
         document.createElement("section");
         document.createElement("nav");
         document.createElement("aside");
         </script>
<![endif]-->
Xdega
<h2>
 
Posts: 124
Joined: Tue Mar 01, 2011 6:30 pm
Location: USA


Return to Feedback on the Specs

Who is online

Users browsing this forum: No registered users and 0 guests