473,434 Members | 1,818 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,434 software developers and data experts.

Local HTML vs. External CSS

Hi...

My external style sheet for a 200+ page site is marked up as:

BODY, P, TABLE, TD, DIV {
background: #ffffff;
font-style: normal;
font-variant: normal;
font-weight: normal;
font-size: 1em;
color: #000000;
font-family: Verdana, sans-serif, arial;
}

I have one solitary page on which I'd like a pale blue background, so I
coded:

<LINK rel="stylesheet" type="text/css" href="gz.css"
title="default">
</HEAD>
<BODY bgcolor="#80ffff" onLoad="setTimeout(window.close, 5000)">

The page validates as HTML 4.01 transitional, but the background stays
white. I was under the impression that local code takes precedence.

Do I really have to go to a CLASS or ID selector?

--
- Yours truly, Pete Collinson

Jul 20 '05 #1
12 2759
In article <SX*********************@news4.srv.hcvlny.cv.net >, Peter
Collinson wrote:
Hi...

My external style sheet for a 200+ page site is marked up as:

BODY, P, TABLE, TD, DIV {
background: #ffffff;
color: #000000;
Is there some good reason to say black on white?
font-style: normal;
font-variant: normal;
font-weight: normal;
Why? If someone wants her text stange looking, I bet he has very good
reason
font-size: 1em;
That is redundant too.
font-family: Verdana, sans-serif, arial;
You shouldn't IMO set font to especially Verdana, nor at all.
}

I have one solitary page on which I'd like a pale blue background, so I
coded:

<LINK rel="stylesheet" type="text/css" href="gz.css"
title="default">
</HEAD>
<BODY bgcolor="#80ffff" onLoad="setTimeout(window.close, 5000)">
You are making popup, aren't you? That's nasty.
The page validates as HTML 4.01 transitional, but the background stays
white. I was under the impression that local code takes precedence.
No, inline CSS takes precedence over other CSS. HTML rules don't. That is
somewhere in spec. CSS1 had some exeptions though.
Do I really have to go to a CLASS or ID selector?


No, you need another stylesheet, or embedded style block for that.
I'll recommend using another external CSS. You need to it to have same
title as your normal style
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #2
Peter Collinson wrote:

[snip]
<LINK rel="stylesheet" type="text/css" href="gz.css"
title="default">
</HEAD>
<BODY bgcolor="#80ffff" onLoad="setTimeout(window.close, 5000)">

The page validates as HTML 4.01 transitional, but the background stays
white. I was under the impression that local code takes precedence.


No. style attributes are treated as though they have an id in the selector.
This means that they have a high specificity:

<URL:http://www.w3.org/TR/REC-CSS2/cascade.html#specificity>

You haven't used a style attribute though, you have used deprecated HTML.
Non-CSS presentational hints have a low specificity:

<URL:http://www.w3.org/TR/REC-CSS2/cascade.html#specificity>

In other words, use CSS instead of obsolete, presentational HTML cruft, or
be treated like a second-class www citizen :)

--
Jim Dabell

Jul 20 '05 #3
Jim Dabell <ji********@jimdabell.com> writes:
No. style attributes are treated as though they have an id in the selector.
This means that they have a high specificity:

<URL:http://www.w3.org/TR/REC-CSS2/cascade.html#specificity>


Though many browsers interpret their specificity as infinite rather
than 100.

--
Chris
Jul 20 '05 #4
In article <87************@dinopsis.dur.ac.uk>, Chris Morris wrote:
Jim Dabell <ji********@jimdabell.com> writes:
No. style attributes are treated as though they have an id in the selector.
This means that they have a high specificity:

<URL:http://www.w3.org/TR/REC-CSS2/cascade.html#specificity>


Though many browsers interpret their specificity as infinite rather
than 100.


Yes, and that's why spec is changed on 2.1

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #5
Lauri Raittila <la***@raittila.cjb.net> chides...

#> My external style sheet for a 200+ page site is marked up as:

#> BODY, P, TABLE, TD, DIV {
#> background: #ffffff;
#> color: #000000;
Is there some good reason to say black on white?
Absolutely... perhaps it's over-coding to you and others, but I'm
covering all my bases, #1, and, #2, I don't like getting *** WARNING ***
messages from the CSS Validator.

#> font-style: normal;
#> font-variant: normal;
#> font-weight: normal;
Why? If someone wants her text stange looking,
I bet he has very good reason
Hey!, c'mon, Lauri... I'm still using training wheels here. I've worked
on an external CSS mark-up template, tweaked it into validating, and by
Gawd and little blue pixels, I'm gonna use it 'til I am comfortable
enough to kick the traces and fly from scratch... to mangle a metaphor
or two.

#> font-size: 1em;
That is redundant too.
Yeah, it may be, but if I want to make a change, it's easy to do, now,
isn't it?!?

