Web designers gained a great deal from the CSS2 specification, especially when it comes to increased flexibility to position HTML elements exactly where they want them within Web pages. Keep reading to learn more.
Introduction to CSS Positioning Properties Part 1 - The "display" property (Page 6 of 6 )
This property is very handy for redefining the default behavior for inline and block elements, since they can be changed to behave in the opposite way. Let’s say we want a paragraph element, which is, as previously defined, a block-level element, to be displayed as an inline element. We’d write the following line in our CSS declaration:
That’s all we need to do. Now all of the paragraph elements will behave as inline elements. Similarly, we might turn an inline element into a block-level element. This is often useful for displaying <a> elements to emulate a button appearance in a navigation bar, but there are numerous other hacks. Our CSS code would look something like this:
/* link properties */
Another common use is to assign an element the "display: none" property, which stops it from being displayed, and completely removes it from the screen space.
Here are the concerned values for the "display" property. There are a number of other possible values, dealing with list, tables, etc. However, for the scope of the article, we’ll detail the following:
Sets the selected element to be a block level element.
Sets the selected element to be an inline element.
Stops the selected element from being displayed, and doesn’t take up any screen space.
We’re not done yet. There are still more CSS visual properties to be reviewed and useful examples. In the next part of this article, we’ll take a close look at more properties and expose some interesting techniques to manipulate element position in Web documents. Until then, stay tuned.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.