Click to show more - JS perhaps?
Basically, you will need to manage the display
CSS property of the element that should be hidden / revealed:
<span id="showHide">Show</span>
<div id="foo" style="display:none">Here is some text</div>
<script>
document.getElementById("showHide").onclick = function() {
var theDiv = document.getElementById("foo");
if(theDiv.style.display == 'none') {
theDiv.style.display = 'block';
this.innerHTML = 'Hide';
} else {
theDiv.style.display = 'none';
this.innerHTML = 'Show';
}
}
</script>
a source to share
Executive summary : use a plugin framework
Long version :
You can use javascript - rather, in conjunction with a javascript framework like jQuery. This includes adding a click handler to a word (actually a span tag around it) and the ability to extract additional information to show as a tooltip - there are many plugins for that. Search for "jquery hint" here or using google: here's one example .
Alternatively, you can simply surround the word with a span tag and add a title attribute to the tag. Hovering over a word (actually a tag) will bring up the browser's default tooltip. This might be an easy way to get started with it - it might actually be the start of a javascript solution. Using a tag for the click event and grabbing data from the title attribute - perhaps by storing the title in jQuery data on page load, then grabbing the text from the data on click so you don't have a conflict with the browser tool tip behavior. Many of the plugins work this way.
a source to share
A quick idea of how to do this while avoiding the JS solution. I'm using jQuery here because it's quicker to embed, but as I mentioned above, if that's your only JS functionality, it will only add a cumbersome file for some trivial additions.
<script type="text/javascript">
jQuery(function() {
$(".article .additional")
.hide()
.before("<a href='#'>")
.prev()
.text("more")
.click(function() {
$(this).next().toggle()
})
});
</script>
<div class="article">
<h2>Some headline</h2>
<p>Some intro text that is always visible</p>
<div class="additional">
<p>Some extra text that is hidden by JS</p>
<p>But will stay visible if the visitor doesn't have JS</p>
</div>
</div>
As you can see, HTML is completely self-contained. Only if JavaScript is supported is the "more" link added and the additional content hidden so that non-JS users can still read the entire text and not have any unnecessary "more" link.
a source to share
Another elegant approach using pure HTML and CSS without JavaScript.
HTML:
here goes text before
<label class="details">
<input type="checkbox" /><span>here come some details</span><em> </em>
</label>
and after
CSS
.details input,
.details span {
display: none;
}
.details input:checked~span {
display: inline;
border-bottom: dotted 1px gray;
}
.details em:after {
content: "show...";
}
.details input:checked~em:after {
content: "...hide";
}
a source to share