Is it good practice to use id's instead of classes wherever possible - i.e. where there will only be one instance of an object?
I recently went through my code, trying to replace classes with id's wherever possible, however, when I changed one particular class to an id, the image replacement tag nested within that div stopped working. Why did this happen?
Please can someone clarify what best practice is regarding the use of classes and id's?
Thanks,
IKID's for things that will only occur once, like your header, logo...
classes for things that occur multiple times.
Just be sure that if you change a class to an ID that you replace . with # in your CSSID's for things that will only occur once, like your header, logo...
classes for things that occur multiple times.
Just be sure that if you change a class to an ID that you replace . with # in your CSS
Thanks, this is what I thought, but I couldn't understand why the image replacement stopped working when I changed the parent div from a class to an id? I was using the Leahy/Langridge Method.can you show us a link or some of the code so we can have a look? It sounds like it's something so simple you've just dissmissed it.Thanks, Scragar, but I've fixed it now.
I recently went through my code, trying to replace classes with id's wherever possible, however, when I changed one particular class to an id, the image replacement tag nested within that div stopped working. Why did this happen?
Please can someone clarify what best practice is regarding the use of classes and id's?
Thanks,
IKID's for things that will only occur once, like your header, logo...
classes for things that occur multiple times.
Just be sure that if you change a class to an ID that you replace . with # in your CSSID's for things that will only occur once, like your header, logo...
classes for things that occur multiple times.
Just be sure that if you change a class to an ID that you replace . with # in your CSS
Thanks, this is what I thought, but I couldn't understand why the image replacement stopped working when I changed the parent div from a class to an id? I was using the Leahy/Langridge Method.can you show us a link or some of the code so we can have a look? It sounds like it's something so simple you've just dissmissed it.Thanks, Scragar, but I've fixed it now.