vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   'ID already defined' Problems (https://vborg.vbsupport.ru/showthread.php?t=61556)

assassingod 02-14-2004 07:29 PM

'ID already defined' Problems
 
Does anyone know why I cant use something like:
Code:

<div id="headerfont">Hello blah</div>
Here is some filler text
<div id="headerfont">hello again!</div>
moore

In XHTML? I get this error when validating:
Quote:

ID "headerfont" already defined
This is very annoying because I need to use that id twice (and more times)

Anyway round it?

Dean C 02-14-2004 08:17 PM

Have you checked in your CSS file that it hasn't been defined twice?

assassingod 02-14-2004 08:28 PM

Yes. My CSS is completely valid.

Andreas 02-14-2004 08:41 PM

IDs must be uniqe ... see W3C XHTML Documentation

Quote:

The values of these attributes must be unique within the document,
If you use one ID more then once within a document you will run into problems when using JavaScript/DOM.

assassingod 02-14-2004 08:48 PM

So what's a way round it? I need to use the ID twice.

Andreas 02-14-2004 08:56 PM

You can't ;)

Why do you need this ID twice? For CSS?

assassingod 02-14-2004 08:59 PM

Well I want to use the ID which is used by CSS for font title - and since there are many of them I want to use it more than once (unless im missing something?)

Andreas 02-14-2004 09:23 PM

Quote:

Originally Posted by assassingod
Well I want to use the ID which is used by CSS for font title

I don't understand that ...
Can you post an example of the CSS you want to apply/use?

Chroder 02-14-2004 09:26 PM

Quote:

Originally Posted by KirbyDE
I don't understand that ...
Can you post an example of the CSS you want to apply/use?

When you define CSS with a "#", you use it on an HTML tag with the ID attribute

Code:

#headerfont { color: red; }

<span id="headerfont">esfdsfds</span>


Andreas 02-14-2004 09:31 PM

@Chroder
I do know how to apply CSS to IDs - thanks ;)
But I don't know what assassingod want's to achieve ...

#id CSS is for central formatting a single element (you could also just do that using style="..").

If he want's CSS for many element's he would use a class.
So I don't get why he needs multiple elements with the same ID, as this doesn't make sense to me?

assassingod 02-14-2004 10:34 PM

Chroder said it fine, except I want to be able to use
Code:

<div id="headerfont">esfdsfds</div>
As many times as I want without getting that 'ID already defined' error.

Andreas 02-14-2004 10:47 PM

This is not possible without breaking XHTML 1.0 rules :)

And I still don't understand WHY you need multiple elements with the same ID ...

Code:

<style type="text/css">
.headerfont {
  font-family: Comic Sans MS;
  color:  red;
  font-weight: bold;
}
</style>

[...]

<div class="headerfont">This is one text in bold, red, Comic Sans MS</div>
<div class="headerfont">And another one</div>
<div class="headerfont">A third one</div>
<div class="headerfont">A fourth one ... does this get boring? ;)</div>


assassingod 02-14-2004 10:49 PM

Because i'll be implenting it into a system. So the output of the script will be:
Code:

<div class="whatever">
here is some text blah blach blah
<div>

And that code will be loop'd, so obviously there is going to be more than 1 result, ergo more div tags.

Andreas 02-14-2004 10:53 PM

Well, in the code you just posted you are using class, so where is your ID problem?

Where do you need multiple elements with the same ID, that's what I don't understand?

assassingod 02-14-2004 10:58 PM

Alright, let me try another way:)

Chroder 02-14-2004 11:23 PM

Quote:

Originally Posted by KirbyDE
@Chroder
I do know how to apply CSS to IDs - thanks ;)
But I don't know what assassingod want's to achieve ...

lol Sorry ;) I thought you were confuzzled :nervous:

Quote:

#id CSS is for central formatting a single element (you could also just do that using style="..").
I never knew that ;) I think I've been using ID's for multiple items as well.

[high]* Chroder takes a note[/high]

assassingod 02-15-2004 01:39 AM

Ok i've fixed it now - thanks:D


All times are GMT. The time now is 05:02 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01236 seconds
  • Memory Usage 1,747KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (17)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete