![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi everyone, I've got a question about what makes the "img" element's width/height attributes valid HTML or XHTML. First of all, this is a rather theoretical question, but digging through the W3C HTML 4.01 standard and this group's archive didn't give me a satisfactory answer, so here we go: Is <img src="img.png" alt="" width="100px" height="100px"> really valid? That kind of width/height specification is certainly accepted by the W3C validator (no matter which version of HTML or XHTML you use), but to my surprise, I found out that the validator accepts virtually everything for the width/height attributes, even negative and non-numeric values, for example: img src="img.png" alt="" width="-100" height="fifty" According to [1], width/height are of type "length", which is either a percentage ("50%" is explicitly stated as an example) or "%Pixel" [2]. There it says that a pixel value is an "integer representing length in pixels". So if the standard requires an integer value for width/height, why does the validator accept non-integer values? And why doesn't the standard require unsigned integers? |
#3
| |||
| |||
|
|
I've got a question about what makes the "img" element's width/height attributes valid HTML or XHTML. First of all, this is a rather theoretical question, but digging through the W3C HTML 4.01 standard and this group's archive didn't give me a satisfactory answer, so here we go: Is <img src="img.png" alt="" width="100px" height="100px"> really valid? |
|
That kind of width/height specification is certainly accepted by the W3C validator (no matter which version of HTML or XHTML you use), but to my surprise, I found out that the validator accepts virtually everything for the width/height attributes, even negative and non-numeric values, for example: img src="img.png" alt="" width="-100" height="fifty" |
#4
| |||
| |||
|
|
.oO(Christian Hackl) Is <img src="img.png" alt="" width="100px" height="100px"> really valid? ... an SGML validator like the W3 validator cannot check attribute values. |
|
Specifically, an SGML parser ensures that the syntax, the structure, the list of elements, and their attributes are valid. But for instance, it cannot catch errors such as setting the width attribute of an IMG element to an invalid value (i.e., "foo" or "12.5"). Although the specification restricts the value for this attribute to an "integer representing a length in pixels," the DTD only defines it to be CDATA, which actually allows any value. Only a specialized program could capture the complete specification of HTML 4. |
|
A schema validator can, which is what you should use to validate XML/XHTML. |
#5
| |||
| |||
|
|
Is <img src="img.png" alt="" width="100px" height="100px"> really valid? No, but ... |
|
img src="img.png" alt="" width="-100" height="fifty" ... an SGML validator like the W3 validator cannot check attribute values. |
|
A schema validator can, which is what you should use to validate XML/XHTML. |
#6
| |||
| |||
|
|
A schema validator, using suitable schema, can check much more than a DTD validator, for sure. However, this is about XML (including XHTML), and we can see from the lack of the magic "/" that the OP is using classic, nominally SGML based HTML. |

|
Moreover, there is no normative schema for XHML 1.0. The schemas are just unofficial attempts at capturing the syntax requirements (partly formal, partly prose) in the XHTML 1.0 specification. |
#7
| |||
| |||
|
|
Moreover, there is no normative schema for XHML 1.0. The schemas are just unofficial attempts at capturing the syntax requirements (partly formal, partly prose) in the XHTML 1.0 specification. What about XHTML 1.1? |
|
Are you telling me that there is no official (W3C) definition of what is conforming XHTML 1.0? |
#8
| |||
| |||
|
|
Scripsit Christian Hackl: Are you telling me that there is no official (W3C) definition of what is conforming XHTML 1.0? No, I'm telling you that there is no normative _schema_. XHTML 1.0 is defined in a quick and dirty way: the syntax is defined using a DTD (not a schema), with some extra requirements written in prose, and with a reference to HTML 4.01 as regards to any _meaning_ of the elements. This leaves some issues open, so that there are different ways to write a schema definition. |
#9
| |||||
| |||||
|
|
OK, let's see if I got it... |
|
There are some XHTML schemas published by the W3C, for example here: http://www.w3.org/TR/xhtml1-schema/ However, those documents are just informal notes and are considered work in progress, so they aren't exactly "official" schemas. |
|
Still, they are good enough to be used by schema validators such as schneegans.de, because they contain improvements such as concise formal definitions for data types |
|
(which allows you, among other things, to formally define that "width" and "height" must be integer values). |
|
There is no official (normative) schema neither for XHTML 1.0 nor XHTML 1.1, there are just normative DTDs, which are unable to express important requirements of the languages. Is this correct? |
#10
| |||
| |||
|
|
The situation is the same. On the other hand, XHTML 1.1 is an exercise in futility. Even if you fake it to be text/html (there's an eternal debate over the issue whether this is even "legal") |
![]() |
| Thread Tools | |
| Display Modes | |
| |