HTML and CSS Reference
In-Depth Information
"This is the right place \
for a newline."
"This is the right place for a newline."
If, on the other hand, you actually want a string value that includes a newline character,
then use the Unicode reference
\A
where you want the newline to occur.
"This is a better place \Afor a newline."
URLs
If you've written web pages, you're obviously familiar with URLs (or, as in CSS2.1,
URIs). Whenever you need to refer to one—as in the
@import
statement, which is used
when importing an external style sheet—the general format is:
url(protocol://
server
/
pathname
)
This example defines what is known as an
absolute URL
. By absolute, I mean a URL
that will work no matter where (or rather, in what page) it's found, because it defines
an absolute location in web space. Let's say that you have a server called web.waffles.org
rectory is an image
waffle22.gif
. In this case, the absolute URL of that image would be:
http://web.waffles.org/pix/waffle22.gif
This URL is valid no matter where it is found, whether the page that contains it is
located on the server
web.waffles.org
or
web.pancakes.com
.
The other type of URL is a
relative URL
, so named because it specifies a location that
is relative to the document that uses it. If you're referring to a relative location, such as
a file in the same directory as your web page, then the general format is:
url(
pathname
)
This works only if the image is on the same server as the page that contains the URL.
For argument's sake, assume that you have a web page located at
http://web.waffles.org/
syrup.html
and that you want the image
waffle22.gif
to appear on this page. In that
case, the URL would be:
pix/waffle22.gif
This path works because the web browser knows that it should start with the place it
found the web document and then add the relative URL. In this case, the pathname
pix/waffle22.gif
added to the server name
http://web.waffles.org
equals
http://web.waf
fles.org/pix/waffle22.gif
. You can almost always use an absolute URL in place of a rel-
ative URL; it doesn't matter which you use, as long as it defines a valid location.
In CSS, relative URLs are relative to the style sheet itself, not to the HTML document
that uses the style sheet. For example, you may have an external style sheet that imports
another style sheet. If you use a relative URL to import the second style sheet, it must
be relative to the first style sheet.