Page with react and tailwind-css

Solution retrospective
I tried to use react with this challenge. I've also never used tailwind css so that was a challenge as well. I ended up having to use some utility classes to undo things that it does like line-width. I was kind of hoping I could've just used the default tailwind classes to make such a simple page work.
Hopefully I can get some good input since I feel bad having to change things in the style tag.
Please log in to post a comment
Log in with GitHubCommunity feedback
- P@danielmrz-dev
Hello @MokoPolo!
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
<div>
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.root
withmain.root
.
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 - In order to make your HTML code more semantic, and since that is the main title of the screen, replace the
- @fresnizky
There are two ways in Tailwind to use specific values that don't match any of the classes provided by Tailwind
You can use an arbitrary value, this is useful when you need to use some values a few times, you just use the basic class with the desired value between square brackets []. Let's say you need a font-size of 15px, you just use it like this
<p class="text-[15px]">This content should be 15px</p>
The second option is to create a custom value in
tailwind.config.js
. This will create a new class you can use (or override an existing one), so this is great when you need to reuse the same value in several places. If you want to add a new font-size namedcontent
to be 15px you should add the following to the theme sectionmodule.exports = { ... theme: { extends: { fontSize: { content: '15px' } } } ... }
And then you can use it in the html like this:
<p class="text-content">This content should be 15px</p>
Hope this was helpful, you can check my solutions where I implement both of these approaches.
Marked as helpful
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