473,513 Members | 2,537 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to override all sytles?

If I want all text, no matter where it is, to be gray, is there a way
to override styles and have that color take affect? It would need to
override DIVs, tables, SPANs, anywhere inline styles are defined,
override external style sheet references, definitions in the HEAD
section.

I won't know ahead of time what exactly the webpage content is.

Thanks,
Brett

Jul 21 '05 #1
11 16711
brett wrote:
If I want all text, no matter where it is, to be gray, is there a way
to override styles and have that color take affect? It would need to
override DIVs, tables, SPANs, anywhere inline styles are defined,
override external style sheet references, definitions in the HEAD
section.

I won't know ahead of time what exactly the webpage content is.


Why are you using styles that color text anything *other* than gray if
you want all your text to be gray?
Jul 21 '05 #2
"brett" <ac*****@cygen.com> wrote:
If I want all text, no matter where it is, to be gray, is there a way
to override styles and have that color take affect?


Unless I'm missing something,
* { color: gray !important; background: white !important; }
in a user style sheet should do that, and does that, on modern browsers.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 21 '05 #3
in comp.infosystems.www.authoring.stylesheets, brett wrote:
If I want all text, no matter where it is, to be gray, is there a way
to override styles and have that color take affect? It would need to
override DIVs, tables, SPANs, anywhere inline styles are defined,
override external style sheet references, definitions in the HEAD
section.

I won't know ahead of time what exactly the webpage content is.


* {color:#999 !important} in you userstylesheet, if you don't have
conflicting userstyles.
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Jul 21 '05 #4
Yeah, that works well, except with conflicting style sheets. I need to
some how override them. Look at this example and note the table cell
style retains its style. How can I override it?

<html>
<head>
<title>Untitled</title>
</head>

<body style="color: gray !important">

<div id="sample1" style="width:100%"><h3>John slowly faded into
view---</h3>
</div>

<a href="x">Here is a problem link</a><br>
<!--style="filter:alpha(opacity=100)"
crossobj.style.MozOpacity-->
<img src="http://www.google.com/images/logo.gif" alt=""
name="imgsample1" id="imgsample1" border="0"
style="filter:alpha(opacity=100); -moz-opacity:1"><br>
<div id="sample2" style="width:100%"><h3>Another fade occurs
here.</h3></div>
<br>
<a href="x">Here is another problem link</a>
<br><br>

<table><tr><td style="color: red">this will stay red</td></tr></table>
<div>text in div tag<h4>this is in DIV tag in H4</h4></div>

</body>
</html>
Thanks,
Brett

Jul 21 '05 #5
"brett" <ac*****@cygen.com> wrote:
Yeah, that works well,
"That"? Please quote or paraphrase the relevant part of the message you are
commenting on.
except with conflicting style sheets.
No, what I responded is correct: using !important in a user style sheet
makes the declaration win other style sheets (excluding, of course, other
!important declarations in a user style sheet).
I need to some how override them.
In a user style sheet, you can override them, as I explained. In an author
style sheet, you cannot, by design, and that's _good_.
Look at this example and note the table cell
style retains its style. How can I override it?
Within an author style sheet, if that's what you mean, as you seem to be
meaning, you can override other declarations (assuming they don't use
!important) by using
* { color: gray !important; background: white !important; }
just as I wrote. Did you actually read the message of mine that you are
responding to?
<body style="color: gray !important">


That's something completely different. It only sets the color of the body
element - and unwisely leaves the background unspecified, at the risk of
getting gray on gray.

Of course, setting everything to gray is most probably absurd.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 21 '05 #6
in comp.infosystems.www.authoring.stylesheets, brett wrote:

What are you replying? Do not top post. Assuming that you still speak
about userstylesheet.
Yeah, that works well, except with conflicting style sheets. I need to
some how override them.
Very hard. But they unlikely have id selectors.
html > head:first-child + body, html > head:first-child + body *
{color:gray !important;}

Gets you specifity 0, 0, 1, 3 works on some browsers.
Look at this example and note the table cell
style retains its style. How can I override it?


URL? If you just added style="color:gray !important;" in your file, you
got everything wrong. Maybe you could explain your real problem? With
URL.
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Jul 21 '05 #7
brett wrote:
If I want all text, no matter where it is, to be gray, is there a way
to override styles and have that color take affect? It would need to
override DIVs, tables, SPANs, anywhere inline styles are defined,
override external style sheet references, definitions in the HEAD
section.


Not with CSS alone. You can't write a selector more specific then an inline
style attribute.

You could do something like:

my el = document.getElementsByTagName('*');
for (var i = 0; i < el.length; i++) {
el[i].style.color = "rgb(50%,50%,50%)"
}

It wouldn't be very quick though.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 21 '05 #8
brett wrote:

If I want all text, no matter where it is, to be gray, is there a way
to override styles and have that color take affect? It would need to
override DIVs, tables, SPANs, anywhere inline styles are defined,
override external style sheet references, definitions in the HEAD
section.

I won't know ahead of time what exactly the webpage content is.


If you are a user viewing someone else's Web page, just set your
browser to use only your own colors and to ignore the colors
specified on the page.

--

David E. Ross
<URL:http://www.rossde.com/>

I use Mozilla as my Web browser because I want a browser that
complies with Web standards. See <URL:http://www.mozilla.org/>.
Jul 21 '05 #9
Lauri Raittila wrote:
in comp.infosystems.www.authoring.stylesheets, brett wrote:

What are you replying? Do not top post. Assuming that you still speak about userstylesheet.
Yeah, that works well, except with conflicting style sheets. I need to some how override them.
Very hard. But they unlikely have id selectors.
html > head:first-child + body, html > head:first-child + body *
{color:gray !important;}

Gets you specifity 0, 0, 1, 3 works on some browsers.
Look at this example and note the table cell
style retains its style. How can I override it?


URL? If you just added style="color:gray !important;" in your file,

you got everything wrong. Maybe you could explain your real problem? With URL.


Perhaps this isn't the right place to ask this question, but this topic
almost answers a similar question I have--but not quite, unless I am
not understanding the posts completely.

I have a portions of a page that I don't have any easy control over
with content that has inline styles such as this

<p><font color="red">Return-pbath</font></b>:
&lt;1zYzTINizEDqr3HXfqno0yqZP6kJsHlFe@<b><font
color="black">109326.<b><font color="red">reply.<b><font
color="red">saveyourwallet<b><font color="blue">.com</p>

I would like to wrap this in a div element, and create a button that
will toggle everything within that color to have an alternate color
(e.g. black). I have been able to affect the font size and font face
because those aren't specified inline, but the color has so far alluded
me.

Regards,

Michael

Jul 21 '05 #10
"Michael Bierman" <mi*************@gmail.com> wrote:
<p><font color="red">Return-pbath</font></b>:
&lt;1zYzTINizEDqr3HXfqno0yqZP6kJsHlFe@<b><font
color="black">109326.<b><font color="red">reply.<b><font
color="red">saveyourwallet<b><font color="blue">.com</p>

I would like to wrap this in a div element, and create a button that
will toggle everything within that color to have an alternate color
(e.g. black). I have been able to affect the font size and font face
because those aren't specified inline, but the color has so far alluded
me.


What you need to do, in CSS yerms, is to set both the p element's and the
font element's color. No matter what we think about the font element, it
constitutes an element in markup and the parsed document, so it has all the
properties defined in CSS specifications, and browsers are allowed to apply
the presentational hints given in color="..." attributes as corresponding
to settings in the page's (author's) style sheet. Conceptually, those
corresponding settings are treated as having the lowest possible
specificity and as appearing at the start of the page's style sheet, so it
is easy to override them - as long as you remember that they need to be
overridden for the font elements as well.

