• Win a Rab Nexus Pull-On with the 1st of the Inglesport Fabulous 5 competitions!

    Caption competition, closes Friday 25th April

    Click here to enter

.net vs CSS Model

  • Thread starter Thread starter Dep
  • Start date Start date
D

Dep

Guest
The discussion on Firefox 2 was getting off topic a bit so I have started a new one.
http://ukcaving.com/board/index.php/topic,2828.0.html

AndyF said:
CSS was supposed to make changing a web site style easy and simple. It's turned into a nightmare of overcomplexity and design by comittee typical of W3C.
The very fact that a CSS change CAN turn into a "major coding" exercise is evidence of it completely failing to meet it's own goal. CSS explodes in a puff of logic to use a phrase.....
This is why I don't do them, I use .NET base classes modified as required and let very clever .NET framework render the pages appropriately to the target browser. This is automatic and seemless. The very concept of custom style sheets for specific browsers is utterly obsolete in the NET environment, even though support is still given for them.

An interesting subject, it seems we have similar viewpoints but have approached the subject from two different technical perspectives.
I have to be honest and say that I know very little about the .net architecture. I am only an amateur web-developer, my primary skill is as a programer.

I have a good understanding of what I am doing with webcode but I am always happy to learn new ideas or have my false impressions corrected.
I like the CSS model, it works for me and has never seemed anything other than quite straightforwards once grasped. (but isn't that the way of all things! :) )

However, your comment makes me think that you have not fully understood the CSS model either.

>>CSS was supposed to make changing a web site style easy and simple.

It does - if properly implemented.
By producing HTML code that has no styling or formating all the style goes into a CSS file.
The code is rendered by any browser in its purest form and the style is laid over using one or several stylesheets - alternate browser-specific stylesheets are just as simple.

The HTML code contains nothing but the most basic structure and the content itself.

>>The very fact that a CSS change CAN turn into a "major coding" exercise

But it doesn't for me - I think you misunderstood me.
I can make global changes to the site style in seconds by only changing one or two files.
The key factor is PROPERLY IMPLEMENTED.

If it wasn't, and there were loads of STYLE tags everywhere or worse still the deprecated FONT tag all over then place then your comment would be totally valid - but I haven't done it like that for exactly that reason.

>>I use .NET base classes modified as required

If I understand this correctly this is basically the same as how it is done in the CSS. My HTML is format free, all I have are ID or CLASS atrributes for each of the principle elements.
The single CSS file defines the styles for these.

You say that the .net system modified these classes as appropriate - well that's no different to having variant CSS loaded as required.

And surely the .net system must be doing some form of implicit browser detect to output the approriate styling and layout classes?

So what does the .net system output as the definition for each of these classes; presumably a series of CSS selectors?

Surely just two _slightly_ different ways of achieving the same thing?


I like the idea of a CSS standard as this gives each browser manufacturer a clearly understood set of rules to follow - compliancy.
The alternative, to remove the standard makes for proprietary code, and then it becomes a free for all, either having to use the unwieldy .net architecture as nothing else will cope with the plethora of variations or having sites that will only work correctly in 'compatible' browsers.


There was a move a while back to attempt to replace the TABLE element used to structure pages into a table-free CSS based layout relying upon the CSS to position, size and align the various DIV elements that make up the page.

There is nothing complicated about it, put this element here, make it this big and align it like this - done.


The very specific problem I have here is the way that the float attribute is rendered in IE7.

I have a container DIV for the page and two sidebars (left and right)
The sidebars are generally short, the main page content is usually much longer.
Thus:

(Not sure what the forum post will make of angle or square brackets so I have used curly brackets instead throughout - I'm sure you'll figure it out.)

{div id="frame"}
{div id="header"}
{/div}{!--header--}
{div id="content"}
{div id="rightbar" class="sidebar"}
{LINKS}
{/div}{!--rightbar--}
{div id="leftbar" class="sidebar"}
{IMAGE}
{/div}{!--leftbar--}
{p}Blah blah blah blah blah blah{/p}
{p}Blah blah blah blah blah blah{/p}
{p}Blah blah blah blah blah blah{/p}
{/div}{!--content--}
{/div}{!--frame--}

In the single stylesheet I have:

div#header {
regular formatting
}
div#content {
regular formatting
}
div.sidebar {
regular formatting
width:180px
border:1px
}
div#leftbar {
float:left;
}
div#rightbar {
float:right;
}


