0

Let's say we have the following html syntax:

<TABLE width=400, height=300>
<TR>
  <TD color=Red>SOME TEXT</TD>
</TR>
</TABLE>

as it can be seen, there is no style used, all tags are written using the uppercase letters. This is invalid. I would like to inform it this kind of incorrect HTML syntax has an influence in web performance?

Additionally, in the code I get from the client, lots of HTML controls are build in code-behind and then injected in the aspx. How is with performance in such a case?

niao
  • 4,972
  • 19
  • 66
  • 114
  • See this question: http://stackoverflow.com/questions/846994/how-to-use-html-agility-pack You can use HtmlAgilityPack to fix bad html – Adrian Iftode Mar 19 '12 at 11:49

3 Answers3

1

Uppercase elements are valid in HTML. HTML is case insensitive. While XHTML is not - everything should be lower case.

Upper vs lower case should not affect performance. But lots of CSS inline with the HTML might very well affect performance as often an external CSS will more effectively define the style globally instead of each element.

HTML

http://www.w3.org/TR/html4/about.html#h-1.2.1

Element names are written in uppercase letters (e.g., BODY). Attribute names are written in lowercase letters (e.g., lang, onsubmit). Recall that in HTML, element and attribute names are case-insensitive; the convention is meant to encourage readability.

XHTML

http://www.w3.org/TR/xhtml1/#h-4.2

XHTML documents must use lower case for all HTML element and attribute names. This difference is necessary because XML is case-sensitive e.g. <li> and <LI> are different tags.

thomthom
  • 2,854
  • 1
  • 23
  • 53
1

The only violation of generic HTML syntax is the comma in <TABLE width=400, height=300>. The comma will probably be taken as part of the attribute value and then ignored. The cost of this error processing is ignorable.

Performance is not an issue here. Basic rendering is.

The height attribute for table is not allowed by HTML specs; though widely supported by browsers, the support is not required (even in HTML5 drafts, which generally require continued support to legacy features) and may be removed in future browsers.

The color attribute for td is not allowed by HTML specs. It is not supported by any browser I know of. So if the intent was to make the text red, it will fail.

The conclusions depend on what you need and can do with the markup. If you cannot adequately change the markup but can inject CSS rules, then you could even fix the non-working non-standard attributes, using e.g.

<style>
[color=Red] { color: red; }
</style> 

This would get tedious since you would need e.g. separate rule for each color, and this would not work on some old browsers.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
0

Building HTML controls server-side takes virtually no time at all. In addition, receiving invalid markup will barely affect the rendering time of the browser - however it will affect the display as it will force the client into quirks mode and make a lot of style properties unusable.

Beyond that I'm not sure what exactly you want to know by asking for information on a hypothetical syntax.

deed02392
  • 4,799
  • 2
  • 31
  • 48
  • it's not a hypothetical syntax. It's the syntax from a real code I received from the client – niao Mar 19 '12 at 11:50