Javascript - show and hide text blocks

You can easily show and hide text blocks in a html file when you place this script in the head-section of your html file (between <head> and </head>).

<script type="text/javascript">
document.write("<style type='text/css'>.hidden{display:none}<\/style>") //hide all texts, except when javascript is off.
function show(area){
	var obj = document.getElementById(area)
	obj.style.display=(obj.style.display=='block')?'none':'block'
}
</script>
When javascript has been enabled, the class 'hidden' will be set not to display the text.
Some people don't want to use javascript: when disabled all hidden texts will nicely be expanded.

This is how it looks between the body-tags (between <body> and </body>):

There is some text which is hidden. <a href="javascript:show('test');">show/hide</a> 
<div class="hidden" id="test">Yes, this was hidden.<br>bladiebla bladiebladiebla was also hidden.</div>
<div>The quick brown fox jumps over the lazy dog. <a href="javascript:show('hiddentext1');">+/-</a></div>
<p class="hidden" id="hiddentext1">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has 
been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled 
it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, 
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum 
passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
This is just normal text ... bla bla<br>
This is just normal text ... bla bla
<div>This is a story about an imaginary house. Do you want to know more about it? <a href="javascript:show('hiddentext2');">more/less</a></div>
<div class="hidden" id="hiddentext2">Sorry, the house was never built...</div>
All the text blocks can be hidden and unhidden individually when you give each block its own id.

This is the result, just test it yourself:

There is some text which is hidden. show/hide
The quick brown fox jumps over the lazy dog. +/-
This is just normal text ... bla bla
This is just normal text ... bla bla
This is a story about an imaginary house. Do you want to know more about it? more/less


--------------------------------------------------------------------------------------------------------------------------
If you want the 'hidden' text to continue on the same line as the visible text then use 'display:inline' instead of 'display:block'.
Just replace the word 'block' by 'inline' in the javascript function show(area).
See my homepage as an example where I have used 'display:inline'.