tags:

views:

168

answers:

2

Please, have a look at the html below. The first sentence is enclosed by a span tag with the class "highlight".

<p><span class="highlight">The Document Object Model (DOM) is a programming interface for HTML and XML documents.</span> It provides a structured representation of the document and it defines a way that the structure can be accessed from programs so that they can change the document structure, style and content. The DOM <strong>provides a representation of the document as a structured group of nodes and objects that have properties and methods.</strong> Essentially, it <span class="blue">connects web pages to scripts or programming languages</span>.</p>

I want to style this, so that only the text of the first sentence appears on the document. All the other sentences, should disappear. I guess it should have something to do with the css attribute display:none;, but I am not sure how to achieve this?

+1  A: 
Pointy
cheers! almost what I'm looking for. That's a big help. Ideally though, I would like to have the space taken up by the none-highlighted text to collapse. I was thinking:p { display: none; }p span.cover { display: inline !important; }but this just removes all paragraph text, including the span content.
Well to do that, you might want to use Javascript to yank the whole `<span>` up out of the paragraph so that it can be displayed separately.
Pointy
A: 

Change your HTML so that instead of having <span class="highlight"> you have a <span class="hide"> on the rest of the paragraph. Then just span.hide { display: none; } in the css.

Finbarr
see what you're saying, but not really what I want. I'm using it for a notetaking app, so what I want to be able to do is simply highlight key points in the content and collapse the other content at will. It would be treble the work for the user to have to highlight the inverse of the key points as you are suggesting. (would involve alot of scrolling). Thanks though.