(Paper) Web Services Interview Question (Paper - 10)
Paper : Web Services Interview Question (Paper - 10)
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.
What is the percentage value in 'font-size' relative to?
It is relative to the parent element's font-size.
For example, if the style sheet says:
H1 {font-size: 20pt;}
SUP {font-size: 80%;}
...then a <SUP> inside an <H1> will have a font-size of 80% times
20pt, or 16pt.
What is wrong with font-family: "Verdana, Arial, Helvetica"?
The quotes. This is actually a list with a single
item containing the well-known 'Verdana, Arial, Helvetica' font family. It is
probably intended to be a list of three items.
Unlike in most other CSS1 properties, values for the font-family are separated
by a comma to indicate that they are alternatives. Font names containing
whitespace should be quoted. If quoting is omitted, any whitespace characters
before and after the font name are ignored and any sequence of whitespace
characters inside the font name is converted to a single space.
So to ask for two fonts foo and bar the syntax is:
font-family: foo, bar
To ask for the two fonts Revival 555 and Iodine you can do this:
font-family: "Revival 555", Iodine
You could also do this:
font-family: Revival 555, Iodine
which is equivalent. Notice that this is not three fonts; you can tell because
after the "l" you didn't hit a comma, (more list items to come) a
semicolon (end of that property, another property coming up) or a curly brace
(end of that rule). This is also equivalent:
font-family: Revival 555, Iodine
^^^^^^ whole bunch of spaces converts to one space
But this next one is asking for a different font with two spaces in the name
font-family: "Revival 555", Iodine
^^two spaces, which are not converted
In general it is more tolerant of user typing to leave out the quotes.
Sometimes you need them, for example there is a real font sold by Fontworks
and designed in 1995 by Stephan Müller called Friday, Saturday, Sunday.
Yes, two commas in the actual font name. CSS1 can handle this:
font-family: "Friday, Saturday, Sunday", cursive
Because it can handle this, the example in the title is syntactically correct.
But what the author or tool wrote was almost certainly not what the document
author intended.
How do I centre my page?
This is very easy. If we take the code in the
last question and change it to 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%;
}
you get a page that fits an 800x600 resolution screen without a horizontal
scrollbar, which will be centered at higher resolutions.

Daily JOBS






Get Your Dream Job! Post Your Resume Today!
Get Your Dream Job! Post Your Resume Today!