Tribute Project Questions

Hello all–I have completed my tribute project and would like your feedback and suggestions.

I wasn’t sure how best to best use id’s. For example, why use <div id="title"></id> when you can use <title></title>? When I tried <div id="title"></id>, the title showed up on the web page. I used the regular <img> tag instead of <div id=img>. Instead of <image-caption>, I used <figcaption>. Plus, when I tried to use div id’s to change things in CSS, it didn’t work. Can someone explain using id’s with CSS for this challenge?

Also, is my code structured correctly/clean?

Thank you.

Hello! o/

The div is a generic container that you can nest to create a logic structure and they can contain other elements. The question now becomes: How can I target a specific div in my page? By using an id.

<title> is normally used inside the <header> and it belongs to metadata (link, meta, title and style - information about your page) and they are invisible .

<div id="title"></id>
When you write this, you are actually opening a div container uniquely named title (but you are not closing the container) and then you immediately close a tag “id” that you never opened before.

I used the regular <img> tag instead of <div id=img>
The img tag allow you to put an image on screen, instead <div id="img"> creates a container named “img”.

I hope to be helpful in some way :stuck_out_tongue_winking_eye:

1 Like

There are a lot of confusing and buggy information in user stories to this challenge, I would not suggest to rely on them for your future projects. Here are some good practices and rules regarding IDs:

  1. IDs must be unique, therefore using generic IDs, like “title”, “image” or “link” is a quite bad idea
  2. IDs as CSS selectors are very specific and generally, a good practice is not to use such specific selectors
  3. Some people consider IDs as a JavaScript-only selector and they stick to the most popular identifier name convention of JS - camelCase

In general ID of HTML element is somewhat like ID of a person, there are very specific use-cases for them and they surely must be used with care.

1 Like

Thanks for your response! You did indeed help. It’s starting to make sense to me. I’m wondering why I could not change id’s in CSS. I could change classes, though. I’ll have to try again.

Do you mind taking a quick look at my code/page? Thanks again.

Thanks for your answer! Whew, I’m not the only one who thought the user stories were a bit weird and not very in line with the HTML and CSS challenges.

  1. Excellent point. I will always keep this in mind.
  2. Should class be used more often than ID’s in HTML/CSS ?
  3. Alright, I will faceoff with ID’s again when I start learning JS.

I will take your advice and not rely on ID’s for future projects in this unit. (Please feel to take a look at my tribute page if you get a chance.) Thank you!