This tutorial introduced you to CSS and how it is used to style XML documents. You got started by learning the basics of CSS, including the fundamental layout and formatting styles that are used to style XML content. You then learned how to associate an external style sheet with an XML document, which is a necessity if you plan on seeing the fruits of your CSS labors. You also found out the difference between relative and absolute positioning and how each are used to position elements. You learned about several other CSS positioning features such as z-index, margins, padding, content alignment, fonts, colors, backgrounds, and text spacing. And finally, you wrapped up the tutorial by exploring a complete CSS example that pulled together most of what you learned throughout the lesson.
Q&A
Q. |
Why can't I just place style rules directly in XML code? |
A. |
XML code must adhere to XML syntax, which consists of elements and attributes. CSS is not an XML-based markup language, which immediately excludes its usage within XML documents using familiar XML elements and attributes. Technically, it could be possible to use inline CSS styles with XML content by way of a special attribute, such as |
Q. |
How do you know when to use relative versus absolute positioning? |
A. |
Although there are no set guidelines regarding the usage of relative versus absolute positioning, the general idea is that absolute positioning is required only when you want to exert a fine degree of control over how content is positioned. This has to do with the fact that absolute positioning allows you to position content down to the exact pixel, whereas relative positioning is less exacting in terms of how it positions content. This isn't to say that relative positioning can't do a good job of positioning XML content; it just means that absolute positioning is more explicit. |
Q. |
If you don't specify the z-index of two elements that overlap each other, how do you know which element will appear on top? |
A. |
If the |
Q. |
Is there a way to know if a font is installed on a system when specifying it in a style sheet? |
A. |
No. Different users may have different fonts installed, and there is no way to predict which fonts will be available. The best solution to this problem is to use popular fonts or system fonts and always provide a secondary font that is ideally a system font. |