Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Flexbox

@jahanzaib504

Desktop design screenshot for the Blog preview card coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


I have one question that should I add class or id to every html tag.

Community feedback

Daniel πŸ›Έβ€’ 44,230

@danielmrz-dev

Posted

Hello @jahanzaib-jazy!

Your solution looks great!

I have a couple of suggestions for improvement:

  • In order to make your HTML code more semantic, and since that is the main title of the screen, replace the <h3> with <h1>. Unlike what most people think, it's not just about the size and weight of the text.

πŸ“Œ The <h1> to <h6> tags are used to define HTML headings.

πŸ“Œ <h1> defines the most important heading.

πŸ“Œ <h6> defines the least important heading.

πŸ“Œ Only use one <h1> per page - this should represent the main heading/subject for the whole page. Also, do not skip heading levels - start with <h1>, then use <h2>, and so on.

  • Also, still about semantic HTML, replace your div.post with main.post.

All these tag changes may have little or no visual impact but they make your HTML code more semantic and improve SEO optimization as well as the accessibility of your project.

I hope it helps!

Other than that, great job!

Marked as helpful

0
P

@RevazSologhashvili

Posted

Using class or id tags in HTML actually depends on what you want to create or how you plan to style it. If you want to apply the same style to multiple elements, such as all list items, you can use the same class for all of them. However, you can’t use the same ID for multiple elements since IDs must be unique. With classes, you can also apply multiple styles to a single HTML tag, like class="color-red bg-black".

If you want to apply unique styling to an element, then you can use IDs. IDs are also used for navigation within a webpage. For example, <a href="#idName">Go to this Part</a> allows you to navigate to the section of your website identified by the specified ID.

Remember, IDs have a higher specificity than classes in CSS, meaning that if there are any conflicting styles between classes and IDs, the styles defined under the ID will override the others. Also, while classes can be used multiple times within a document and can be applied to multiple elements, IDs are unique and each one can only be used once within a document. This uniqueness makes IDs very useful for JavaScript manipulation.

Marked as helpful

0

P

@RevazSologhashvili

Posted

So it’s not necessary to add a class or id to every HTML tag. Classes and ids are used for specific purposes:

Classes are used when you want to apply the same styling or behavior to multiple elements. They are also helpful when you want to target elements with JavaScript.

Ids are unique identifiers for elements and should be used when you want to style or manipulate a single, unique element.

You should only add classes or ids when you need to reference the element in your CSS or JavaScript. Adding them to every tag can make your HTML unnecessarily complex and harder to maintain. It’s best to keep your code as simple and clean as possible. 😊

Marked as helpful

0

@jahanzaib504

Posted

Thanks a lot. It was really helpful.@RevazSologhashvili

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord