Adult web hosting - CHAPTER 5 DISPLAYING XML USING CSS 161

CHAPTER 5 DISPLAYING XML USING CSS 161 CSS2 includes the concept of pseudo-elements that allow you to add content when styling XML documents. These elements are :before, which inserts content before an element, and :after, which inserts the content afterward. Using these pseudo-elements, you can add text and images before any element in the source document. You can also use two additional pseudo-elements to add different effects to the first line or first letter of some text. These are :first-line, which adds special styles to the first line of the text in a selector, and :first-letter, which does the same to the first letter of the selector. The syntax for all pseudo-elements is selector:psuedo-element {property: value;} Let s work through an example to see how these pseudo-elements might apply. The XML document, addedContent.xml, includes four paragraphs containing text. The elements are imaginatively called
,
,
, and
:
This content is within paragraph 1 This content is within paragraph 2 This content is within paragraph 3 This content is within paragraph 4
In this example, the stylesheet associates different pseudo-elements with each paragraph. The CSS required to style the first paragraph follows: paragraph1:first-letter { float:left; font-size:24pt; font-style:italic; font-weight:bold; padding-right:4px; } Unfortunately, none of the major browsers support the first-letter pseudo-selector, so the page doesn t display properly. The style declaration for the second paragraph uses the following to display the entire line in uppercase: paragraph2:first-line { text-transform:uppercase; font-weight:bold; } Again, none of the major browsers support this pseudo-selector. In the third paragraph, the stylesheet inserts some text before the paragraph. The text to be added is placed in quotes as the value of the content property. This time, the example works in Netscape, Firefox, and Opera:
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Leave a Reply