This is all simple basic stuff - very easy to maintain and works everywhere until IE7 came along.
As I am sure you know the 'float' makes the element pop up to a 'higher'** level than the rest of the page. The two sidebars float up into the corners and sit over the {P} elements in the main body which display between the sidebars and wrap themselves around and expand to the full page width lower down where the sidbars end.

**in this context, by higher I mean further out the plane of the screen, ie one lement covering another.

IE7 did something really odd. It does not place float elements at a higher level.

But my problem, and why I am calling this a bug and not a CSS/HTML coding error is that it does not fail in a consistent fashion.
I could understand it streaming the sidebar as a regular block-level element, or placing it underneath.

But it doesn't. In the example I gave above there is an image in the LH sidebar, a small thumbnail picture 180x135.
It places the paragraph text and the image at the same 'height' (ie plane of page) and displays them in alternate stripes of picture/text/picture/text instead of obtusely placing one atop the other.

Now I'm not too fussed about this, all I have to do is find the required CSS instruction to tell IE7 in whatever way it needs to be told to lift the sidebar up 'higher' and wrap the body text around it - just as the other browsers do.

And then add EITHER a few simple CSS hacks to make IE7 work, or supply a slightly modified CSS for IE7 using the MS proprietary conditional HTML syntax:
{!--[if IE 7]}
@import "/css/ie7_specific.css";
{![endif]--}

So why else did MS design this syntax?

As I said elsewhere I'm not doing this for a living so it will get done when I have time, and as with many technical issues like this a good deal of that time is initially spent simply thinking about the issue and how best to solve it.

My one constraint is that I am not designing a site from scratch, this was an unforseen problem when the current design was implemented and so I MUST find a solution that fits the existing framework, I will not be changing page code unless I really have to.
And I am fairly sure a simple CSS solution will popup, it's just a question of how best to mplement it with the least hassle.

In the meantime I need to find out specifically how IE7 views the CSS, this too presents a major issue as I cannot load IE7 without loosing either IE6 or IE5 on other installations. WTF can't MS give the executable different names iexplore5.exe, iexplore6.exe,.. - then they could coexist without being forced to upgrade and overwrite. Yes I know about all about dual boots but frankly I cannot be arsed to go to those lengths just yet. SIDIGTTS
But until I can see the error for myself I can't do much, people are going to get fed up with me asking for screengrabs all the time - and that's a very hard way to code.

Actually a few ideas have occurred to me whilst typing this, the focus has been on the float element as that is where the fault appears, but I have noticed before that IE* has real serious rendering issues with text-align:justify;
Why should IE7 be any different.

It may actually be a fault here with this causing the {p} text to expand into the sidebar.


Another point AndyF made was that a website is no good if it cannot be seen properly by 90% of users.
This is totally true, but it is also reasonable to assume that siteX should render the same in two consecutive versions of one's product.

The fact that the same code appears so differently in IE6 and IE7 says that something is wrong and that this is a compliancy issue.

And with such a long gap since IE6 came out, IE6 had become the de facto standard browser - combined with FF the two worked in much the same way and were used by the overwhelming majority. I am amazed that IE7 is not designed to continue this - again this makes me think that what I am seeing is buggy behaviour in IE7.

