View Full Version : when and where to use these in css?
05-12-2009, 02:06 PM
1) when do we use line-height and height? (In menus (ul,li) do we use height or line-height?)
2) when do we use % and pixel?
3) when do we use
position:absolute? are they supportive for IE?
4) when do we use float and clear function?
5) Using use tables when div's are not aligned properly is right method?
These all problems I face in my current project, Please clarify me with this so that its very helpful to align my work..
05-12-2009, 02:28 PM
The line-height property is for the height of a line (how ironic), usually this applies to text. The lines of the text will be spaced out vertically if you increase the line height (i. e. the lines become higher) while the height property specifies the height of an element (it’s a difference if you increase the height of the lines in a paragraph or the height of the paragraph itself).
For lists I would suggest using height, perhaps together with some top and bottom padding for the list items (or perhaps scrap the fixed height and just apply some top and bottom padding). Line height can be useful as well but might become problematic with cross browser compatibility or if the text in the list items wraps.
If you use percents or pixels as values is completely your choice. If you want a liquid layout (adapting to the size of the viewport) or a layout that keeps the dimensions relative to the size of the viewport you should use relative units such as percent, em, or ex. If your layout is static you should use absolute units such as px (pixels), cm (centimeters), in (inch), mm (millimeters), pt (points), or pc (picas). These latter ones are probably more useful for print layouts so the px unit would be the most appropriate for screen layouts. Also refer to http://www.w3schools.com/css/css_units.asp Note that you can mix any of the units. For example you can specify your general page width in pixels and then specify widths of child elements in percents which relate to the width of the parent.
I don’t have the time to explain the other stuff right now as it’s a little more involved.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.