473,657 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using both style and class in an element

Hi folks,

I found this in some pages:

<td style="border-bottom: 1px solid #000000; border-left: 1px solid
#000000; background-color:#4080A0;f ont-weight: bold; color: #000000;"
class="myclass" >

I've never seen both style and class used in the same element. Is the
common? Which wins? What happens?

For what it's worth, the class myclass was not actually defined.
--
Dan Langille
resume: http://www.langille.org/
Jul 20 '05 #1
19 2958
Dan Langille wrote:
I've never seen both style and class used in the same element. Is the
common?
No, thankfully. The style attribute is nasty.
Which wins? What happens?


The style attribute has a higher specificity then external style sheets.

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
Jul 20 '05 #2
"Dan Langille" <us******@YEAH. RIGHT.dvl-software.com.in valid> wrote in
message news:c5******** *************** *********@4ax.c om...
Hi folks,

I found this in some pages:

<td style="border-bottom: 1px solid #000000; border-left: 1px solid
#000000; background-color:#4080A0;f ont-weight: bold; color: #000000;"
class="myclass" >

I've never seen both style and class used in the same element. Is the
common? Which wins? What happens?


This is where the "cascade" rules come into play. IDs have more weight than
CLASSes, but locally-defined styles have more weight than linked
stylesheets, the last instance of style defined overrides a previous
instance, etc., etc.

-- Richard
Jul 20 '05 #3
David Dorward <do*****@yahoo. com> wrote:
I've never seen both style and class used in the same element. Is the
common?

Which wins? What happens?


The style attribute has a higher specificity then external style sheets.


Not necessarily, ID's in an external stylesheet have a higher
specificity than an inline style.
Headless

Jul 20 '05 #4
Headless wrote:
The style attribute has a higher specificity then external style sheets.


Not necessarily, ID's in an external stylesheet have a higher
specificity than an inline style.


Ah, I just did some looking in the spec.

Style attributes have the same specificity as ids, but are considered to be
defined later in the cascade order.

#foo { color: blue; }
<this id="foo" style="color: red;">

would be red BUT

this#foo { color: blue; }
<this id="foo" style="color: red;">

would be blue (as this#foo gets a score of 101, while style="" gets a score
of 100)

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
Jul 20 '05 #5
David Dorward <do*****@yahoo. com> writes:
Style attributes have the same specificity as ids, but are considered to be
defined later in the cascade order.


In the original CSS 2 specification. However, it is changed in the CSS
2 errata, and therefore also in the the CSS2.1 working draft. In
these, inline styles have specificity 1,0,0,0 rather than 0,1,0,0 (as
#id).

I know Opera 7 is based on the CSS2.1 WD, and I think Mozilla is too.
IE 6 gives higher specificity to inline styles as well.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6
Lasse Reichstein Nielsen wrote:
In the original CSS 2 specification. However, it is changed in the CSS
2 errata, and therefore also in the the CSS2.1 working draft. In
these, inline styles have specificity 1,0,0,0 rather than 0,1,0,0 (as
#id).


Insert stock "Why not update the spec at the main page instead of forcing
people to read errata!?" rant.
--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
Jul 20 '05 #7
On Fri, Jul 11, David Dorward inscribed on the eternal scroll:
Insert stock "Why not update the spec at the main page instead of forcing
people to read errata!?" rant.


I'd say it's because the main page belongs to the authoritative
specification (TR), whereas the errata are a work in progress.

Note that the CSS2 TR version from 1998 still clearly states:

"This specification defines Cascading Style Sheets, level 2 (CSS2)."

and:

"The English version of this specification is the only normative
version. "

It does not say: "this specification _as amended by subsequent
errata_". I'd say there's a message in that.

Jul 20 '05 #8
On Thu, 10 Jul 2003 23:00:01 +0100, David Dorward <do*****@yahoo. com>
wrote:
Dan Langille wrote:
I've never seen both style and class used in the same element. Is the
common?


No, thankfully. The style attribute is nasty.


Why? Let's take a recent example I met: some photos of different sizes
to be floated at various places in the text, each photo with a caption.

I would do this by:
- placing photo and caption in a floated DIV;
- styling this by defining the float, padding, border, margin and text
properties in an external stylesheet;
- and setting the width of the floated box in a local style attribute,
as it will be different for every photo. (Or I might place a default
size in the stylesheet and override it locally when necessary.)

How would you do it?

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #9
On Sat, 12 Jul 2003 16:24:56 +0100, Headless <in************ *@dna.ie>
wrote:
Stephen Poley <sb*****@xs4all .nl> wrote:
No, thankfully. The style attribute is nasty.
Why? Let's take a recent example I met: some photos of different sizes
to be floated at various places in the text, each photo with a caption.

....
I used to do the same thing, I've moved those widths to an external
stylesheet because if an image has a caption wider than the image so
that it wraps, I prefer it not to wrap when my external stylesheets are
not used (UA not capable of retrieving my external stylesheets, or
disabled by the user).


With the consequence that every photo needs its own style in the
external stylesheet. Doesn't seem like an attractive option to me.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #10

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

Similar topics

1
1871
by: Rostov | last post by:
I've got a script where I'm trying to toggle the visibility of a div node by a click on an image that is the sibling of the div. So I've got this HTML: <div> <img src="RightPointingTriangle.gif" onclick="openclose(this);"> <span class="title">title</span> <div class="contents"> Hi. This is the contents.
6
3610
by: LRW | last post by:
I have a Javascript that makes a tablerow visible ot invisible, that works fine in InternetExplorer, but in Mozilla it's unresponsive and I get the following Javascript Console error: Error: itemeditrow is not defined Source File: editform.php Line: 45 Below is the Javascript, and a section of the HTML for that tablerow. I don't get it. It looks defined to me. What am I missing?
3
2111
by: joealey2003 | last post by:
Hi all... I included a css file on my html and i need to check some properties. The html is: <style id="myid" src="mycsspage.css"> </style> Now i need something to access it like: alert(document.getElementById("myid").bottomline.color);
21
3963
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
7
3346
by: adam | last post by:
i'm working on a portion of a CMS that allows content-admins to browse a product list, and add individual products into the taxonomy by clicking checkboxes next to categories they might belong in. since the taxonomy is a rather long list, i'm hiding and showing divs for the secondary and tertiary links, so when a user clicks on the checkbox for the parent category, the children appear in a second (and third) div, with checkboxes of their...
3
9257
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to work on FireFox or Netscape. What could be wrong? The function: function setActiveTab(tabNo) {
16
2027
by: Giggle Girl | last post by:
Hi there, I have a nav tree similar to the XP Windows Explorer in behavior. It uses styles to underline a row on mouseover, and change the look of a row when clicked. Currently, it is working fine using CSS/Javascript, by calling functions that underline and highlight by passing in IDs. The problem is, I do not want to pass in IDs. Currently it has one the TDs to be changed, but I may need to add one for images (to change the
4
1366
by: tshad | last post by:
I am trying to set up various grids with different displays and don't want to set each row and column individually. Right now I use the following in my css page: table { border-collapse: separate; border-color:#999999 } th {
53
4653
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code, and .Net2005 code. I'm developing in vb.net 2005. This test sub just reads an input text file, writing out records to another text file, eliminating records that have a '99' in them (it is similar to a CSV file). Some of my concerns are:
1
15321
by: Armin Gajda | last post by:
Hi, I have the following problem: An input field get a border assigned by a style class (e.g. 2px solid red). When the field gets the focus, we set the border to green. element.style.border = "2px solid green"; When the field looses the focus, the border should change back to red.
0
8402
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8315
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8829
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5633
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.