PDA

View Full Version : Something from nothing


David
21st Sep 2004, 10:34 pm
As an adjunct to another thread (http://www.websitearchitecture.net/forum/index.php?showtopic=334&view=findpost&p=2226), I thought I'd just post an example of a web page with nothing on it except an empty <div> tag. Although there is no HTML content on the page, it is still possible to use CSS to "create something from nothing" as it were. Here's the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Testing the box</title>
<style type="text/css">
<!--
#test {
background-color: #C60;
height: 200px;
width: 200px;
margin: 100px auto;
border: 10px solid #F90;
}
-->
</style>
</head>
<body>

<div id="test"></div>

</body>
</html>

Notice that the div tag has an id called "test". This identifies it as being formatted as per the #test style declaration. This declaration basically describes how a browser should render the <div> despite the fact that it contains nothing.

The resultant web page looks like this:

http://www.websitearchitecture.co.uk/watson/postimages/boxtest.gif