<?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/"
	>

<channel>
	<title>Indiana University: IT Training Tips Blog &#187; Cascading Style Sheets</title>
	<atom:link href="http://ittrainingtips.iu.edu/category/cascading-style-sheets/feed" rel="self" type="application/rss+xml" />
	<link>http://ittrainingtips.iu.edu</link>
	<description>Tips and tricks to help you make the most of technology</description>
	<lastBuildDate>Thu, 16 May 2013 16:17:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using the CSS content property to update text content across your site</title>
		<link>http://ittrainingtips.iu.edu/cascading-style-sheets/using-the-css-content-property-to-update-text-content-across-your-site/10/2011</link>
		<comments>http://ittrainingtips.iu.edu/cascading-style-sheets/using-the-css-content-property-to-update-text-content-across-your-site/10/2011#comments</comments>
		<pubDate>Sat, 15 Oct 2011 22:52:13 +0000</pubDate>
		<dc:creator>Chabane Maidi</dc:creator>
				<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://ittrainingtips.iu.edu/?p=4143</guid>
		<description><![CDATA[You&#8217;ve fully completed the home page for a new website you&#8217;re working on, and you&#8217;re about ready to copy it dozens of times to flesh out the rest of the pages for your website. Right before you start duplicating that index.html page, you remember that you wanted to add copyright information to the footer. It [...]]]></description>
				<content:encoded><![CDATA[<p>You&#8217;ve fully completed the home page for a new website you&#8217;re working on, and you&#8217;re about ready to copy it dozens of times to flesh out the rest of the pages for your website. Right before you start duplicating that index.html page, you remember that you wanted to add copyright information to the footer.<br />
It is also a bit of a wake up call that you could have remembered to put in the copyright information a month later and would have to, at that point, go into each of these of pages individually to fix the footer.<br />
This tutorial is about a handy little css property that allows you to control the content inside of any given element in your xhtml documents. Since this can be handled in an external css stylesheet document, you&#8217;d be able to change the content across all the dependent xhtml files while only having to go to one place.<br />
Prerequisite knowledge:<br />
an intermediate understanding of XHTML and CSS<br />
Say we have a page like this:<br />
<img src="http://ittrainingtips.iu.edu/wp-content/uploads/2011/09/samplePage1.png" alt="An example of a web page with a footer at the bottom" /><br />
Note: this tutorial assumes you would know how to create a page like this, or any basic webpage for that matter.<br />
The footer has a bit of contact information inside of it, but let&#8217;s say we also want to add the copyright information to the footer, next to the email address.<br />
The code for the footer may look like this:</p>
<pre><code>
&lt;div id=&quot;footer&quot;&gt;
  &lt;p&gt;contact: email@example.com&lt;/p&gt;
&lt;/div&gt;
</code></pre>
<p>The css property we will be using to insert the desired additional text is the &#8220;content&#8221; property. There are a few quirks to get used to when using this property. For one, the property can only be used in a rule whose selector uses the either the &#8220;before&#8221; or &#8220;after&#8221; pseudo-selector. The content that you add using css will be placed within the targeted element, but whether the content will appear before or after the pre-existing content of the targeted element depends on which pseudo-selector you choose.<br />
Since we want the copyright information to appear after the e-mail address, we will use the &#8220;after&#8221; pseudo-selector. Create an additional rule in your stylesheet as follows:</p>
<pre><code>
div#footer p:after
{
  
}
</code></pre>
<p>This rule will target only paragraphs within the footer, and place whatever the value of the content property is after the existing content within the paragraph. Let&#8217;s create this copyright information with the content property now:</p>
<pre><code>
div#footer p:after
{
  content: " - copyright 2011";
}
</code></pre>
<p>If you look at the page in a browser, you should see that the footer now says &#8220;contact: email@example.com &#8211; copyright 2011&#8243;. Every page on the website should now have the updated footer, and we didn&#8217;t have to lay a finger on any of the xhtml documents.<br />
Success, right? Well let&#8217;s say that you wanted to use the copyright character entity instead of the text &#8220;copyright.&#8221; Naturally, you&#8217;d think to replace &#8220;copyright&#8221; with the &amp;copy; character entity. You can go ahead and try it if you&#8217;d like.<br />
What you&#8217;d see is that the text &#8220;&amp;copy;&#8221; appears literally on the webpage. The next thing you might do is remember that each character entity name has an entity number value too, that can be used as a character entity reference as well. You could then look up copyright&#8217;s character entity value as 169, and try replacing &amp;copy; with &amp;&#035;169; in that content property value.<br />
Well, this would have worked if we were using &amp;&#035;169; in the xhtml content, but unfortunately, it does not work that way in the css. In order to get these character entities to work, we have to convert the entity decimal value to hexadecimal and use css escape syntax. If you don&#8217;t understand what is meant by all that, then no worries, the process is really straightforward.<br />
First, do an internet search for &#8220;decimal to hex converter&#8221;; there are many of these resources on the web. In fact, you can simply type in &#8220;169 decimal to hex&#8221; to the bing search engine, and the answer should be at the top of the results, without having to go into any pages.<br />
The hexadecimal equivalent of decimal value 169 is hex value A9.<br />
Note: to differentiate hexadecimal numbers from standard [base ten or decimal] numbers, some resources might use the &#8220;0x&#8221; notation, e.g., 0xA9 for the hexadecimal value A9.<br />
In order to use this in the css content property value, to prevent literally displaying &#8220;A9&#8243; we need to use the css &#8220;escape&#8221; syntax to use it as a character entity. We do this with a backslash.<br />
Replace &amp;copy; (or &#8220;copyright&#8221; if you didn&#8217;t attempt to use the xhtml character entity name) with &#8220;\A9 &#8220;:<br />
<code><br />
content: " - \A9 &nbsp;2011";<br />
</code><br />
Note: there are two spaces between &#8220;\A9&#8243; and &#8220;2011&#8243; and that is because the space following the hexadecimal value is part of the escape syntax. The space prevents ambiguity in situations where the designer wants the character entity to appear next to the content without any space, and the first character of that content just so happens to be a hexadecimal digit (i.e. 0-9 and a-f or A-F). If we wanted &#8220;&copy;2011&#8243; (that is, no space between &copy; and 2011) then we would use &#8220;\A9 2011&#8243; instead of &#8220;\A92011&#8243; because the browser can&#8217;t tell you don&#8217;t mean \A and 92011, or \A92 and 011, \A920 and 11, and so on.<br />
Well, everything works, but before you leave here to try this on your own project, there are a couple important items to consider.<br />
First, the content property and the :before and :after pseudo-selectors do not work in versions of Internet Explorer before IE8, so if this content you will generate with this css technique is pivotal to the accessibility of your site, then it may be a good idea to hold off until more users have migrated away from those earlier versions of IE.<br />
Second, and somewhat related to the previous concern, is the idea of semantics. Css is meant to be used for presentation and style only. All content and structure is intended to be kept in xhtml. This being said, when we use the content property, it is usually to enhance the page, rather than to add essential content.<br />
Along this same vein, you may have already noticed that you cannot drag-select the text generated with the content property, because as far as the actual document goes, that content does not actually exist&#8211; it is merely presentational elements from css, and so it most definitely will not be used in any semantic application, like use in &#8220;pagerank&#8221; for Google&#8217;s search engine, accessibility with screen readers, and so forth.<br />
As long as you are aware of these caveats, then go ahead and find clever uses of this unique and powerful css property.</p>
]]></content:encoded>
			<wfw:commentRss>http://ittrainingtips.iu.edu/cascading-style-sheets/using-the-css-content-property-to-update-text-content-across-your-site/10/2011/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using JavaScript to create a dynamic tab-based webpage</title>
		<link>http://ittrainingtips.iu.edu/cascading-style-sheets/using-javascript-to-create-a-dynamic-tab-based-webpage/09/2011</link>
		<comments>http://ittrainingtips.iu.edu/cascading-style-sheets/using-javascript-to-create-a-dynamic-tab-based-webpage/09/2011#comments</comments>
		<pubDate>Mon, 26 Sep 2011 11:13:14 +0000</pubDate>
		<dc:creator>Chabane Maidi</dc:creator>
				<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Basics]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://ittrainingtips.iu.edu/?p=4106</guid>
		<description><![CDATA[Have you ever been to a web page where you can click on buttons or tabs that swap content on the page without having to load an entirely separate web page? Have you ever wondered how to make your own page have similar behavior? Well, there&#8217;s good news and bad news. The bad news is [...]]]></description>
				<content:encoded><![CDATA[<p>Have you ever been to a web page where you can click on buttons or tabs that swap content on the page without having to load an entirely separate web page? Have you ever wondered how to make your own page have similar behavior?<br />
Well, there&#8217;s good news and bad news. The bad news is that you&#8217;re going to need to write a bit of javascript to get this to work, and if you don&#8217;t know javascript, I can understand your reflex to just close this tutorial right now&#8211; but hold on! The good news is that it&#8217;s simple and doesn&#8217;t require an in-depth understanding of javascript to get this working.</p>
<p>Prerequisites for this tutorial:<br />
A moderate understanding of XHTML and CSS</p>
<p><span id="more-4106"></span>In order to get started, create a new xhtml document using your favorite xhtml editor, and save it as anything you like (make sure it has either an htm or html file extension!), and copy the following code into your blank document:</p>
<pre><code>
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0
Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;EN&quot; lang=&quot;EN&quot;&gt;
&lt;head&gt;
&lt;title&gt;Test Page&lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;
charset=iso-8859-1&quot; /&gt;

&lt;style type=&quot;text/css&quot;&gt;
body
{
  text-align: center; /* to support older IE browsers */
  font: 100% calibri, verdana, sans-serif;
  margin: 0px; /* zero out margin and padding for best browser
compatibility */
  padding: 0px;
}
div#wrapper
{
  text-align: left; /* overrides the centering in the body rule */
  margin: 0px auto; /* centers the content on the browser window */
  width: 800px;
  background-color: #cddaff;
}
div#header
{
  text-align: center;
  background-color: #b2fadb;
}
table#buttons
{
  border-spacing: 25px 0px;
  margin: 0px auto;
  padding-bottom: 10px;
}
table#buttons td
{
  border: 1px solid #769185;
  margin: 0px 20px;
  width: 200px;
  height: 50px;
}
div#footer
{
  text-align: center;
  font-size: 70%;
  background-color: #b6c9ff;	
}
div.contentPage
{
  width: 700px;
  margin: 0px auto;
  border: dashed 1px #769185;
  padding: 10px;
  font-size: 120%;
}
h2, p
{
  margin-top: 0px;
  padding: 3px;
}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;wrapper&quot;&gt;
  &lt;div id=&quot;header&quot;&gt;
    &lt;h1&gt;Click a button to see each page&lt;/h1&gt;
    &lt;table id=&quot;buttons&quot;&gt;
      &lt;tr&gt;
        &lt;td&gt;Home&lt;/td&gt;
        &lt;td&gt;Contact&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/div&gt; &lt;!-- /header --&gt;
  &lt;div id=&quot;contentHome&quot; class=&quot;contentPage&quot;&gt;
  &lt;h2&gt;Welcome to Gary&#039;s tent shoppe&lt;/h2&gt;
    &lt;p&gt;Hi, my name is Gary Gertmertin, and I love to sell tents. Ever since I was a wee lad, tents were beautiful pieces of human innovation to me. Over the years, I&#039;ve slept in at least fifteen tents. Don&#039;t get me wrong, I hate camping, I just love tents.
    &lt;/p&gt;
    &lt;p&gt;We sell all kinds of tents. There are doggy tents and tent mansions, complete with a swimming pool. If you want to know what types of tents we sell, then go to the contact information tab on this site, and shoot me an e-mail. We don&#039;t give out pictures, so don&#039;t bother asking.
    &lt;/p&gt;
  &lt;/div&gt;
  &lt;div id=&quot;contentContact&quot; class=&quot;contentPage&quot;&gt;
    &lt;h2&gt;How to contact Gary&lt;/h2&gt;
    &lt;p&gt;I refuse to use telephone technology. So don&#039;t ask for any telephone numbers.&lt;/p&gt;
    &lt;address&gt;
      Gary Gertmertin&lt;br /&gt;
      e-mail: gertymerty@example.com
    &lt;/address&gt;
  &lt;/div&gt;
  &lt;div id=&quot;footer&quot;&gt;
    &lt;p&gt;copyright 2011&lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>From here on out, only add code that is bold and italicized.<br />
Don&#8217;t worry if you don&#8217;t understand what all the CSS is doing; for this tutorial, what&#8217;s important to be aware of here is that there are multiple divisions (as coded with div elements, and in this example there are only two) that are intended to represent different sub-pages of this xhtml document, namely, a div element uniquely identified (with the id attribute) as &#8220;contentHome&#8221; and another with the id value &#8220;contentPage.&#8221;<br />
Important: elements that you intend to control individually with javascript have to be referred to by the id attribute of the element, because unlike the class attribute, the id uniquely identifies the element and thus prevents ambiguity in the reference.<br />
Go ahead and view the newly created page in a browser. You should see that both the home page and the contact page (the dashed line boxes in the periwinkle content area) are visible, stacked on top of each other. If there were more sub-pages, then there would be even more boxes here. There is a small bit of xhtml and css groundwork that we need to take care of before getting to the javascript. First, we&#8217;re going to prepare the &#8220;buttons.&#8221;<br />
We want the user to be able to click on the &#8220;Home&#8221; and &#8220;Contact&#8221; &#8220;buttons&#8221; in the header section of the page to access the different sub-pages. Normally we would opt for anchor elements, but since we&#8217;re not actually leaving this page, we can just make the table data element behavior resemble anchor elements using css.<br />
First, add the following declaration to the &#8220;table#buttons td&#8221; style rule in the embedded stylesheet:</p>
<pre><code> 
table#buttons td 
{
  border: 1px solid #769185; 
  margin: 0px 20px; 
  width: 200px; 
  height: 50px; 
  <strong><em>cursor: pointer;</em></strong>
} 
</code></pre>
<p>Note: the &#8220;pointer&#8221; value does not work on IE4-5.5. Add &#8220;pointer: hand;&#8221; as well to accomodate those browsers.<br />
Now, when the cursor moves over those table data elements, it becomes the hand which signifies a clickable area. We can improve this further by giving an even more pronounced visual cue. Anchor elements aren&#8217;t the only elements that the hover pseudo-selector works for. Let&#8217;s create some style for when the user hovers over a button. Type in the following style rule:</p>
<pre><code> 
<strong><em>
td:hover 
{ 
  background-color: #a1e2c6;
} 
</em></strong> 
</code></pre>
<p>You can add additional properties as you like to truly have a customized appearance. The user should now be given adequate visual cues that these table data elements are dynamic.<br />
We&#8217;re almost ready to start writing some javascript to get the desired functionality to work. As it stands, all the sub-pages are visible onto the content pane when the webpage is accessed. We only want a sub-page to be visible if the corresponding button is clicked. Let&#8217;s use CSS to start hiding all the sub-pages by default.<br />
To do this, add the following declaration to the &#8220;div.contentPage&#8221; style rule:</p>
<pre><code> 
div.contentPage 
{ 
  width: 700px; 
  margin: 0px auto; 
  border: dashed 1px #769185; 
  padding: 10px; 
  font-size: 120%; 
  <strong><em>visibility: hidden;</em></strong> 
} 
</code></pre>
<p>If you refresh your page in the browser window, you&#8217;ll notice that while the sub-pages have been successfully hidden, they still take up the space in the content pane they did while they were visible. This will become especially problematic as the sub-pages become longer, or more sub-pages are added. To fix this problem, we have to separate the sub-pages from the standard document flow.<br />
To remove an element from the document flow, we can change its position property using css. Add the following declaration to the &#8220;div.contentPage&#8221; style rule:</p>
<pre><code> 
div.contentPage 
{ 
  width: 700px; 
  margin: 0px auto; 
  border: dashed 1px #769185; 
  padding: 10px; 
  font-size: 120%; 
  visibility: hidden; 
  <strong><em>position: absolute;</em></strong> 
} 
</code></pre>
<p>When you refresh the browser, the page should look as if it has no sub-pages. Now that these sub-pages are hidden away, we need to be able to get them back on command by clicking the buttons. This is where the javascript comes in. Are you ready?<br />
Javascript is a fairly advanced topic, and this tutorial isn&#8217;t designed to lay down foundational knowledge for it. Rather, you should be able to learn just enough javascript to be able to integrate this functionality in your own site, and tweak it to your liking.<br />
Add the following attribute to each opening td tag:<br />
<code><br />
&lt;td <strong><em>onmouseup=""</em></strong>&gt;Home&lt;/td&gt;<br />
&lt;td <strong><em>onmouseup=""</em></strong>&gt;Contact&lt;/td&gt;<br />
</code><br />
onmouseup is an example of an event attribute. It will allow us to call javascript code when the user lets go of the left-click button on his or her mouse while the cursor is over a button. Other examples of event attributes are onclick, onmouseover, and onmouseout just to name a few. Clever use of these events will allow you to create a creative and dynamic website.<br />
Write the following code as the value for the onmouseup attribute for the first td element:<br />
<code><br />
&lt;td onmouseup="<strong><em>showHide('contentHome','contentContact');</em></strong>"&gt;Home&lt;/td&gt;<br />
</code><br />
and the following for the second td element:<br />
<code><br />
&lt;td onmouseup="<strong><em>showHide('contentContact','contentHome');</em></strong>"&gt;Home&lt;/td&gt;<br />
</code><br />
Now, this shouldn&#8217;t really make any sense yet. Just recognize a couple facts here: showHide is the name of a function, and we are calling it here while passing in two, what are called, arguments&#8211; the strings &#8220;contentHome&#8221; and &#8220;contentContact,&#8221; which just so happen to be the names given to the buttons by their id attributes.<br />
The showHide function works by passing in the element (by its id attibute value) you want to make un-invisible as the first argument, and whatever elements you want to hide or remain hidden are however many final arguments you want to pass, whether it&#8217;s the second argument, or third or fourth and so on. So in this case, when the user clicks the Home button, the contentHome div element becomes visible, and the contentContact becomes hidden or remains hidden, and vice versa for clicking the Contact button.<br />
There&#8217;s only one problem though, and that is that the showHide javascript function does not exist yet. We have to write it, and that is just what we are going to do next. First, we are going to create an embedded javascript document within the head element of this page.<br />
Scroll up to your head element where your embedded stylesheet exists. Add an opening and closing &#8220;script&#8221; tag pair somewhere directly within the scope of the head element.</p>
<pre><code> 
<strong><em>&lt;script type="text/javascript"&gt; &lt;/script&gt;</em></strong>
</code></pre>
<p>Start off by writing the following code within the script element:<br />
<code><br />
<strong><em>function showHide()<br />
{</p>
<p>}<br />
</em></strong></code><br />
The function keyword allows you to create a new function. We&#8217;ve named this function &#8220;showHide.&#8221; Everything between the curly brace pair will be executed when this function is called. Just assume that the parenthesis pair after &#8220;showHide&#8221; are required boilerplate code to get the function to work.<br />
Inside of the curly braces type the following code:</p>
<pre><code>
function showHide() 
{ 
  <strong><em>var d = document;</em></strong> 
} 
</code></pre>
<p>We&#8217;ve now created a shorter name for document. Whenever we have to write &#8220;document,&#8221; we can simply write &#8220;d&#8221; instead. Each statement in javascript must be ended with a semicolon. Now, type the next line of code:<br />
<code><br />
var d = document;<br />
<strong><em>var args = showHide.arguments;</em></strong><br />
</code><br />
Like the previous line of code, we&#8217;ve assigned a shorter name for a longer sequence of characters to not only make typing more efficient, but more meaningful as well. By typing &#8220;showHide.arguments&#8221; we are accessing the list of arguments passed into the showHide function. The new variable &#8220;args&#8221; will now represent that list. We will now grab the first item from the list. Type the following line of code:<br />
<code><br />
var d = document;<br />
var args = showHide.arguments;<br />
<strong><em>var idName = args[0];</em></strong><br />
</code><br />
We&#8217;ve successfully grabbed the first item of the list (item 0), and stored it in the variable &#8220;idName.&#8221; This is the name of the of element we wish to &#8220;show,&#8221; but not the element itself. We have to first retrieve the element, by writing the following line of code:<br />
<code><br />
var d = document;<br />
var args = showHide.arguments;<br />
var idName = args[0];<br />
<strong><em>var elementToShow = d.getElementById(idName);</em></strong><br />
</code><br />
We are passing our idName string into the getElementById function to grab the actual element we want to make visible, and we are storing it within the new variable we have named &#8220;elementToShow.&#8221;<br />
Now that we have the element we&#8217;re looking for, to make it visibile, type the following code on a new line:<br />
<code><br />
var d = document;<br />
var args = showHide.arguments;<br />
var idName = args[0];<br />
var elementToShow = d.getElementById(idName);<br />
<strong><em>elementToShow.style.visibility = 'visible';</em></strong><br />
</code><br />
At this point, the buttons should be able to make their respective sub-pages visible, but we have a couple problems. First, the sub-page made visibile will still be outside the document flow, which won&#8217;t work for this webpage design (the footer needs to be able to be pushed down). Second, we have no way of hiding any other sub-pages that might already be visible. Let&#8217;s address these problems now.<br />
Type in the following code next:<br />
<code><br />
var d = document;<br />
var args = showHide.arguments;<br />
var idName = args[0];<br />
var elementToShow = d.getElementById(idName);<br />
elementToShow.style.visibility = 'visible';<br />
<strong><em>elementToShow.style.position = 'static';</em></strong><br />
</code><br />
The default css position property value is &#8220;static,&#8221; so this should now pop the sub-page back into the document flow. Excellent, the &#8220;show&#8221; part of the showHide function is now complete. It is now time for the &#8220;hide&#8221; part.<br />
We will first start by declaring a new variable we plan to store the element we want to hide:<br />
<code><br />
var d = document;<br />
var args = showHide.arguments;<br />
var idName = args[0];<br />
var elementToShow = d.getElementById(idName);<br />
elementToShow.style.visibility = 'visible';<br />
elementToShow.style.position = 'static';</p>
<p><strong><em>var elementToHide;</em></strong><br />
</code><br />
This part is a little trickier. For this specific webpage, since there are only two sub-pages, we could just do something very similar to what we did to show the elementToShow, but that would limit this function for webpages with only two sub-pages. We need to make this function more scalable, so as to allow any number of these sub-pages.<br />
We will achieve this with a loop. For each iteration of the loop, we will hide the next argument in the list of arguments until the list is finished. To create this loop, write the following code:<br />
<code><br />
var elementToHide;<br />
<strong><em><br />
for (var i = 1; i &lt; args.length; ++i)<br />
{</p>
<p>}<br />
</em></strong></code><br />
Without having explained the logic and syntax behind this code, the important thing to understand is that with this code, starting from the second argument, everything between those curly braces will be executed exactly as many times as there exist arguments remaining in the args list.<br />
We will add three statements to this loop:</p>
<pre><code> 
var elementToHide; 
for (var i = 1; i &lt; args.length; ++i) 
{ 
  <strong><em>elementToHide = d.getElementById(args[i]);
  elementToHide.style.visibility = 'hidden';
  elementToHide.style.position = 'absolute';</em></strong>
} 
</code></pre>
<p>This should look similar to the code used to show the first argument. This time around, we are grabbing each of the remaining elements from the list, and overwriting the elementToHide variable each iteration with the next element in the list. Each element is set to be hidden again or remain hidden, and escape the document flow.<br />
At this point, if all went well, you should be able to refresh the webpage in the browser window, and the dynamic functionality of the page should be complete.<br />
If you want further practice, then try adding additional sub-pages, and buttons that correspond with them. The real challenge will come when you try to adapt this code to your own project. Hopefully this tutorial will have made the otherwise daunting javascript language manageable enough to create your own show/hide behavior to add to your website.</p>
]]></content:encoded>
			<wfw:commentRss>http://ittrainingtips.iu.edu/cascading-style-sheets/using-javascript-to-create-a-dynamic-tab-based-webpage/09/2011/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
