Hi! I’m going through the ‘Learn CSS Grid by building a magazine’. And they have used classes to name some elements but I think those class names will not be used again in the file so won’t it be a better choice to use id?
Link for Step #8 of the lesson
Here’s the code till Step #8:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Magazine</title>
<link
href="https://fonts.googleapis.com/css?family=Anton%7CBaskervville%7CRaleway&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
/>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<main>
<section class="heading">
<header class="hero">
<img
src="https://cdn.freecodecamp.org/platform/universal/fcc_meta_1920X1080-indigo.png"
alt="freecodecamp logo"
loading="lazy"
class="hero-img"
/>
<h1 class="hero-title">OUR NEW CURRICULUM</h1>
<p class="hero-subtitle">
Our efforts to restructure our curriculum with a more project-based focus
</p>
</header>
</section>
</main>
</body>
</html>
As you can see there are classes like heading, hero-img, hero-subtitle, hero-title that won’t be used again. So if they aren’t being used again why haven’t they used id for this purpose?
Link for the last step of the lesson
I checked the final html file at the end of the lesson and these classes have not been used again with any other element. So then why haven’t they used id for this purpose? Wouldn’t it make more sense to use id to name elements?