473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using the browser's default style for an element

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
4 2979
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sol | last post by:
Hi, is it possible to disable an element using CSS? instead of using document.getElementById("someButton").disabled = true I would like to use <style> ..someButton {disabled : true;...
1
by: Philip | last post by:
Hey, Is it possible to get the default value of an element's style.backgroundColor property that's set in a css class? Example, since I'm very tired and can't word that any better ;) ...
1
by: J. Potts | last post by:
Just out of curiosity, has anyone run into this problem? Someone where I work put a set of pages together with the following in the style sheet: BODY { position: absolute; margin-top: 0mm;...
15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
2
by: Dave Hammond | last post by:
I'm not sure if this is technically a javascript question, but I'm coding in javascript, so I'll try here first. To overlay a section of a page I typically use an absolute positioned <div> and...
4
by: ScooterMX | last post by:
I have a menu that stretches across the top of a series of pages, and I need to be able to change all 8 div's absolute position. Here's a snippet of the code I am using: <div id="layer1"...
1
by: dotnetdummy | last post by:
Hi, Can anyone who can help me out if possible. At the moment, I'm working on a window application (vb.net) which print out html document's through a default network printer. I'm using...
3
by: Lance Wynn | last post by:
Hello, I am receiving this error when trying to instantiate a webservice component. I have 2 development machines, both are XP sp2 with VS 2008 installed. On one machine, the code works fine. On...
1
Claus Mygind
by: Claus Mygind | last post by:
How come I can set this style element document.getElementById("popTime").style.left = "0px"; but not this document.getElementById("freqJobDiv").style.zIndex = "20"; I have two nested...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.