Previous Message
Next Message

CSS defaults, kinda strange

Sent by Jukka K. Korpela on 11 August 2004 08:08


On Tue, 10 Aug 2004, Scott Haneda wrote:

> on 8/10/04 11:42 PM, Keith Burgin at [EMAIL-REMOVED] wrote:
- -
> > Rather than try to establish more specific rules for the "outside" HTML,
> > make the specific ID's and classes apply specifically to your HTML and
> > leave theirs unstyled.
> >
> > Just a suggestion.
>
> Nice suggestion.  Though I don't quite know how to do this,

In the simplest case you could put all of your own HTML inside two
<div> elements, with the "outside" stuff between them (optionally inside
<div> - not needed for this purpose but logical anyway), and assign your
styles to those <div> elements rather than to <body>

Something like

<html>
<body class="example">

<div class="my">
(the start of the document)
</div>

<div class="newsletter">
(the injected html code)
</div>

<div class="my">
(the rest of the document)
</div>

</body>
</html>

(I dropped align="left" from your markup, since it's the default anyway.)

And then you would, instead of
  body { ... }
use just
  .my { ... }

> And furthermore, since this is a<body> tag, wont it totally override the
> "newsletter" class anyway?

I'm not sure I see what you mean by the question. Anything you set for
<body> is basically for the <body> element but may get inherited to
subelements and so on, according to certain rules. For example, if you set
font-family for <body>, then any subelement that has no font-family
setting of its own (via any style sheet or via markup) inherits that
font-family. But if the injected code contains e.g. <font face="...">,
then this gets interpreted as corresponding to a font-family setting for
that <font> element. Hence that element has the font family set in the
face="..." markup. Thus, contrary to what people often say, CSS
settings don't always override presentational HTML markup.

(If you wanted to override <font> stuff in injected code, you would use a
selector that matches <font> elements, e.g.
  body, font { font-family: ...; }
but I guess you don't, in this case.)

There's also a different approach to the original problem. Instead of
actually inserting the injected code into an HTML document (statically or
dynamically e.g. via PHP), you could use an <iframe> or <object> element
to "embed" an external HTML document. That would mean that the external
document is presented "autonymously" (with its own style sheet(s) if it so
specifies, or with no style sheet if it does not) in a sub-window like
area inside your document. But in that case you could not add _any_
styling to it without changing the external HTML document or its own style
sheet. (About iframe: http://www.cs.tut.fi/~jkorpela/html/iframe.html )

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: