![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
They let you get away with all sorts of things, but will they continue to do so in the next version? |
|
.boxred, .boxgreen { margin: 10px; } .boxred { background-color: #ff0000; } .boxgreen { background-color: #00ff00; } |
#4
| |||
| |||
|
|
.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. |
#5
| |||
| |||
|
|
On Tue, 05 Aug 2003 07:52:05 +0100, Steve Pugh <steve (AT) pugh (DOT) 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. |
#6
| |||
| |||
|
|
Yes, but which edge? Guessing the meaning of invalid code *wrongly* isn't going to do much for their reputation as a reliable UA. |
#7
| |||
| |||
|
|
On Tue, 5 Aug 2003 08:01:05 +0000 (UTC), "Jukka K. Korpela" jkorpela (AT) cs (DOT) tut.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? |
|
(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 |
#8
| |||
| |||
|
|
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. |
#9
| ||||
| ||||
|
|
Obviously they're both required in XHTML 1.0, but since Netscape 4 predates XHTML this comparison is beginning to get silly. |
|
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. |
|
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. |
#10
| |||
| |||
|
|
On 05 Aug 2003 12:15:30 +0100, Chris Morris <c.i.morris (AT) durham (DOT) ac.uk> wrote: 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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |