473,386 Members | 2,050 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,386 software developers and data experts.

External/internal styles

Just FMI, if an external stylesheet is linked to a page (with <link>),
will subsequent <style> tags override the values in the external
stylesheet?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 20 '05 #1
6 3400
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:bq**********@chessie.cirr.com...
Just FMI, if an external stylesheet is linked to a page (with <link>),
will subsequent <style> tags override the values in the external
stylesheet?


They will add to the styles, and if you have conflicting styles between the
external and internal style definitions, whichever is defined last will get
priority. So if your external file includes:

span { font-weight: 600; }

and your internal styles include:

span { font-weight: 100; }

then if you linked stylesheet was included before the internal style
definition, the span font-weight will be 100. If the linked stylesheet was
included after the internal style definition, the span font-weight will be
600.

Regards,
Peter Foti

Jul 20 '05 #2
In article <bq**********@chessie.cirr.com> in
comp.infosystems.www.authoring.stylesheets, Christopher Benson-
Manica <at***@nospam.cyberspace.org> wrote:
Just FMI, if an external stylesheet is linked to a page (with <link>),
will subsequent <style> tags override the values in the external
stylesheet?


All else being equal, yes.

http://www.w3.org/TR/REC-CSS2/cascade.html#cascade

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #3

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:bq**********@chessie.cirr.com...
Just FMI, if an external stylesheet is linked to a page (with <link>),
will subsequent <style> tags override the values in the external
stylesheet?
They will add to the styles, and if you have conflicting styles between

the external and internal style definitions, whichever is defined last will get priority. So if your external file includes:

span { font-weight: 600; }

and your internal styles include:

span { font-weight: 100; }

then if you linked stylesheet was included before the internal style
definition, the span font-weight will be 100. If the linked stylesheet was included after the internal style definition, the span font-weight will be
600.


Could you please explain what you mean by "before the internal style
definition" and "after ...."? And what do you mean by "included"?

Thanks.

I thought I understood that the answer to the poster's question was in the
name, "Cascading Style Sheets," and that the lowest style (from external
style sheet to inline style) was the one that governed the display of a
particular item. But I really don't understand your reference to before and
after.

--

Bonnie Granat
http://www.granatedit.com

Jul 20 '05 #4
*Bonnie Granat* <bg*****@granatedit.com>:

Could you please explain what you mean by "before the internal style
definition" and "after ...."?
Just that, physical order. If you can call it "physical" in code.
You can either have

<link rel="stylesheet" type="text/css" href="external.file">
<style type="text/css">...</style>,

i.e. 'link' _before_ internal style, or

<style type="text/css">...</style>
<link rel="stylesheet" type="text/css" href="external.file">,

i.e. 'link' _after_ internal style. Of course you can have multiple 'style'
and/or 'link' elements in whatever order you want.

For many selectors it won't matter, but if you've got two with equal
specifity--they don't need to be exactly the same--the latter specified
wins, no matter where it was defined. You can even throw @import stylesheets
in, the principle doesn't change.

The algorithm in <http://www.w3.org/TR/CSS21/cascade.html#cascading-order>
is pretty clear in my opinion, even a little bit cleare than the CSS 2.0
version. Specifity calculation rules are in 6.4.3.
And what do you mean by "included"?
In the (HTML) code.
I thought I understood that the answer to the poster's question was in the
name, "Cascading Style Sheets," and that the lowest style (from external
style sheet to inline style) was the one that governed the display of a
particular item.


Only the 'style' attribute is special the rest of the author styles is
thrown together, keeping code appearance order unchanged. The rest is weight
('!important' or not?) and specifity (what selector?).

--
"Right way turning, Listen we are learning.
Head's full of noise, Chicken's got no choice.
Heads are rollin', Chicken blood is stolen.
The rest of the chicken wants a picke-nicken" Guano Apes - We use the Pain
Jul 20 '05 #5
"Bonnie Granat" <bg*****@granatedit.com> wrote in message
news:3f******@andromeda.5sc.net...

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message news:bq**********@chessie.cirr.com...
Just FMI, if an external stylesheet is linked to a page (with <link>),
will subsequent <style> tags override the values in the external
stylesheet?
They will add to the styles, and if you have conflicting styles between