I think (haven't fully verified this yet) that IE7 was intended to take a very strict view of the CSS, and to read it properly and ignore all hacks. This could be annoying but would be deemed a good thing in the long term as CSS hacks are not a good thing at all - the one weakness of the CSS model.
But with IE5 dying out the need for these has gone.


But the bottom line is that 99% of internet users don't use IE5, IE6, IE7, FF, Opera, Lynx etc - they use a 'web-browser' and that's the clever ones who can even distinguish a single application from the apparently seamless 'magic' that is their operating system.


So yes this is a genuine issue with IE7 that will affect others.
I _will_ fix it.
And the CSS method will not hinder me in this fix (I hope!)

One point I will concede is that the fix will need to be sooner than I had initially anticipated.

I will be very interested to identify the specific cause of this difference.

Sorry this is a bit long, but technical stuff so often is.


 
Its not possible to into every aspect of .NET ina forum post, but the most importnat things are as follows.

.NET allows logical seperation of style and content and code, and this is a good thing.

Consider a "DIV" element..... in .NET you can use old HTML, code a div and set it's style with CSS. This works, but each time a new browser comes out you may havea coding job, and you may have to code seperately the CSS for each target browser and do browser sniffing. That is wasteful of coding time wise.

In .NET you alternative is to use a "label" element. You can (either at design or run time) set colours, fonts etc. etc, or (for the die hards) pick a style from a style sheet.

When the page is requested, NET does indeed do browser sniffing, and will then render the element into code that is understood by the browser.
As an example, if the target browser is a very early Mozilla style broswer, then the "label" wil be rendered as an HTML 3.2 div. If it's IE6 it would be rendered as HTML 4.0. Styles may be embedded as a style element, or as HTML attributes.

This all happens automaticaly, and is why .NET aps require little (if any) cross browser testing, because the .NET rendering engine does that all for you.

When a new browser appears, or a new standard, the NET framwork is upgraded (about once a year) to cope. This upgrade affects all sites on you server in one swoop, and you never have to be faced with 40-50 sites to upgrade at a time. For a commercial organisation, this is important!

The use of modified classes is effectively done by what is termed a "user control". This effectively gives a single point of modification to affect a whole site for a given, say, font or colour, without using CSS. WHy do this? Well if you need to change the look of a site programatically, then with CSS you need X CSS files, one for each look and programatically switch between them. However, if you need to change, say, a colour from a database field, then you are best to skip the CSS and simply programatically change the colour in the "user control".

Consider (with CSS) how you would allow the user to (say a site admin for example) to choose the background colour of his web site (as viewed by visitors) via a site admin page WITHOUT having direct access to the code or editing a CSS file.....

I'd suggest you download and try Visual Web Developer Express 2005, it's free (yes it is!  :) ) and will give you a road to damascus revelation.......

http://www.asp.net/downloads/essential.aspx?tabid=62





 
Andy,
Does .NET work with otherscripting languages such as php or is it just for asp (microsoft)?

 
Les W said:
Andy,
Does .NET work with otherscripting languages such as php or is it just for asp (microsoft)?

ASP.NET isn't really a scripting platform, in that it does not run in line interpretted code in the way of (old) asp 3.0.

ASP.NET pages are compiled into a DLL, and are not interpretteed. The "code behind" can be written in a number of languages, the most popular being C# or Visual Basic, but any .NET supported language will work (eg J#). This compilation means that .NET pages run a lot faster than interpretted pages, and allow far greater concurrency (i.e. more users at the same time).

There IS a PHP available for .NET, but it is an untidy kludge that fails to use many of the better .NET features available.

 
I think this may be the first post of the new year!

Hi Andy,
thanks for that, and interesting and detailed explanation.

>>.NET allows logical seperation of style and content and code, and this is a good thing.

So does the CSS model. We are both agreed then that this is a 'Good Thing' and an ideal to work towards.
Both methods then maintain pure HTML and content with all formatting control placed elsewhere, in the CSS files in my case and within the .et architecture in yours.

In practice it seems to me that both methods are doing the same basic tasks  although in different ways, essentially the alternative CSS is automatically rendered by the .net engine.

I agree in that case that life is slightly easier in that you will not end up, as I am, in having to suddenly produce another CSS cersion just for IE7.

But the way I implement CSS does not have the complexity you appear to imagine.
The key parts of the HEAD section of the pages on the site that load the required CSS are all included in a single SSI file, so once I have created my new IE7.css I only need to add another CSS inclusion  line - a simple enough task.

>>As an example, if the target browser is a very early Mozilla style broswer, then the "label" wil be rendered as an HTML 3.2 div. If it's IE6 it would be rendered as HTML 4.0. Styles may be embedded as a style element, or as HTML attributes.