Thus, font { color: black; background: white; } would override the effect
of the font markup in this case, but you could also make things simpler:
* { color: black; background: white; }

Similarly, should you wish to nullify the effect of <b> markup, you would
say
b { font-weight: normal; }

I guess that these rules would work despite the fact that the markup is
invalid, with several font and b elements that have been opened but not
closed.

How you map this principle to client-side scripting that changes element
properties dynamically is off-topic for this group, I guess, and depends on
the DOM.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 21 '05 #11
Thanks Jukka. I ended up with a solution that looks very much like
what you describe. For other people's reference, I found an excellent
resource at http://developer.apple.com/internet/...nt/styles.html

This sample code, which Apple has granted unresticted usage, solved my
problem nicely.

Regards,

Michael

Jul 21 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3106
by: Woodmon | last post by:
Example of my CSS follows: <style type="text/css" media="screen"> BODY { color: white } A:link { color: 66CCFF; } A:visited { color: CC66FF; } A:active { color: CC66FF; } A:hover { color: white; background-color: #0099cc; text-decoration: #000000;}
7
6422
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override ListView.Items.Add(), . I see that it is a virtual method so it should be easy to do. If anyone can help I would appreciate it greatly. I can do what...
5
2583
by: Mark Broadbent | last post by:
Oh yes its that chestnut again! Ive gone over the following (http://www.yoda.arachsys.com/csharp/faq/ -thanks Jon!) again regarding this subject and performed a few of my own tests. I have two classes yClass which inherits xClass. xClass has a virtual method which simply writes a line of text stating its origin, yClass implements the same...
2
4517
by: Flip | last post by:
In java, the default for methods is override. In c# that is not the case. This talks about two classes, the base class and the overriding class. What happens when you have a third class in the mix, extending the second class, how can you indicate the method in the third class is overridding the overridden method? Do you declare the second...
5
9575
by: Stoyan | last post by:
Hi All, I don't understand very well this part of MSDN: "Derived classes that override GetHashCode must also override Equals to guarantee that two objects considered equal have the same hash code; otherwise, Hashtable might not work correctly." Does any one know, why we must also override Equals, Please give my an example:) Thanks, Stoyan
15
2510
by: John Salerno | last post by:
Hi all. I have a question about virtual and override methods. Please forgive the elementary nature! First off, let me quote Programming in the Key of C#: "Any virtual method overridden with 'override' remains a virtual method for further descendent classes." Now here's my question: Let's say you have base class A, and subclasses B and C....
2
4041
by: Adriano Coser | last post by:
Hello. After I converted my .net code to the new VC2005 syntax I started to get C4490 on my ExpandableObjectConverter subclass overrides. The GetProperties method is no longer called by the PropertyGrid when I use my subclass as a type converter. Can anyone tell me what has changed? What's the correct way to override GetProperties...
8
5470
by: bdeviled | last post by:
I am deploying to a web environment that uses load balancing and to insure that sessions persist across servers, the environment uses SQL to manage sessions. The machine.config file determines how all applications will use sessions and to insure that all application use this method, the session properties cannot be overriden. Within the...
5
4515
by: Marcel Hug | last post by:
Hi NG ! I'm new in C# and I'm reading a book about the fundamentals and concepts. In the chapter Methods it's written to use virtual, if i would like to override the method in a subclass. This I've to do by using override. It's also written, that's possible to "hide" the base class method by using the new key word. Because I've already...
0
7270
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7563
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.