Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is the HTML on this site so clean?

I work with C# at work but dislike how with webforms it spews out a lot of JavaScript not including the many lines for viewstate that it creates.

That's why I like coding with PHP as I have full control.

But I was just wondering how this sites HTML is so clean and elegant?

Does using MVC have something to do with it? I see that JQuery is used but surely you still use asp:required validators? If you do, where is all the hideous code that it normally produces?

And if they arent using required field validators, why not? Surely it's quicker to develop in than using JQuery?

One of the main reasons I code my personal sites in PHP was due to the more elegant HTML that it produces but if I can produce code like this site then I will go full time .net!

like image 737
KevinUK Avatar asked Aug 15 '08 21:08

KevinUK


People also ask

What is HTML cleaning?

HTML Cleaner removes unwanted spaces and make the html code readable, also provide option to get clean text from the html.

Why is the source code on websites so messy?

Because most of it is generated from code. HTML doesn't care about line breaks (mostly), and code usually doesn't insert any line breaks. Even Javascript can be generated from server-side code. All this put together makes it look messy.


3 Answers

One of the goals of ASP.NET MVC is to give you control of your markup. However, there have always been choices with ASP.NET which would allow you to generate relatively clean HTML.

For instance, ASP.NET has always offered a choice with validator controls. Do you value development speed over markup? Use validators. Value markup over development speed? Pick another validation mechanism. Your comments on validators are kind of contradictory there - it's possible to use ASP.NET and still make choices for markup purity over development speed.

Also, with webforms, we've had the CSS Friendly Control Adapters for a few years which will modify the controls to render more semantic markup. ASP.NET 3.5 included the ListView, which makes it really easy to write repeater type controls which emit semantic HTML. We used ASP.NET webforms on the Microsoft PDC site and have kept the HTML pretty clean: http://microsoftpdc.com/Agenda/Speakers.aspx - the Viewstate could probably be disabled on most pages, although in reality it's only a few dozen bytes.

like image 124
Jon Galloway Avatar answered Oct 19 '22 18:10

Jon Galloway


You were on the right track. It is the fact that they are using the ASP.NET MVC web framework. It allows you to have full control of your output html.

like image 3
Dale Ragan Avatar answered Oct 19 '22 18:10

Dale Ragan


The ASP.NET MVC Framework is an alternative to the normal "web forms" way of doing ASP.NET development. With it you lose a lot of abstraction, but gain a lot of control.

like image 3
Zack Peterson Avatar answered Oct 19 '22 20:10

Zack Peterson