473,665 Members | 2,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple ID instances

qwe
More curiosity than a real problem, but...

I've been abusing HTML ID attributes slightly.

..box {
margin: 10px;
}

#red {
background-color: #ff0000;
}

#green {
background-color: #00ff00;
}

<div class="box" id="red"></div>
<div class="box" id="green"></div>
<div class="box" id="red"></div>

To get a red box followed by a green box and another red box.

HTML validators complain because id attributes are supposed to be unique,
but the big three browser engines let me get away with it.

What's the "right" way to do this? Should I just have boxred and boxgreen
classes? That seems a little wasteful when I only want to change one
property.

Jul 20 '05 #1
12 15071
qwe <_1*******@yaho o.com> wrote:

I've been abusing HTML ID attributes slightly.

.box {
margin: 10px;
}

#red {
background-color: #ff0000;
}

#green {
background-color: #00ff00;
}

<div class="box" id="red"></div>
<div class="box" id="green"></div>
<div class="box" id="red"></div>

To get a red box followed by a green box and another red box.

HTML validators complain because id attributes are supposed to be unique,
but the big three browser engines let me get away with it.
They let you get away with all sorts of things, but will they continue
to do so in the next version?
What's the "right" way to do this? Should I just have boxred and boxgreen
classes? That seems a little wasteful when I only want to change one
property.


Change red and green to classes and apply multiple classes to the
divs. Some older browsers will not apply either class.

<div class="box red"></div>
<div class="box green"></div>
<div class="box red"></div>

Or use classes as you suggest but give the shared and differeing
properties in different styles e.g.

