PDA

View Full Version : Something from nothing



David
21st Sep 2004, 11:34 pm
As an adjunct to another thread (http://www.websitearchitecture.net/forum/index.php?showtopic=334&view=findpost&p=2226), I thought I&#39;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&#39;s the code:

&#60;&#33;DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http&#58;//www.w3.org/1999/xhtml&#34;&#62;
&#60;head&#62;
&#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=iso-8859-1&#34; /&#62;
&#60;title&#62;Testing the box&#60;/title&#62;
&#60;style type=&#34;text/css&#34;&#62;
&#60;&#33;--
#test {
background-color&#58; #C60;
height&#58; 200px;
width&#58; 200px;
margin&#58; 100px auto;
border&#58; 10px solid #F90;
}
--&#62;
&#60;/style&#62;
&#60;/head&#62;
&#60;body&#62;

&#60;div id=&#34;test&#34;&#62;&#60;/div&#62;

&#60;/body&#62;
&#60;/html&#62;

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