Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Can you use the same id in different files

Perhaps I am missing something here, but the earlier tutorials on selectors only deal with cases which use one file. I am aware that you should not use the same id multiple times within the same documet. But, If i have multiple pages for my site, and each page includes:

<h1> title <h1>

can I use <h1 id="title"> on each html file that includes the title? or should I use a class instead?

1 Answer

zentronic
zentronic
7,593 Points

Hello Conah,

Technically it's possible to use the same ID for an element in different files. But id's are made to identify an object clearly, so please use the class attribut when selecting multiple elements.

I hope i could help you! Have a nice day :D