..boxred, .boxgreen { margin: 10px; }
..boxred { background-color: #ff0000; }
..boxgreen { background-color: #00ff00; }

Or set the background-color of .box to red and just have #green
override it in the one exception.
<div class="box"></div>
<div class="box" id="green"></div>
<div class="box"></div>

The best solution will depend on you actual situation rather than on
the simplified examples being used here.

BTW you should always set a color when you set a background-color.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #2
qwe
On Tue, 05 Aug 2003 07:52:05 +0100, Steve Pugh <st***@pugh.net > wrote:
They let you get away with all sorts of things, but will they continue
to do so in the next version?
Yes; as long as there is competition in the market, the browser that is
least strict will have an edge.
.boxred, .boxgreen { margin: 10px; }
.boxred { background-color: #ff0000; }
.boxgreen { background-color: #00ff00; }


I think that's exactly what I was looking for... thanks. The other examples
were useful too.

Jul 20 '05 #3
qwe <_1*******@yaho o.com> wrote:
.box {
margin: 10px;
}

#red {
background-color: #ff0000;
}

#green {
background-color: #00ff00;
}

<div class="box" id="red"></div>
<div class="box" id="green"></div>
<div class="box" id="red"></div>

To get a red box followed by a green box and another red box.

HTML validators complain because id attributes are supposed to be unique,
but the big three browser engines let me get away with it.

What's the "right" way to do this? Should I just have boxred and boxgreen
classes? That seems a little wasteful when I only want to change one
property.


..box{margin:10 px}
..red{backgroun d-color:#ff0000}
..green{backgro und-color:#00ff00}

<div class="box red"></div>
<div class="box green"></div>
<div class="box red"></div>
Headless

--
Email and filter list: http://www.headless.dna.ie/usenet.htm
Jul 20 '05 #4
qwe <_1*******@yaho o.com> writes:
On Tue, 05 Aug 2003 07:52:05 +0100, Steve Pugh <st***@pugh.net > wrote:
They let you get away with all sorts of things, but will they continue
to do so in the next version?


Yes; as long as there is competition in the market, the browser that is
least strict will have an edge.


Yes, but which edge? Guessing the meaning of invalid code *wrongly*
isn't going to do much for their reputation as a reliable UA.

--
Chris
Jul 20 '05 #5
On Tue, Aug 5, Chris Morris inscribed on the eternal scroll:
Yes, but which edge? Guessing the meaning of invalid code *wrongly*
isn't going to do much for their reputation as a reliable UA.


The problem here is that the kind of author who relies on browser
guessing will optimise their page for the browser that does the most
guessing (YKWIM), and then complain about all the others being
"wrong".

--
"In the hardest of cases, I show them the W3C membership list: as
soon as the customer sees that MS is a member, then everything the
W3C says is good, and typically they even demand conformance with
W3C written into the contract" - (Matthias Esken, freely translated)
Jul 20 '05 #6
qwe <_1*******@yaho o.com> writes:
On Tue, 5 Aug 2003 08:01:05 +0000 (UTC), "Jukka K. Korpela"
<jk******@cs.tu t.fi> wrote:
Really? Meanwhile on Earth, the versions of the most popular browsers have
been getting _stricter_ in the last few years, both as regards to HTML and
Yeah, I thought that would get a bite.

Look at it like this. You're an end-user. Browser A renders your favourite
site perfectly, Browser B shows you a blank page. Which browser will you
use?


Given that I switch browser based on what machine I'm currently using,
I'd probably never have chosen it as a favourite site.
(Example off the top of my head: Netscape 4 is really picky about </td>
tags. Mozilla 1 will correctly render the page if you ignore them.)

<table border="1">
<tr><td>1<td>3< tr><td>2<td>4
</table>


http://www.w3.org/TR/html401/struct/....html#h-11.2.5

End tags for <td> and <tr> are optional in HTML 4. Netscape 4 ignores
the spec and goes wrong, Mozilla 1 follows the spec and gets it right.

Your point?

--
Chris
Jul 20 '05 #7
qwe wrote:
HTML validators complain because id attributes are supposed to be unique,
but the big three browser engines let me get away with it.

What's the "right" way to do this? Should I just have boxred and boxgreen
classes? That seems a little wasteful when I only want to change one
property.


Elements can have multiple classes.

class="box red"

Which would match .red { } AND .box { }

--
David Dorward http://david.us-lot.org/
Which is stupider: Pop-up ads claiming they'll stop spam, or spam claiming
it'll stop pop-up ads? -- Dork Tower
Jul 20 '05 #8
qwe <_1*******@yaho o.com> writes:
On 05 Aug 2003 10:47:13 +0100, in comp.infosystem s.www.authoring.stylesheets
you wrote:
qwe <_1*******@yaho o.com> writes:
(Example off the top of my head: Netscape 4 is really picky about </td>
tags. Mozilla 1 will correctly render the page if you ignore them.)
http://www.w3.org/TR/html401/struct/....html#h-11.2.5

End tags for <td> and <tr> are optional in HTML 4. Netscape 4 ignores
the spec and goes wrong, Mozilla 1 follows the spec and gets it right.


Hmm... you could be right. What about XHTML 1.0? I was under the impression


Obviously they're both required in XHTML 1.0, but since Netscape 4
predates XHTML this comparison is beginning to get silly.

To bring things slightly back on topic with stylesheets, closing all
non-empty elements is very good to avoid Netscape 4 CSS confusion.
it was an XML application, though I confess I didn't test Mozilla's reaction
with the correct doctype in place. One moment...
XML Parsing Error: mismatched tag. Expected: </td>.
Location: http://dinopsis/~cim/xhtmltest
Line Number 9, Column 8:
</table>
-------^

Of course, that was sending it with the application/xhtml+xml content-type.

Sending it as text/html it isn't surprising it treats it as HTML, most
browsers not going to the trouble of downloading (or otherwise
obtaining) the DTD and performing a validation before displaying the
page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<body>
<table border="1">
<tr><td>1<td> 3
<tr><td>2<td> 4
</table>
</body>
</html>

renders as (un?)expected in Mozilla 1.3, IE 6.02 and Opera 7.0, all on Win.
Sent as application/xhtml+xml, IE offered to save
it to disk, and Opera did something similar to Mozilla (except the
error report was a little more helpful).
Possibly I'm missing a "be really anal" switch in one or another of them,
but even if it exists then it's off by default and my point still stands -
browser vendors place "what the author meant to say" over "what the author
really said".
TelepathicML, excellent. It's when they get it wrong that the
problems come in. (previous comments about a certain application
'training' authors for its bugs accepted, though)
Now I come to think about it, that may even be the Right Thing
from a usability POV - hmm.
There is a principle of 'be conservative in what you send, be liberal
in what you accept', but the problem is that if you're the wrong
liberal things get even worse than if you'd rejected it initially.
I just don't see a time when a major browser will refuse to render <br> or
<hr> in an XHTML doc.


XML Parsing Error: mismatched tag. Expected: </br>.
Location: http://dinopsis/~cim/xhtmltest
Line Number 9, Column 3:

The future is now?

--
Chris
Jul 20 '05 #9
qwe
On 05 Aug 2003 12:15:30 +0100, Chris Morris <c.********@dur ham.ac.uk> wrote:
Obviously they're both required in XHTML 1.0, but since Netscape 4
predates XHTML this comparison is beginning to get silly.
Yup.
Sending it as text/html it isn't surprising it treats it as HTML, most
browsers not going to the trouble of downloading (or otherwise
obtaining) the DTD and performing a validation before displaying the
page.
Interesting. I suppose there are no hard and fast rules about what to do
when the content-type and doctype disagree, because they're in seperate
specs.
There is a principle of 'be conservative in what you send, be liberal
in what you accept', but the problem is that if you're the wrong
I was thinking of the law of least surprise, but that fits too.
liberal things get even worse than if you'd rejected it initially.


Unless you hold 90% of the market, of course... then you become a de facto
standard.

The rest snipped because I think you've proved your points pretty
succesfully.

Jul 20 '05 #10

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

Similar topics

1
2205
by: Martin V. | last post by:
Hello, Is the multiple instances capability of SQL2K mature enough for a Production system? We're looking at upgrading our hardware but the proposed solution calls for consolidating two currently separate SQL Server's onto one machine with two CPU's. Of the current two servers, one is for OLTP (~800Mb) and the other for
1
5985
by: Vlad | last post by:
Is there any way to install multiple instances of the same windows service designed with VS.NET 2003? I tried copying the binaries into a separate folder and then copying registry entries for the original service under a new name but the SCM complains that the executable does not have this service implemented. Please note that I need to have distinct instances of executables installed not merely multiple windows services defined within...
11
5294
by: Mike | last post by:
Looking to find any information on how to properly configure multiple instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking for information on how the multiple instance settings should configured to work, how memory is shared or not, etc. I can not seem to find any good links to this information. Thanks, Mike
1
1919
by: Johan | last post by:
If a user happens to open multiple instances of her frontend, what kind of problems can occur? For example, one user reported that she was able to, once or twice, bypass the evaluation procedures that check a new record before it's allowed into the database. She said that this happened on a day when her computer behaved strangely in general. We have not been able to repeat/reconstruct the error, and I wonder if the explanation can be...
11
20946
by: Clark Stevens | last post by:
I just finished a WinForms app in VB.NET. I want to allow the user to be able to run multiple instances of the program like you can with Notepad and Wordpad. The way it is now, once I run the executable I can not run another instance as long as the first instance is running. How can I change this behavior? Thanks.
10
4973
by: John | last post by:
I currently have a Windows Service that runs Transactions that are very Processor/Memory Intensive. I have a requirement to deploy multiple instances of the Web service on the Same server. Each Instance needs to run in its own process. My current approach to this is to put all the logic into a separate "Worker" assembly and install it into the GAC. I'm then going to create Multiple Windows Services (i.e. MyService1, MyService2 etc..)...
1
2976
by: sunil | last post by:
Hello All. I have written a program as an exe that performs some kind of order processing. The program is first configured and then started manually. I have have multiple instances of this program with their own ini file and multiple instances can run simultaneouly. Now what i want to convert the whole thing into a windows ervice that is self starting and reads the configuration from the .ini file(its own) and can be run separately as a...
4
3139
by: Mike | last post by:
Class A public objX I want to create 2 or more instances of Class A and have the same value for objX in all instances. Instance1 of Class A Instance2 of Class A Instance3 of Class A
6
6913
by: Bugs | last post by:
Does anyone have any recommendations on the best way to create multiple instances of the same class when the final number of instances is unknown? For example, I have a class and based on some user actions, I want to create n number instances of those classes, which is obviously unknown at compile time. What is the easiest way to create and then manage these kinds of objects? Using an array seems intuitive but it also seems like it...
0
1597
by: jigsmshah | last post by:
I have a windows service developed in C#.I am reading the connection string from an ini file and also i am reading 3 image file from the bin directory. now the new requirement is that there will be multiple instances of the same windows service running. My concern is that will there be any problem when multiple instances will be reading those above mentioned file.I am not writing to any files in the service. If i try to use lock() when...
0
8438
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
8348
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
8863
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...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7376
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...
1
6187
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
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
1761
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.