css interview questions(101-110)
How do I get my footer to sit at the bottom…?
Need a div which makes space at the bottom of the main page (inside the #wrap div). Then, the footer (being inside #wrap) can be placed in that space by using absolute positioning. Like this :
CSS body, html { height:100%; } body { margin:0; padding:0; } #wrap { position:relative; width:780px; margin:auto; min-height:100%; } * html #wrap { height:100%; } # clearfooter { height:50px; overflow:hidden; } #footer { position:absolute; bottom:0; width:100%; height:50px; } HTML <div id="wrap"> ...content goes here... <div id="clearfooter"></div> <div id="footer">Footer</div> </div>
Can I attach more than one declaration to a selector?
Yes. If more than one declaration is attached to a selector they must appear in a semi colon separated list, e.g.;
Selector {declaration1; declaration2} P {background: white; color: black}
Border around a table?
Try the following:
.tblboda { border-width: 1px; border-style: solid; border-color: #CCCCCC; } /*color, thickness and style can be altered*/
You put this style declaration either in
an external stylesheet, or you can stuff it in
the
<head></head> section, like: <style type="text/css"> (here you can place your styles) </style> and apply it to the table as follows: <div class="tblboda"> <table yaddayadda> <tr> <td>Content text and more content</td> </tr> </table> </div>
That should give you a grey thin border around this table.
If you want the border to ’shrink wrap’ around the table, then you have to use the tag instead the The other way would be that you apply the class .tblboda directly to the table (for IE and other contemporary browsers), like In the NN4.xx stylesheet, you use the same properties as above, and in the IE and other contemporary browsers you carefully set all those properties to default, like {border-style: none;} Then you wrap the table in the
This way you have a table that is wrapped in a nice little border: .tblboda2 for NN4.xx, .tblboda for IE and other modern browsers. How do you target a certain browser? IE can be targetted by preceding your properties with ‘* html’. For example… Another way to target IE is with conditional comments. Put this (below) in the head - just before the closing tag - and put anything you want to be directed only at IE in another stylesheet. How does inheritance work? HTML documents are structured hierarchically. There is an ancestor, the top level element, the HTML element, from which all other elements (children) are descended. As in any other family also children of the HTML family can inherit their parents, e.g. color or size. By letting the children inherit their parents a default style can be created for top level elements and their children. (Note: not all properties can be inherited). The inheritance starts at the oldest ancestor and is passed on to its children and then their children and the children’s children and so on. Inherited style can be overridden by declaring specific style to child element. For example if the EM element is not to inherit its parent P then own style must be declared to it. For example: BODY {font-size: 10pt} BODY {font-size: 10pt} All text except for the level 1 headings will be displayed in a 10 point font. H1 will be displayed in a 14 point font (or in a font that is 80% larger than the one set to BODY). If the element H1 contains other elements, e.g. EM then the EM element will also be displayed in a 14 point font (or 180%) it will inherit the property of the parent H1. If the EM element is to be displayed in some other font then own font properties must be declared to it, e.g.: BODY {font-size: 10pt} The EM element will be displayed in a 15 point font or will be 10% larger than H1. NOTE: EM is, in this example, inside H1 therefore will inherit H1’s properties and not Body’s. The above declaration will display all EM elements in 15 point font or font that is 10% larger than font declared to the parent element. If this specific font is to apply to EM elements but only if they are inside H1 and not every occurrence of EM then EM must take a form of a contextual selector. H1 EM {font-size: 15pt} or H1 EM {font-size: 110%} In the example above EM is a contextual selector. It will be displayed in specified font only if it will be found in the context of H1. Not all properties are inherited. One such property is background. However, since it’s initial value is transparent the background of the parent element will shine through by default unless it is explicitly set.
tag. But that is not quite proper CSS or HTML, because a is for inline elements. A table is not an inline element, therefore the correct tag is a
and you define another class for each stylesheet: .tblboda2
#nav {
position:fixed;
}
* html #nav { /* this will target IE */
position:absolute;
}
<!--[if IE]>
<link href="ieonly.css" rel="stylesheet" type="text/css">
<![endif]-->
If you need to target IE5x...
#wrap {
width:760px; /* for IE5x */
w\idth:780px; /* for all other major browsers */
}
All text will be displayed in a 10 point font
H1 {font-size: 14pt} or H1 {font-size: 180%}
H1 {font-size: 14pt} or H1 {font-size: 180%}
EM {font-size: 15pt} or EM {font-size: 110%}




Leave a Reply
You must be logged in to post a comment.