<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Off The Top Of My Head &#187; HTML</title>
	<atom:link href="http://waltermilner.wordpress.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://waltermilner.wordpress.com</link>
	<description>Don&#039;t open it</description>
	<lastBuildDate>Fri, 13 Nov 2009 15:22:01 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='waltermilner.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/b44a15b2fa7eb4a7da92d7789987d5e1?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Off The Top Of My Head &#187; HTML</title>
		<link>http://waltermilner.wordpress.com</link>
	</image>
			<item>
		<title>Shadowed text with CSS</title>
		<link>http://waltermilner.wordpress.com/2009/11/03/shadowed-text-with-css/</link>
		<comments>http://waltermilner.wordpress.com/2009/11/03/shadowed-text-with-css/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 15:37:31 +0000</pubDate>
		<dc:creator>waltermilner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[drop shadow]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Krijn Hoetmer]]></category>
		<category><![CDATA[menu bars]]></category>
		<category><![CDATA[shadowed text]]></category>

		<guid isPermaLink="false">http://waltermilner.wordpress.com/?p=208</guid>
		<description><![CDATA[The target was to make a navigation bar like that at www.apple.com, which looks like this:
They did this by having all the links share a single background image, with the x and y offsets for each set so they show the correct part of that single image. In turn the text shadowing has been done [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=waltermilner.wordpress.com&blog=464072&post=208&subd=waltermilner&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The target was to make a navigation bar like that at www.apple.com, which looks like this:</p>
<div id="attachment_209" class="wp-caption alignleft" style="width: 518px"><img class="size-full wp-image-209" title="apple" src="http://waltermilner.files.wordpress.com/2009/11/apple.jpg?w=508&#038;h=96" alt="apple navbar" width="508" height="96" /><p class="wp-caption-text">Apple navbar</p></div>
<p>They did this by having all the links share a single background image, with the x and y offsets for each set so they show the correct part of that single image. In turn the text shadowing has been done in the graphics package that made the image.</p>
<p>I wanted something like this that could be done using CSS, without having to handcraft a background image for each link. That&#8217;s what we&#8217;re trying to do.</p>
<p>Thanks to Krijn Hoetmer I had a JavaScript function which would shadow some text. But the first problem would be that I would need to put both a JavaScript link and a style sheet link in the HTML &#8211; I wanted just one link. After some Googling and experimenting I had some JS which would dynamically load a style sheet:</p>
<address>var cssNode = document.createElement(&#8216;link&#8217;);</address>
<address>cssNode.type = &#8216;text/css&#8217;;</address>
<address>cssNode.rel = &#8217;stylesheet&#8217;;</address>
<address>cssNode.href = &#8216;menuBar1.css&#8217;;</address>
<address>cssNode.media = &#8217;screen&#8217;;</address>
<address>cssNode.title = &#8216;dynamicLoadedSheet&#8217;;</address>
<address>document.getElementsByTagName(&#8220;head&#8221;)[0].appendChild(cssNode);</address>
<p>So menuBar1.css would style the menu bar, and this JS would load it.</p>
<p>Next task is to shadow the text on eack link. This works by getting the div which encloses the menu, getting each of the child nodes, and calling the shadow function for each one:</p>
<address>var menu=document.getElementById(&#8220;menu&#8221;);</address>
<address>var children=menu.childNodes;</address>
<address>for (i=0; i&lt;children.length; i++)</address>
<address> {</address>
<address> applyShadow(children[i], &#8216;white&#8217;, 3,10, 7);</address>
<address> }</address>
<p>The applyShadow function is originally by Krijn Hoetmer is modified here slightly, to handle text which has some padding (third and fourth parameters are teh left and top padding:</p>
<address>function applyShadow(targetElement, shadowColor, shadowOffset,pside, ptop) {</address>
<address> if (typeof(targetElement) != &#8216;object&#8217;) {</address>
<address> targetElement = document.getElementById(targetElement);</address>
<address> }</address>
<address> var value = targetElement.firstChild.nodeValue;</address>
<address> targetElement.style.position = &#8216;relative&#8217;;</address>
<address> targetElement.style.zIndex = 1;</address>
<address> var newEl = document.createElement(&#8217;span&#8217;);</address>
<address> newEl.appendChild(document.createTextNode(value));</address>
<address> newEl.className = &#8217;shadowed&#8217;;</address>
<address> newEl.style.color = shadowColor;</address>
<address> newEl.style.position = &#8216;absolute&#8217;;</address>
<address> newEl.style.left = &#8216;0px&#8217;;</address>
<address> newEl.style.top = shadowOffset + &#8216;px&#8217;;</address>
<address> newEl.style.zIndex = -1;</address>
<address> newEl.style.paddingLeft=pside+1+&#8221;px&#8221;;</address>
<address> newEl.style.paddingTop=ptop+1+&#8221;px&#8221;;</address>
<address> targetElement.appendChild(newEl);</address>
<p>}</p>
<p>The HTML this is applying to is:</p>
<p>&lt;div id=&#8221;menu&#8221;&gt;&lt;a href=&#8221;nowhere&#8221; &gt;Link One&lt;/a&gt;&lt;a href=&#8221;nowhere&#8221;&gt;Link Two&lt;/a&gt;&lt;a href=&#8221;nowhere&#8221;&gt;Link Three&lt;/a&gt;&lt;a href=&#8221;nowhere&#8221;&gt;Link Four&lt;/a&gt;&lt;/div&gt;</p>
<p>This is all done in one line &#8211; any spaces or CRs produce spurious white space text nodes in the DOM tree.</p>
<p>This shadows the text &#8211; but we need to insert graphics for the link separators.  This is a rather bizarre loop:</p>
<address>var count = children.length;</address>
<address>for (i=0; i&lt;count*2; i++)</address>
<address>{ </address>
<address> var image = document.createElement(&#8216;img&#8217;);</address>
<address> image.setAttribute(&#8217;src&#8217;,'images/gap.gif&#8217;);</address>
<address> menu.insertBefore(image,children[i]);</address>
<address> i++;</address>
<address>}</address>
<p>we go for twice the number of child nodes that are there &#8211; because when we&#8217;ve finished, we&#8217;ll have twice that number. And we go i++ every time we add one. children is dynamically updated as we add nodes.</p>
<p>The style sheet is</p>
<address>#menu</address>
<address>{</address>
<address> position: absolute;</address>
<address> left: 20%;</address>
<address> right: 20%;</address>
<address> min-width: 32%;</address>
<address> background-image: url(images/linkbg.gif);</address>
<address> -moz-border-radius: 5px;</address>
<address> text-align: center;</address>
<address> height: 37px; </address>
<address>}</address>
<address>
#menu a</address>
<address>{</address>
<address> position:relative;</address>
<address> color: black;</address>
<address> font-family: arial, helvetica, sans-serif;</address>
<address> font-size:11px;</address>
<address> padding-left: 10px;</address>
<address> padding-top: 10px;</address>
<address> padding-bottom:10px;</address>
<address> top:-15px; </address>
<address>}</address>
<p>The background image is 37 pixels high. We&#8217;ll only get round corners in FF &#8211; that&#8217;s IE&#8217;s problem. The result is:</p>
<div id="attachment_210" class="wp-caption alignleft" style="width: 477px"><img class="size-full wp-image-210" title="menu" src="http://waltermilner.files.wordpress.com/2009/11/menu.jpg?w=467&#038;h=86" alt="menu bar" width="467" height="86" /><p class="wp-caption-text">My version</p></div>
<p>Works in FF and IE</p>
<p>&nbsp;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/waltermilner.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/waltermilner.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/waltermilner.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/waltermilner.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/waltermilner.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/waltermilner.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/waltermilner.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/waltermilner.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/waltermilner.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/waltermilner.wordpress.com/208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=waltermilner.wordpress.com&blog=464072&post=208&subd=waltermilner&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://waltermilner.wordpress.com/2009/11/03/shadowed-text-with-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d1cd29e1482533ded586b3a66c70ac0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">waltermilner</media:title>
		</media:content>

		<media:content url="http://waltermilner.files.wordpress.com/2009/11/apple.jpg" medium="image">
			<media:title type="html">apple</media:title>
		</media:content>

		<media:content url="http://waltermilner.files.wordpress.com/2009/11/menu.jpg" medium="image">
			<media:title type="html">menu</media:title>
		</media:content>
	</item>
		<item>
		<title>Height of divs</title>
		<link>http://waltermilner.wordpress.com/2009/09/15/height-of-divs/</link>
		<comments>http://waltermilner.wordpress.com/2009/09/15/height-of-divs/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 16:05:19 +0000</pubDate>
		<dc:creator>waltermilner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[web pages]]></category>

		<guid isPermaLink="false">http://waltermilner.wordpress.com/?p=200</guid>
		<description><![CDATA[In a CSS style sheet its common to center the content by having a div with an id styled like
#outer
{
position: relative;
width: 400px;
margin: auto;
background-color: rgb(1,0,104);
border: 5px white solid;
}
which is 400 wide and centered. But what height? You can fix the height, but if you want it to work with any content, there is an &#8216;issue&#8217;. By [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=waltermilner.wordpress.com&blog=464072&post=200&subd=waltermilner&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In a CSS style sheet its common to center the content by having a div with an id styled like</p>
<p>#outer<br />
{<br />
position: relative;<br />
width: 400px;<br />
margin: auto;<br />
background-color: rgb(1,0,104);<br />
border: 5px white solid;<br />
}</p>
<p>which is 400 wide and centered. But what height? You can fix the height, but if you want it to work with any content, there is an &#8216;issue&#8217;. By default a div goes &#8216;height:auto;&#8217;, and expands to enclose its content. This works &#8211; sort of. Suppose the html is<br />
&lt;div id=&#8221;outer&#8221;&gt;</p>
<p>blah blah blah</p>
<p>blah blah&lt;/div&gt;</p>
<p>then you see:</p>
<p><img class="alignleft size-full wp-image-201" title="pic1" src="http://waltermilner.files.wordpress.com/2009/09/pic1.png?w=433&#038;h=68" alt="pic1" width="433" height="68" /></p>
<p>so the outer div has expanded. Now suppose you put another div inside the outer div:<br />
&lt;div id=&#8221;outer&#8221;&gt;<br />
&lt;div id=&#8221;title&#8221;&gt;The title&lt;br/&gt;on two lines&lt;/div&gt;<br />
blah blah blah<br />
blah blah<br />
&lt;/div&gt;</p>
<p>and title is styled</p>
<p>#title<br />
{<br />
border: thin red solid;<br />
}</p>
<p>then we see:</p>
<p><img class="alignleft size-full wp-image-202" title="pic2" src="http://waltermilner.files.wordpress.com/2009/09/pic2.png?w=474&#038;h=106" alt="pic2" width="474" height="106" /></p>
<p>still correct. Now suppose we position title absolute, like this:</p>
<p>#title<br />
{<br />
position: absolute;<br />
top:20px;<br />
left:50px;<br />
border: thin red solid;<br />
}</p>
<p>Now we see:</p>
<p><img class="alignleft size-full wp-image-203" title="pic3" src="http://waltermilner.files.wordpress.com/2009/09/pic3.png?w=453&#038;h=99" alt="pic3" width="453" height="99" /></p>
<p>The browser is not clever enough to work out what height it would need to be to enclose the inner div &#8211; it has given up. So you can&#8217;t use absolute positioning if you want the containing div to work out its correct height.</p>
<p>If you use relative positioning &#8211; the containing div height is correct, according to the &#8216;initial&#8217; position of the inner div, before its moved, as it were. For example, if you had</p>
<p>#title<br />
{<br />
position: relative;<br />
top:20px;<br />
left:50px;<br />
border: thin red solid;<br />
}</p>
<p>you see:</p>
<p><img class="alignleft size-full wp-image-204" title="pic4" src="http://waltermilner.files.wordpress.com/2009/09/pic4.png?w=503&#038;h=108" alt="pic4" width="503" height="108" /></p>
<p>The browser has left room for it in its initial position, above the &#8216;blah blah&#8217;.</p>
<p>So this is OK for left-right positioning. What if we want it not at the top? Set a margin-top:</p>
<p>#title<br />
{<br />
position: relative;<br />
top:0px;<br />
left:50px;<br />
width: 100px;<br />
margin-top:50px;<br />
border: thin red solid;<br />
}</p>
<p>and you get:</p>
<p><img class="alignleft size-full wp-image-205" title="pic5" src="http://waltermilner.files.wordpress.com/2009/09/pic5.png?w=458&#038;h=161" alt="pic5" width="458" height="161" /></p>
<p>This took me all afternoon. Ha!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/waltermilner.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/waltermilner.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/waltermilner.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/waltermilner.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/waltermilner.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/waltermilner.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/waltermilner.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/waltermilner.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/waltermilner.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/waltermilner.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=waltermilner.wordpress.com&blog=464072&post=200&subd=waltermilner&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://waltermilner.wordpress.com/2009/09/15/height-of-divs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d1cd29e1482533ded586b3a66c70ac0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">waltermilner</media:title>
		</media:content>

		<media:content url="http://waltermilner.files.wordpress.com/2009/09/pic1.png" medium="image">
			<media:title type="html">pic1</media:title>
		</media:content>

		<media:content url="http://waltermilner.files.wordpress.com/2009/09/pic2.png" medium="image">
			<media:title type="html">pic2</media:title>
		</media:content>

		<media:content url="http://waltermilner.files.wordpress.com/2009/09/pic3.png" medium="image">
			<media:title type="html">pic3</media:title>
		</media:content>

		<media:content url="http://waltermilner.files.wordpress.com/2009/09/pic4.png" medium="image">
			<media:title type="html">pic4</media:title>
		</media:content>

		<media:content url="http://waltermilner.files.wordpress.com/2009/09/pic5.png" medium="image">
			<media:title type="html">pic5</media:title>
		</media:content>
	</item>
		<item>
		<title>My pretty pastel website</title>
		<link>http://waltermilner.wordpress.com/2008/03/14/my-pretty-pastel-website/</link>
		<comments>http://waltermilner.wordpress.com/2008/03/14/my-pretty-pastel-website/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 15:30:45 +0000</pubDate>
		<dc:creator>waltermilner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[website design]]></category>

		<guid isPermaLink="false">http://waltermilner.wordpress.com/?p=43</guid>
		<description><![CDATA[I&#8217;ve hardly touched my website for around a year, but I&#8217;m currently preparing to teach a week-long course on HTML, CSS, JavaScript, SQL and PHP (pretty good in a week) so I thought I should practice what I preach. Which I can&#8217;t, really, because I&#8217;m visually pretty uncreative. But I know how to Google, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=waltermilner.wordpress.com&blog=464072&post=43&subd=waltermilner&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve hardly touched my website for around a year, but I&#8217;m currently preparing to teach a week-long course on HTML, CSS, JavaScript, SQL and PHP (pretty good in a week) so I thought I should practice what I preach. Which I can&#8217;t, really, because I&#8217;m visually pretty uncreative. But I know how to Google, and I found <a href="http://www.wellstyled.com/tools/colorscheme2/index-en.html">this</a> excellent color scheme gismo, and <a href="http://www.sitepoint.com/article/anatomy-web-fonts">this</a> piece about web fonts, and the result is <a href="http://www.waltermilner.com/">this</a>. What do you think?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/waltermilner.wordpress.com/43/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/waltermilner.wordpress.com/43/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/waltermilner.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/waltermilner.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/waltermilner.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/waltermilner.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/waltermilner.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/waltermilner.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/waltermilner.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/waltermilner.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/waltermilner.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/waltermilner.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=waltermilner.wordpress.com&blog=464072&post=43&subd=waltermilner&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://waltermilner.wordpress.com/2008/03/14/my-pretty-pastel-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d1cd29e1482533ded586b3a66c70ac0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">waltermilner</media:title>
		</media:content>
	</item>
	</channel>
</rss>