#> font-family: Verdana, sans-serif, arial;
You shouldn't IMO set font to especially Verdana, nor at all.
Whew!, you're a mean woman!

#> }
#>
#> I have one solitary page on which I'd like a pale blue
#> background, so I coded:

#> <LINK rel="stylesheet" type="text/css" href="gz.css"
#> href="gz.css" title="default">
#> </HEAD>
#> <BODY bgcolor="#80ffff" onLoad="setTimeout(window.close, 5000)">
You are making popup, aren't you? That's nasty.
Guilty! Guilty! Guilty!

But a necessary adjunct of the project description is that occasional
time-sensitive announcements be displayed for 5 seconds.

#> The page validates as HTML 4.01 transitional, but
#> the background stays white. I was under the
#> impression that local code takes precedence.
No, inline CSS takes precedence over other CSS.
HTML rules don't. That is somewhere in spec.
CSS1 had some exeptions though.
#> Do I really have to go to a CLASS or ID selector?
No, you need another stylesheet, or embedded style
block for that. I'll recommend using another external
CSS. You need to it to have same title as your normal style


I doped out the embedded style declaration shortly after I posted the
original question:

<LINK rel="stylesheet" type="text/css" href="../gz.css"
title="default">

<style type="text/css"><!--body { background: #80ffff; }--></style>

</HEAD>

It seems to achieve the desired effect.

Thank you for your comments and suggestions.
--
- Yours truly, Pete Collinson




































Jul 20 '05 #6
In article <i9**********************@news4.srv.hcvlny.cv.net> , Peter
Collinson wrote:
Lauri Raittila <la***@raittila.cjb.net> chides...

#> My external style sheet for a 200+ page site is marked up as:

#> BODY, P, TABLE, TD, DIV {
#> background: #ffffff;
#> color: #000000;
Is there some good reason to say black on white?
Absolutely... perhaps it's over-coding to you and others, but I'm
covering all my bases, #1, and, #2, I don't like getting *** WARNING ***
messages from the CSS Validator.


But, why black on white. It is default on all CSS knowing browsers, I
think. and when someone has changed it, he does it with good reason. I
have, at least. And you don't get any warning, when you leave both out.
#> font-size: 1em;
That is redundant too.
Yeah, it may be, but if I want to make a change, it's easy to do, now,
isn't it?!?


Well, you never change body font size. And em unit is buggy in some old
browser that you don't need to care much. But using lots of redundant
code makes it more likely to hit some bug accidentally.
#> font-family: Verdana, sans-serif, arial;
You shouldn't IMO set font to especially Verdana, nor at all.
Whew!, you're a mean woman!


Use google groups to find out why, and what I'm not.
Guilty! Guilty! Guilty!

But a necessary adjunct of the project description is that occasional
time-sensitive announcements be displayed for 5 seconds.
OK. Automatic pop-up ads don't bother me as much as banners, as I use
browser that never shows me any pop-up ads.
I doped out the embedded style declaration shortly after I posted the
original question:
You mean, you replaced deprecated HTML attribute using embedded CSS.
<LINK rel="stylesheet" type="text/css" href="../gz.css"
title="default">
That is linked/external preferred stylesheet. (whitout title it would be
persistant, with rel="alternative stylesheet" it would be alternative)
<style type="text/css"><!--body { background: #80ffff; }--></style>


That's called embedded stylesheet.

<body style="none:none">

Here none:none is inline style. I hope this helps to understand
teminology.
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Feel free to contact me by email if your message OT, or private, etc.
but do not CC same message to as you send to usenet.
Jul 20 '05 #7
Lauri Raittila <la***@raittila.cjb.net> wrote in message
news:<MP************************@news.cis.dfn.de>. ..
Is there some good reason to say black on white?


Absolutely... perhaps it's over-coding to you and others, but I'm
covering all my bases, #1, and, #2, I don't like getting *** WARNING ***
messages from the CSS Validator.


But, why black on white. It is default on all CSS knowing browsers, I
think. and when someone has changed it, he does it with good reason. I
have, at least.


You're probably right in general, and I don't disagree with your advice.
But I set my defaults to black on gray. I like this best for default,
but that doesn't mean I don't like the web to have a little variety.

However, it seems like the safest advice is just use style sheets for
layout, and don't specify any style settings at all. :-)
Jul 20 '05 #8
In article <d1**************************@posting.google.com >, Christopher
wrote:
You're probably right in general, and I don't disagree with your advice.
But I set my defaults to black on gray. I like this best for default,
Then you see why, obviously - try something like #f0f0f0; or some
suitable off white on your page - it is much nicer than white. I think so
at least.
but that doesn't mean I don't like the web to have a little variety.
By using grey background on your web page would have some more variety,
using white, it's the same as all others, so I fail to see your point.
However, it seems like the safest advice is just use style sheets for
layout, and don't specify any style settings at all. :-)


Of course you can use CSS, but it is not nice to use CSS to make the page
look as it would in browsers factory settings.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #9
"Peter Collinson" <bl******@optonline.net> wrote in message
news:SX*********************@news4.srv.hcvlny.cv.n et...
Hi...

My external style sheet for a 200+ page site is marked up as:

BODY, P, TABLE, TD, DIV {
background: #ffffff;
font-style: normal;
font-variant: normal;
font-weight: normal;
font-size: 1em;
1em means the size of am 'm' character in the current font.
color: #000000;
font-family: Verdana, sans-serif, arial;
}

I have one solitary page on which I'd like a pale blue background, so I
coded:

<LINK rel="stylesheet" type="text/css" href="gz.css"
title="default">
</HEAD>
<BODY bgcolor="#80ffff" onLoad="setTimeout(window.close, 5000)">

The page validates as HTML 4.01 transitional, but the background stays
white. I was under the impression that local code takes precedence.

Do I really have to go to a CLASS or ID selector?
No, just
<BODY style="background-color:#80ffff" onLoad="setTimeout(window.close,
5000)">

--
- Yours truly, Pete Collinson


Jul 20 '05 #10
Lauri Raittila <la***@raittila.cjb.net> wrote in message
news:<MP************************@news.cis.dfn.de>. ..
In article <d1**************************@posting.google.com >, Christopher
wrote:
You're probably right in general, and I don't disagree with your advice.
But I set my defaults to black on gray. I like this best for default,


Then you see why, obviously - try something like #f0f0f0; or some
suitable off white on your page - it is much nicer than white. I think so
at least.
but that doesn't mean I don't like the web to have a little variety.


By using grey background on your web page would have some more variety,
using white, it's the same as all others, so I fail to see your point.


My point is that if Pete's page looks best as black on white, I want to
view it as black on white, even if in most cases I don't like that. This
is all IMHO, of course, so take it FWIW.

I don't have vision problems. Rest assured that if I did, I would have
background and color set with !important in my userContent.css file, or
else not be using a visual browser, and this issue would be moot. But I
don't. So the colors I want to see are the ones that look best for that
page.

For a lot of pages there's nothing but plain text, and I prefer black
on gray for that. But some pages actually do look best with a white
background. Maybe all his GIFs are aliased to white. Have you seen what
the www.google.com page looks like with a gray background? It's ugly.
Jul 20 '05 #11
"Alan J. Flavell" <fl*****@mail.cern.ch> wrote in message
news:Pi*******************************@lxplus081.c ern.ch...
On Tue, Jul 22, Steven Dilley inscribed on the eternal scroll:
"Peter Collinson" <bl******@optonline.net> wrote in message

font-size: 1em;


1em means the size of am 'm' character in the current font.


What sort of light is *that* remark supposed to throw on anything?

I'd suggest reading what the CSS specification has to say about em
units in CSS before answering too many more questions.


Have I misconstrued? yet again?

The spec says:
Relative units specify a length relative to another length property.
The relative units 'em' and 'ex' are relative to the font size of the
element itself.
H1 { margin: 0.5em } /* ems, the height of the element's font */
H1 { margin: 1ex } /* x-height, ~ the height of the letter 'x' */

I guess the 'em' is not about the letter 'm', but the 'ex' is about the
letter 'x'?
Sincere apologies if my confusion has become contagious.
--
Steve

Jul 20 '05 #12
In article <3f********@10.10.0.241>, Steven Dilley wrote:
I guess the 'em' is not about the letter 'm', but the 'ex' is about the
letter 'x'?


Yes.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #13

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

Similar topics

11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
1
by: Colin J. Williams | last post by:
I have material on a local PC which I upload to a web server. I would like to use webchecker to check both the local linkage and that at the remote server. All works well when I check the...
1
by: Dave Theese | last post by:
Consider the following declaration *inside of a function*: int j(int); My compiler (VC++ 7.1) accepts this. typeid returns a type of int __cdecl(int). Local functions are not legal in C++....
4
by: Peter Ammon | last post by:
I would like to share a variable between two functions defined in two separate source files; no other functions will need the global variable so I'd prefer to not give it file scope. Thus, I want...
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
7
by: bbasberg | last post by:
Hello, I thought I would do a "sanity check" by asking the experts how to do the following: I need to process external data (it will be in an Access DB table and will be updated daily) into a...
6
by: LeslieTP | last post by:
I'd like to submit a .php form to a url at an external site and redirect to a local page, but am stumped and need some help. <form ACTION="http://www.externalsite/post.php" method="post"...
7
by: RN1 | last post by:
Is it possible to connect to my local SQL Server 2005 database from a remote web server? If yes, what ConnectionString do I use? Thanks, Ron
1
by: Tina | last post by:
I want to browse my aspnet application on my dev box which has a local I/P 192.168.1.1 and it is connected to my rounter that has my real external IP of say 200.200.200.200. If I browse the...
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
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,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.