HTML and CSS Reference
In-Depth Information
Attribute Values May Be Case Sensitive
Consider <img SRC= " test.gif " > and <IMG src= " test.gif " > . Under traditional HTML,
these are equivalent because the <img> tag and the src attribute are not case sensitive.
However, given XHTML, they should always be lowercase. However, just because attribute
names are not case sensitive under traditional HTML, this doesn't mean every aspect of
attributes is case insensitive.
Regardless of the use of XHTML or HTML, the actual attribute values in some tags may
be case sensitive, particularly where URLs are concerned. So <img src= " test.gif " > and
<img src= " TEST.GIF " > do not necessarily reference the same image. When referenced
from a UNIX-based Web server, where filenames are case sensitive, test.gif and TEST.GIF
would be two different files, whereas on a Windows Web server, where filenames are not
case sensitive, they would reference the same file. This is a common problem and often
hinders the ability to easily transport a Web site from one server to another.
(X)HTML Is Sensitive to a Single Whitespace Character
Any white space between characters displays as a single space. This includes all tabs, line
breaks, and carriage returns. Consider this markup:
<strong> T e s t o f s p a c e s </strong><br>
<strong> T e s t o f s p a c e s </strong><br>
<strong> T
e s
t o f s p a c e s </strong><br>
As shown here, all the spaces, tabs, and returns are collapsed to a single element:
However, it is possible to force the whitespace issue. If more spaces are required, it is
possible to use the nonbreaking space entity, or &nbsp; . Some consider this the duct tape of
the Web—useful in a bind when a little bit of spacing is needed or an element has to be kept
from collapsing. Yet using markup such as
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Look, I'm spaced out!
would add space to the output, the question is, exactly how far? In print, using spaces to
format is dangerous given font size variability, so text rarely lines up. This is no different on
the Web.
Further note that in some situations, (X)HTML does treat whitespace characters differently.
In the case of the pre element, which defines a preformatted block of text, white space is
preserved rather than ignored because the content is considered preformatted. It is also
possible to use the CSS property white-space to change default whitespace handling.
Because browsers will ignore most white space, Web page authors often format their
documents for readability. However, the reality is that browsers really don't care one way or
another, nor do end users. Because of this, some sites have adopted a markup optimization
idea, often called crunching or minification , to save bandwidth.
Search WWH ::




Custom Search