I take it you mean it outputs a different DOCTYPE?

>>Styles may be embedded as a style element, or as HTML attributes.

But surely this is putting the formatting back into the content, unless you are talking about dynamically generated pages ie .asp

Doesn't this lead to pages that are larger than they need to be?
Although as broadband becomes the norm I suppose it's less of an issue than the old 56Kb days.

>>Consider (with CSS) how you would allow the user to (say a site admin for example) to choose the background colour of his web site (as viewed by visitors) via a site admin page WITHOUT having direct access to the code or editing a CSS file.....

I can think of two ways to do this using my method...

The first is to use the alternative stylesheet syntax and make a styleswitcher.
A bit clunky but it can be done easily enough using SSI files or shared JS (to be fair it's also more trouble than its worth and therefore pointless in a commercial environment)

The other idea is more sophisticated and is much closer to mimicing what .net does (in fact it's an idea I may develop further as a clean solution to cross-browser issues)
It's to do this...
{head}
...
{style type="text/css"}
@import "/cgi-bin/custom_css_output.pl";
{/style}
...
{/head}

Said program will simply output a browser or user specific complete CSS.
This is a direct equivalent to what .net appears to be doing.

HTML spec remains in all cases as xHTML1.0 Strict or transitional, I cannot see why there is a need to downgrade the HTML spec for older browsers, even IE5.0 has no serious issues with xHTML1.0

Because I have been very careful to separate content from style this all hinges on a single CSS file - its just a matter of loading the right one, and in this instance quickly developing a new one for IE7 - once I have sussed what the differences are.

One very significant difference here is that .net is a package that has many features like this already built in. I can see why it has a strong appeal to anyone working in commercial web development.
What I have is much simpler, there are no packages at all, anything I want is doable but I have to do it myself in the first place.
But I don't code things twice - I always build things to be modular so they can be updated/replaced in future as required.

Fortunately this is where my primary skill as a programer comes in.
Someone trying to do this using a WYSIWYG system and trying to build a pure CSS model website is going to come seriously unstuck if they cannot utilise CGI resources - thus they need to use a package with all this taken care off - like .net.
For me I am lucky enough to be able to create the special tools that I need from scratch. As a hobby this is great, it teaches me a good deal and is a real challenge.

But I could never make a living from it, this is the bottom line. You are quite right to point out the big differences in development time.

As I said before this IE7 thing has caught me out which is annoying.
But at the same time I am quite confident that once I have addressed this specific issue my own architecture will pose no problem at all in alowing it to be quickly fixed in a robust fashion.

And it is also true, I believe, that if ALL browsers adopted a standard interpretation of the simple CSS rules then life would be simpler all round, a large chunk of the .net functionality (and its corresponding CPU time) would not be needed!

Thanks for the free download location, I may give it a whirl and see how I get on.

And in your response to LesW's question...

>>There IS a PHP available for .NET, but it is an untidy kludge that fails to use many of the better .NET features available.

If it's an untidy kludge then PHP should feel right at home. :)

More importantly to me, does .net support Perl?
 
I think this may be the first post of the new year!

Hi Andy,
thanks for that, and interesting and detailed explanation.

>>.NET allows logical seperation of style and content and code, and this is a good thing.

So does the CSS model. We are both agreed then that this is a 'Good Thing' and an ideal to work towards.
Both methods then maintain pure HTML and content with all formatting control placed elsewhere, in the CSS files in my case and within the .et architecture in yours.

In practice it seems to me that both methods are doing the same basic tasks  although in different ways, essentially the alternative CSS is automatically rendered by the .net engine.

I agree in that case that life is slightly easier in that you will not end up, as I am, in having to suddenly produce another CSS cersion just for IE7.

But the way I implement CSS does not have the complexity you appear to imagine.
The key parts of the HEAD section of the pages on the site that load the required CSS are all included in a single SSI file, so once I have created my new IE7.css I only need to add another CSS inclusion  line - a simple enough task.

It can be with simple CSS, but can be much more complex if the full potential of CSS3 have been used. Now consider you are a web site developer, and your company has 100+ sites to sort out under maintainace agreements. That is going to cost you a lot of money..!

>>As an example, if the target browser is a very early Mozilla style broswer, then the "label" wil be rendered as an HTML 3.2 div. If it's IE6 it would be rendered as HTML 4.0. Styles may be embedded as a style element, or as HTML attributes.

I take it you mean it outputs a different DOCTYPE?

Yes, exactly that

>>Styles may be embedded as a style element, or as HTML attributes.

But surely this is putting the formatting back into the content, unless you are talking about dynamically generated pages ie .asp

Yes, the seperation is in the design area. Depending on implementation it gets rendered as embedded styles or in-line styles.

Doesn't this lead to pages that are larger than they need to be?

Yes, this is true. But even a complex page it may add, say, a few thousand characters. But that is 1-2K of material. Plonk an image on the page and you instantly may add 50K to fully populate the page, so the increased content is generally insignificant as a proportion of full page footprint. Most people are indeed on broadband of some sort these days.


Although as broadband becomes the norm I suppose it's less of an issue than the old 56Kb days.

>>Consider (with CSS) how you would allow the user to (say a site admin for example) to choose the background colour of his web site (as viewed by visitors) via a site admin page WITHOUT having direct access to the code or editing a CSS file.....

I can think of two ways to do this using my method...

The first is to use the alternative stylesheet syntax and make a styleswitcher.
A bit clunky but it can be done easily enough using SSI files or shared JS (to be fair it's also more trouble than its worth and therefore pointless in a commercial environment)

The other idea is more sophisticated and is much closer to mimicing what .net does (in fact it's an idea I may develop further as a clean solution to cross-browser issues)
It's to do this...
{head}
...
{style type="text/css"}
@import "/cgi-bin/custom_css_output.pl";
{/style}
...
{/head}

Said program will simply output a browser or user specific complete CSS.
This is a direct equivalent to what .net appears to be doing.

HTML spec remains in all cases as xHTML1.0 Strict or transitional, I cannot see why there is a need to downgrade the HTML spec for older browsers, even IE5.0 has no serious issues with xHTML1.0

The downgrade was mainly to handle REALLY old browsers that did not support style attributes properly. There are still a lot in use, in third world educational establishments, and some coporations on UNIX systems. It rarely kicked in, and most .NET 2005 output is XHTML now.

The mechanism has other benefits that I won't go into, but are such things as whether to render javascript at the client or perform a server round trip to deal with a form submission if the browser has javascript disabled. It can also perform cookieless renderings if cookies are disabled or declined etc. etc  And these things you don't code, you just let the .NET framework do it for you...

Because I have been very careful to separate content from style this all hinges on a single CSS file - its just a matter of loading the right one, and in this instance quickly developing a new one for IE7 - once I have sussed what the differences are.

One very significant difference here is that .net is a package that has many features like this already built in. I can see why it has a strong appeal to anyone working in commercial web development.
What I have is much simpler, there are no packages at all, anything I want is doable but I have to do it myself in the first place.
But I don't code things twice - I always build things to be modular so they can be updated/replaced in future as required.

Fortunately this is where my primary skill as a programer comes in.
Someone trying to do this using a WYSIWYG system and trying to build a pure CSS model website is going to come seriously unstuck if they cannot utilise CGI resources - thus they need to use a package with all this taken care off - like .net.
For me I am lucky enough to be able to create the special tools that I need from scratch. As a hobby this is great, it teaches me a good deal and is a real challenge.

But I could never make a living from it, this is the bottom line. You are quite right to point out the big differences in development time.

As I said before this IE7 thing has caught me out which is annoying.
But at the same time I am quite confident that once I have addressed this specific issue my own architecture will pose no problem at all in alowing it to be quickly fixed in a robust fashion.

And it is also true, I believe, that if ALL browsers adopted a standard interpretation of the simple CSS rules then life would be simpler all round, a large chunk of the .net functionality (and its corresponding CPU time) would not be needed!

Thanks for the free download location, I may give it a whirl and see how I get on.

As a general point the key problem for many of the W3C standards is that they define structures and rules that are often very difficult to implement. The object models are often ambiguous, and the definition of error handling is virtually undefined. If the W3C did it's job, they would define not just a standard, but also rendering models to implement the standard. If they did this and commercial co's implemeted the rendering model, there would be much better compatability.

As a standards organisation, W3C sucks. they just aren't good at it. I'd like to see web standards handed over to someone like the ISO organisation who are much more professional and rigid in their approach.  TCP/IP is pretty solid, we don't have connection protocol issues these days, they have it nailed.....


 
AndyF said:
It can be with simple CSS, but can be much more complex if the full potential of CSS3 have been used. Now consider you are a web site developer, and your company has 100+ sites to sort out under maintainace agreements. That is going to cost you a lot of money..!

Yes, I agree. My goal was and still is to find an implementation method for the CSS model (and associated JS/DHTML behaviour) that is as portable and as easily maintained as it can be. For the most part I believe I have succeeded.

AndyF said:
Yes, this is true. But even a complex page it may add, say, a few thousand characters. But that is 1-2K of material. Plonk an image on the page and you instantly may add 50K to fully populate the page, so the increased content is generally insignificant as a proportion of full page footprint. Most people are indeed on broadband of some sort these days.

True - I worry a lot less about big pages nowadays, and your point about images swamping a small amount of extra text is certainly valid.

AndyF said:
The downgrade was mainly to handle REALLY old browsers that did not support style attributes properly. There are still a lot in use, in third world educational establishments, and some coporations on UNIX systems. It rarely kicked in, and most .NET 2005 output is XHTML now.

I am fortunate in that my non-commerial application doesn't need to accomodate these, a simple browser/object detection will either result in the page working corrcetly or a message stating that 'your browser is obsolete, or oddly configured and this site may not work properly'.
You probably could not get away with that but I can.

I quite unashamedly refuse to accomodate version 4 browsers now, IE5.0 is the lowest spec I bother to code for now, and over the next year or so even this will fall by the wayside.

>>most .NET 2005 output is XHTML now.
Glad to hear that!

AndyF said:
The mechanism has other benefits that I won't go into, but are such things as whether to render javascript at the client or perform a server round trip to deal with a form submission if the browser has javascript disabled. It can also perform cookieless renderings if cookies are disabled or declined etc. etc  And these things you don't code, you just let the .NET framework do it for you...

That's useful, as I said before I simply test to see if it will work and either do it or display a message.
I have a variety of simple JS functions that perform object tests that will determine this easily and they are highly portable.

AndyF said:
As a general point the key problem for many of the W3C standards is that they define structures and rules that are often very difficult to implement. The object models are often ambiguous, and the definition of error handling is virtually undefined. If the W3C did it's job, they would define not just a standard, but also rendering models to implement the standard. If they did this and commercial co's implemeted the rendering model, there would be much better compatability.

A certain degree of apples vs oranges here.
The CSS model defines how the CSS itself should work but does not make any statement about object detection or graceful degradation - this has very little to do with the CSS model.
On the other hand .net seems to be addressing more issues. Not sure that a comparison in those terms is really valid; object models and error handling are not really touched by the basic CSS model which is strictly about style.

AndyF said:
As a standards organisation, W3C sucks. they just aren't good at it. I'd like to see web standards handed over to someone like the ISO organisation who are much more professional and rigid in their approach.  TCP/IP is pretty solid, we don't have connection protocol issues these days, they have it nailed.....

By and large I think I agree. The problem is that they are not an 'official' standards body like the ISO.
I too wish they were - then it would become a global standard which even MS would have a hard time trying to 'push'.

I have to say it bugs the hell out of me that after years of 'browser wars' the web-coding system still hasn't settled down into a proper standard.

At the end of the day the basic idea of HTML and associated style using CSS directives is so bloody simple yet the various browser manufacturers, W3C and so on just cannot seem to get it together to sing from the same songbook.

But on the other hand the complexity of it all ensures that it remains in the realm of 'experts' only - which ensures work for web-programmers and coders.
So perhaps we should not rock the boat too much. :)
 
Back
Top