OR
<style type="text/css">
Body {
stress: inherit;
}
</style>
--
John Malone
==============
| Yep yep yep yep BrrrrrrrrrrrRing 8)
| --
| John Malone
| ==============
| || It's what drives web developers to drink.
||
|| --
|| Murray
|| --------------
|| MVP FrontPage
||
||
|| || > Picture here..
|| >
http://www.xmas-i-am.com/elements.htm
|| >
|| > How do you calculate that?
|| >
|| > --
|| > John Malone
|| > ==============
|| > || > | Take a look at this... First in IE and then FF
|| > | Test1 has a Doc type (valid)
|| > |
http://www.xmas-i-am.com/test1.htm
|| > | Test 2 has none (Quirks mode)
|| > |
http://www.xmas-i-am.com/test2.htm
|| > |
|| > | 4 Views and none are the same...
|| > |
|| > | You will find that if you compute to the px it won't always work.
|| > | more factors enter the picture... Doc Type! and more later..
|| > |
|| > | --
|| > | John Malone
|| > | ==============
|| > | || > || What I found, as I mentioned earlier, is that FF and IE handle the
| code
|| > || differently (p.s. I misspoke when I said your code wasn't compliant;
|| > its
|| > | one
|| > || of the browsers).
|| > ||
|| > || I think it is as straight forward as 1+1=2 (in the example being
used
|| > | here)
|| > || once you find a browser that follows the recommendation. In fact,
| the
|| > | irony
|| > || is that the specification actually uses a math equation for this.
|| > ||
|| > || This is the key section from the specification:
|| > ||
|| > ||
|| > || 10.3.3 Block-level, non-replaced elements in normal flow
|| > ||
|| > || If 'left' or 'right' are given as 'auto', their computed value is 0.
|| > The
|| > || following constraints must hold between the other properties:
|| > ||
|| > || 'margin-left' + 'border-left-width' + 'padding-left' + 'width' +
|| > || 'padding-right' + 'border-right-width' + 'margin-right' = width of
|| > | containing
|| > || block
|| > ||
|| > || (If the border style is 'none', use '0' as the border width.) If all
| of
|| > | the
|| > || above have a specified value other than 'auto', the values are said
| to
|| > be
|| > || "over-constrained" and one of the computed values will have to be
|| > | different
|| > || from its specified value. If the 'direction' property has the value
|| > 'ltr',
|| > || the specified value of 'margin-right' is ignored and the value is
|| > computed
|| > | so
|| > || as to make the equality true. If the value of 'direction' is 'ltr',
|| > this
|| > || happens to 'margin-left' instead.
|| > ||
|| > || If there is exactly one value specified as 'auto', its computed
value
|| > || follows from the equality.
|| > ||
|| > || If 'width' is set to 'auto', any other 'auto' values become '0' and
|| > | 'width'
|| > || follows from the resulting equality.
|| > ||
|| > || If both 'margin-left' and 'margin-right' are 'auto', their computed
|| > values
|| > || are equal.
|| > ||
|| > || What seems to be important is the equation and the implication that
|| > things
|| > || will be unpredictable if the equation is "over-constrained" and/or
is
|| > out
|| > | of
|| > || balance.
|| > ||
|| > || So maybe what I've learned is this: The overall block width, which
is
|| > the
|| > || sum of the left and right margins, borders, and paddings along with
| the
|| > || content width, MUST equal the width of the ancestor block content
| area.
|| > | If
|| > || possible, certain properties will be adjusted to make the equation
|| > true.
|| > | My
|| > || assumption is, that if the equation cannot be made to be true, the
|| > results
|| > || will be unpredictable.
|| > ||
|| > || BTW: there appears to be a typo in the specification. One of the
|| > "ltr"s
|| > || needs to be a "rtl".
|| > ||
|| > || Tom
|| > ||
|| > || "John Malone" wrote:
|| > ||
|| > || > For FF you would need to take out the underscore (in the CSS) and
| put
|| > || > content in the container to see it.
|| > || >
|| > || > Here it is and I think you will find something you might not have
|| > | expected.
|| > || > 8)
|| > || >
|| > || > head part...
|| > || > ==================
|| > || > <style type="text/css">
|| > || > body {
|| > || > margin: 0;
|| > || > padding: 0;
|| > || > }
|| > || > #container1 {
|| > || > padding: 0px;
|| > || > width: 100px;
|| > || > color: black;
|| > || > background-color: red;
|| > || > }
|| > || > #container2 {
|| > || > margin:0;
|| > || > Border: 0px black;
|| > || > padding: 0px;
|| > || > width: 100px;
|| > || > color: black;
|| > || > background-color: blue;
|| > || > }
|| > || > </style>
|| > || > ========================
|| > || > Body stuff
|| > || > NOTE: I added content The letter A
|| > || > and the letter B
|| > || > ======================
|| > || > <div id="container1"><p>A</p>
|| > || > <div id="container2"><p>B</p>
|| > || > </div>
|| > || > </div>
|| > || > ======================
|| > || > If you have tried this you can see why the answers are not as easy
| as
|| > | 1+1=2
|| > || >
|| > || > HTH
|| > || > --
|| > || > John Malone
|| > || > ==============
|| > || > || > || > | 8) I was going to answer all the questions BUT...
|| > || > | That might not be much real help...
|| > || > | You have FrontPage so.... make a page.
|| > || > |
|| > || > | Put your CSS in the heading and have at it.
|| > || > | It is far better to see it for your self. (at least for me).
|| > || > |
|| > || > | To get you started here is some css...
|| > || > | Put this in the <head> Just before the </head> tag....
|| > || > |
|| > || > | <style type="text/css">
|| > || > | body {
|| > || > | margin: o;
|| > || > | padding: 0;
|| > || > | }
|| > || > | #block_A {
|| > || > | width: 100px;
|| > || > | color: black;
|| > || > | background-color: red;
|| > || > | }
|| > || > | #block_B {
|| > || > | width: 100px;
|| > || > | color: black;
|| > || > | background-color: blue;
|| > || > | }
|| > || > |
|| > || > | #block_AA {
|| > || > | width: 100px;
|| > || > | color: black;
|| > || > | background-color: red;
|| > || > | }
|| > || > | #block_BB {
|| > || > | margin:0px;
|| > || > | Border: 0px black;
|| > || > | padding: 0px;
|| > || > | width: 100px;
|| > || > | color: black;
|| > || > | background-color: blue;
|| > || > | }
|| > || > | </style>
|| > || > | ===========================
|| > || > | NOTE: block_BB is set at "0" Change to suit your wants / needs
|| > || > | The blue block is in the red block
|| > || > | ===========================
|| > || > | Now you can do the HTML like this...
|| > || > |
|| > || > | <div id="block_A">
|| > || > | <div id="block_B">
|| > || > | </div><!-- /B -->
|| > || > | </Div><!-- /A --></td>
|| > || > |
|| > || > | and or
|| > || > |
|| > || > | <div id="block_AA">
|| > || > | <div id="block_BB">
|| > || > | </div><!-- /BB -->
|| > || > | </Div><!-- /AA -->
|| > || > | =======================
|| > || > |
|| > || > | That puts block B (blue) inside A (red)
|| > || > |
|| > || > | Now you can play with it all you want...
|| > || > |
|| > || > | Here is one of the best easy explanations I have read
|| > || > | -----------------------------------
|| > || > | Real basic CSS in FP?
|| > || > |
|| > || > | CSS is based on RULES which contain STYLES, and SELECTORS, e.g.,
|| > || > |
|| > || > | p { color:blue; }
|| > || > |
|| > || > | That whole line is a rule. The color:blue is a style. The "p" is
| a
|| > || > selector.
|| > || > |
|| > || > | Selectors can be of four different kinds -
|| > || > |
|| > || > | 1. a tag name
|| > || > | 2. a custom class
|| > || > | 3. an id selector
|| > || > | 4. a descendent selector
|| > || > |
|| > || > | The example above is using a tag name as a selector - all <p>
| tags
|| > on
|| > | the
|| > || > | page will contain blue text.
|| > || > |
|| > || > | A custom class would look something like this -
|| > || > |
|| > || > | .special { color:green; }
|| > || > |
|| > || > | So, all <p> tags containing that class specification would
| contain
|| > | green
|| > || > | text instead of blue, e.g.,
|| > || > |
|| > || > | <p class="special">this is green</p>
|| > || > |
|| > || > | An id selector would look like this -
|| > || > |
|| > || > | #reallySpecial { color:red; }
|| > || > |
|| > || > | and you can apply it like this -
|| > || > |
|| > || > | <p id="reallySpecial" class="special">this is red</p>
|| > || > |
|| > || > | What you can see from this is that the id selector's rule has
|| > | overridden
|| > || > the
|| > || > | class selector's rule, because the text is red. This illustrates
|| > one
|| > | of
|| > || > the
|| > || > | fundamental differences between id selectors and custom
classes -
|| > the
|| > || > former
|| > || > | have a 'greater specificity' and will 'trump' other rules that
|| > apply
|| > | but
|| > || > | with a lower specificity, like custom classes.
|| > || > |
|| > || > | Finally, a descendent selector will look like this -
|| > || > |
|| > || > | .special span { color:black; }
|| > || > |
|| > || > | It says to make any span tag's contents black when they occur
|| > inside
|| > a
|| > || > | container with a class of 'special', e.g.,
|| > || > |
|| > || > | <p class="special">This text is blue except <span>for this,
which
|| > is
|| > || > | black</span></p>
|| > || > |
|| > || > | The selector specifies the 'descent' of the rule from container
| to
|| > || > content,
|| > || > | i.e., from 'ancestor' to 'child', where, in this case, the <p>
| tag
|| > is
|| > | the
|| > || > | ancestor, and the <span> tag is the child.
|| > || > |
|| > || > | One final thing. ID selectors must be unique, in that only a
| single
|| > || > element
|| > || > | on any given page can possess it, e.g.,
|| > || > |
|| > || > | <p id="reallySpecial">whatever</p>
|| > || > | <p id="reallySpecial">whatever</p>
|| > || > |
|| > || > | is an illegal instance of this, since there are two elements,
| each
|| > of
|| > || > which
|| > || > | has the id="reallySpecial" value.
|| > || > |
|| > || > | A class selector can be used any number of times on a given
page,
|| > | e.g.,
|| > || > |
|| > || > | <p class="special">This text is blue except <span>for this,
which
|| > is
|| > || > | black</span></p>
|| > || > | <p class="special">This text is blue except <span>for this,
which
|| > is
|| > || > | black</span></p>
|| > || > |
|| > || > | would be perfectly valid.
|| > || > |
|| > || > | In the scheme of things, there are rules for calculating the
|| > | specificity
|| > || > of
|| > || > | the styles. Here are some of the rules -
|| > || > |
|| > || > | 1. The style that is closest to the element being styled wins in
|| > the
|| > || > absence
|| > || > | of other mitigating factors. This is why you cannot trump font
| tags
|| > || > with....
|| > || > |
|| > || > | CSS, since the font styles are always closer.
|| > || > | 2. A redefined tag has a specificity value of 1.
|| > || > | 3. A custom class has a specificity of 10.
|| > || > | 4. An id selector has a specificity of 100.
|| > || > |
|| > || > | Thus, in this case, the green color would have a specificity of
1
|| > and
|| > | the
|| > || > | custom class of 10. The class wins.
|| > || > |
|| > || > | h1 { color:green; }
|| > || > | .headline { color:red; }
|| > || > |
|| > || > | <h1 class="headline">This is red</h1>
|| > || > | ============================
|| > || > |
|| > || > | It is nice that you are taking the time to learn some CSS
|| > || > | 8)
|| > || > | Padding is inside the container
|| > || > | Margin is outside
|| > || > |
|| > || > | Hope this helps some
|| > || > | --
|| > || > | John Malone
|| > || > | ==============
|| > || > | || > || > || I've done my homework by reading the spec and searching the
net,
|| > but
|| > | I'm
|| > || > || still confused about the CSS width property as it relates to
the
|| > || > ancestor.
|| > || > ||
|| > || > || Using the example: the nearest ancestor's (A) content area is
|| > 100px.
|| > | The
|| > || > || box inside it (B) has a width of 100% with no other dimension
|| > | properties.
|| > || > | My
|| > || > || assumption is that the content width, the padding boundary
| width,
|| > the
|| > || > | border
|| > || > || boundary width, and the margin boundary width are all 100px.
|| > || > ||
|| > || > || Now, if I add a left or right dimension to the margin, border,
| or
|| > | padding
|| > || > || does the content width of B shrink by the sum of these widths?
| Or
|| > | does
|| > || > | the
|| > || > || content area "push" these dimensions out beyond 100px?
|| > || > ||
|| > || > || Using the same boxes, assume that B has a width property of 90%
|| > and
|| > || > assume
|| > || > || the sum of the widths of the padding, border, and margin are
| 6px.
|| > Is
|| > | the
|| > || > || content width of B 90px or is it actually 94px?
|| > || > ||
|| > || > || Sorry for asking something this basic, but I got confused when
|| > trying
|| > | to
|| > || > || understand it.
|| > || > ||
|| > || > || Thanks
|| > || > ||
|| > || > || Tom
|| > || > ||
|| > || > ||
|| > || > |
|| > || > |
|| > || >
|| > || >
|| > || >
|| > |
|| > |
|| >
|| >
||
||
|
|