the
external and internal style definitions, whichever is defined last will

get
priority. So if your external file includes:

span { font-weight: 600; }

and your internal styles include:

span { font-weight: 100; }

then if you linked stylesheet was included before the internal style
definition, the span font-weight will be 100. If the linked stylesheet

was
included after the internal style definition, the span font-weight will be 600.


Could you please explain what you mean by "before the internal style
definition" and "after ...."? And what do you mean by "included"?


Sure... by "internal", I meant style definitions that are defined in the
head of the document within <style></style>. By "external", I meant styles
that are linked in using <link> (or the @import directive). By "included",
I meant whether the linked in stylesheet came before the internal style
definitions in the document, or after them. Stan Brown's post in this
thread has a good link.
I thought I understood that the answer to the poster's question was in the
name, "Cascading Style Sheets," and that the lowest style (from external
style sheet to inline style) was the one that governed the display of a
particular item. But I really don't understand your reference to before and after.


Your understanding was incorrect. Each style definition gets a weight,
which depends on the import order. For example:

..myclass{ color: red; }
..myclass{ color: green; }

<p class="myclass">This text is green because the last rule had greater
weight</p>

Now, suppose that I put the first definition in an external file
(mystyle.css) and imported it:

@import url(mystyle.css)
..myclass{ color: green; }

The text would still be green because the last definition still has the most
weight. But now if I swap the order:

..myclass{ color: green; }
@import url(mystyle.css)

Now the text would be red, because the last definition is now the one in the
external file.

Hope this helps.
Peter
Jul 20 '05 #6
*Peter Foti* <pe****@systolicnetworks.com>:

.myclass{ color: green; }
@import url(mystyle.css)


Although it explains the principle well, this would be invalid syntax if
inside the same 'style' element or CSS file, because @import has to be at
the top.

That means

<style type="text/css">.myclass{ color: green; }
@import url(mystyle.css)</style>

is illegal, while

<style type="text/css">.myclass{ color: green; }</style>
<style type="text/css">@import url(mystyle.css)</style>

and of course

<style type="text/css">@import url(mystyle.css)
.myclass{ color: green; }</style>

are not. IIRC.

--
Arthur: "I really wish I'd listened to what my mother told me when I was young."
Ford: "Why, what did she tell you?"
Arthur: "I don't know, I didn't listen."
Jul 20 '05 #7

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

Similar topics

11
by: Douglas Reith | last post by:
Hi There, Can someone please tell me why the XML spec states that an attribute value with an external entity is forbidden? Or point me to the appropriate document? Or better still, perhaps you...
1
by: Razvan | last post by:
Hi What is the difference between an internal and an external entity ? The first one is defined in the internal subset (not in a separate DTD file, but in the XML file itself - in...
2
by: Markus Ernst | last post by:
Hi I build a small content management system. I use different external stylesheets for the admin section and the frontend, called admin.css and frontend.css. Now I would like to preview some...
7
by: David Filmer | last post by:
Greetings. I want to localize a style definition to a portion of an HTML document, but use an external stylesheet. It seems that I can only do <style><!-- @import...
26
by: HarryO | last post by:
I created an external stylesheet file 'styles.css' and an html file that includes the line: <LINK REL="stylesheet" TYPE="text/css" HREF="styles.css" Both the .css file and the html file reside...
12
by: relaxedrob | last post by:
Hi All! I have a page with with the following style information: <link rel="stylesheet" type="text/css" href="/eEmployment/eTech.css" /> <style type="text/css"> DIV.Application {...
3
by: al.cpwn | last post by:
do static and inline functions or members have internal linkage? I have been reading this newsgroup on google and found conflicting ideas. Can someone please help me understand why in some places...
14
by: Stapes | last post by:
Hi I have this entry in my stylesheet main1.css: #head { width: 310px; height: 60px; float: left; display: block; background-image: url(logo.jpg); background-position: left top;
35
by: Guy Macon | last post by:
I have been running tests on various doctypes and found something interesting. I set up a test page using this doctype... <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 1//EN"> ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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:
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.