techpreparation-homepage

Home  Interview Questions  Certifications  Aptitude Questions  Tutorials  Placement Papers  Search  Resume  Soft Skills  Video  Forum  Blog

Android app on Google Play

Technical Interview Questions
JavaScript Interview Question
XHtml Interview Questions
Ajax Interview Questions
XML Interview Questions
VB Interview Questions
                              .........More

Source Codes
Flash Source Codes
Html Source Codes
CSS Source Codes
                              .........More

Soft Skills
Communication Skills
Leadership Skills
                              .........More

 

 

  

CSS Interview Questions and Answers



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 <span> tag instead the
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 <div>. If you play around with it a bit then you have a good chance to achieve what you want and still have correct HTML/CSS.

The other way would be that you apply the class .tblboda directly to the table (for IE and other contemporary browsers), like <table ... class="tableboda"> and you define another class for each stylesheet: .tblboda2

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 <div> with the class .tblboda2 (NN4.xx does that) (IE a.o.c.b. don't do anything, because the border-style is set to "none" = no border at all).

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...

#nav {
position:fixed;
}
* html #nav { /* this will target IE */
position:absolute;
}

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.
<!--[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 */
}

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}
All text will be displayed in a 10 point font

BODY {font-size: 10pt}
H1 {font-size: 14pt} or H1 {font-size: 180%}

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}
H1 {font-size: 14pt} or H1 {font-size: 180%}
EM {font-size: 15pt} or EM {font-size: 110%}

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.

Page Numbers :   1       2       3       4       5       6       7       8       9       10      11      12      13      14      15      16      17

 

Have a Question ? post your questions here. It will be answered as soon as possible.

Check Html Interview Questions for more Html Interview Questions with answers