By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,625 Members | 2,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,625 IT Pros & Developers. It's quick & easy.

Using the browser's default style for an element

P: n/a
I'm almost certain there is no easy answer to this question, but I'd
thought I'd just check....

*Ignoring* for a second why I want to do this, is there any way to
specify that an element in a page should ignore all CSS properties
that have been defined for it, and to adopt some form of browser
default?

Suppose I want to add a <tdelement to an *arbitrary* web page. I
want this element to ignore any CSS directives that may already apply
to <tdelements, and to behave as though the original page has no CSS
defined at all.

I'm guessing there is no way to do this, and I must define by hand my
own set of styles that I consider to be "default. e.g.:

<td style="margin: 0; padding: 0; background-color: inherited; ......
">

Any thoughts on this issue??

Apr 16 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Mon, 16 Apr 2007, Duncan Jones wrote:
I'm almost certain there is no easy answer to this question,
Which question?
*Ignoring* for a second why I want to do this,
To do what?
is there any way to
specify that an element in a page should ignore all CSS properties
that have been defined for it, and to adopt some form of browser
default?
Ah! Do you mean something like
http://www.w3.org/TR/REC-CSS2/cascad...ue-def-inherit
?

--
In memoriam Alan J. Flavell
http://groups.google.com/groups/sear...Alan.J.Flavell
Apr 16 '07 #2

P: n/a
Scripsit Duncan Jones:
*Ignoring* for a second why I want to do this, is there any way to
specify that an element in a page should ignore all CSS properties
that have been defined for it, and to adopt some form of browser
default?
Not in CSS. Whether there is a way of doing that outside CSS is a different
thing and depends on the browser. Some browsers even have their default
style sheet more or less documented and might have it available as a CSS
file. But there is no way to say to browsers in general that they should use
their defaults for some property or all properties.
Suppose I want to add a <tdelement to an *arbitrary* web page. I
want this element to ignore any CSS directives that may already apply
to <tdelements, and to behave as though the original page has no CSS
defined at all.
You can't. What you can do is to insert an <iframeor <objectelement e.g.
inside a <tdelement. Then browsers will display the content of the
embedded element autonymously, independently of the embedding page's style
sheet. Thus, if you don't specify any style sheet for it, browser defaults
will be used, even if the embedding page has been styled. Whether <iframe>
or <objectelement is suitable for some particular purpose is a different
issue.
I'm guessing there is no way to do this, and I must define by hand my
own set of styles that I consider to be "default. e.g.:

<td style="margin: 0; padding: 0; background-color: inherited; ......
">
I guess you meant inherit, not inherited. Please not that IE does not
support the value inherit. Moreover, the initial value of background-color
is transparent, and this is the typical browser default for most elements,
including table cells.

Note that <tdelements typically have default rendering that corresponds to
padding: 2px, and margin properties are ignored for table cells.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Apr 16 '07 #3

P: n/a
On 16 Apr, 15:59, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
Scripsit Duncan Jones:
*Ignoring* for a second why I want to do this, is there any way to
specify that an element in a page should ignore all CSS properties
that have been defined for it, and to adopt some form of browser
default?

Not in CSS. Whether there is a way of doing that outside CSS is a different
thing and depends on the browser. Some browsers even have their default
style sheet more or less documented and might have it available as a CSS
file. But there is no way to say to browsers in general that they should use
their defaults for some property or all properties.
Suppose I want to add a <tdelement to an *arbitrary* web page. I
want this element to ignore any CSS directives that may already apply
to <tdelements, and to behave as though the original page has no CSS
defined at all.

You can't. What you can do is to insert an <iframeor <objectelement e.g.
inside a <tdelement. Then browsers will display the content of the
embedded element autonymously, independently of the embedding page's style
sheet. Thus, if you don't specify any style sheet for it, browser defaults
will be used, even if the embedding page has been styled. Whether <iframe>
or <objectelement is suitable for some particular purpose is a different
issue.
I'm guessing there is no way to do this, and I must define by hand my
own set of styles that I consider to be "default. e.g.:
<td style="margin: 0; padding: 0; background-color: inherited; ......
">

I guess you meant inherit, not inherited. Please not that IE does not
support the value inherit. Moreover, the initial value of background-color
is transparent, and this is the typical browser default for most elements,
including table cells.

Note that <tdelements typically have default rendering that corresponds to
padding: 2px, and margin properties are ignored for table cells.

--
Jukka K. Korpela ("Yucca")http://www.cs.tut.fi/~jkorpela/
Thanks for the help, Jukka.

Apr 16 '07 #4

P: n/a
Scripsit Andreas Prilop:
>is there any way to
specify that an element in a page should ignore all CSS properties
that have been defined for it, and to adopt some form of browser
default?

Ah! Do you mean something like
http://www.w3.org/TR/REC-CSS2/cascad...ue-def-inherit
?
No, that would be something completely different. (The allusion to Monty
Python is intentional.)

The value inherit means (by the specifications, which are ignored by IE in
this matter) that the value of a property is copied - by certain rules,
with some surprises - from the value of the property for the "parent"
(immediately enclosing element) of the current element.

This is quite distinct from adopting a browser default. Inheritance is, by
definition, applicable only when _no_ style sheet being used sets a value
for a property of an element.

To take a simple example, a browser may well have some monospace font as its
default font for <preor <textareaelements. Actually, that's more or less
the recommendation for <pre>. If you set pre, textarea { font-family:
inherit; }, then you are _not_ telling the browser to use its default. Quite
on the contrary, you are overriding the browser default and telling the
browser to use the font-family value of the "parent" of the <textarea>
element. This is typically <divor <form>, which usually has no font-family
setting, so it inherits it etc., and we probably come up to the settings for
<body>. Thus, the effect is _typically_ that the browser default for the
_overall_ font-family is used, not the browser default for the specific
element. And, of course, if any intermediate element between <preor
<textareaand <bodyhas its own font-family setting, from whichever style
sheet, it breaks the chain of inheritance.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Apr 17 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.