Age calculator with html, css, and jquery

Solution retrospective
Here is my completed project of the age calculator.
I want to ask everyone how you included the leap year in your calculations. Any suggestions?
Please log in to post a comment
Log in with GitHubCommunity feedback
- @AlfredoPegueroC
Hello, @vernonroque
With the next function, you can retrieve the days of each month.
function daysInMonth(month, year) { return new Date(year, month, 0).getDate(); }
I hope it helps.
Marked as helpful - @Ezekiel225
Hello there 👋 @vernonroque.
Good job on completing the challenge !
Your project looks really good!
I have suggestions about your code that might interest you.
Consider adding a min-height of 100vh to the body element so as to centralize your project.
body { min-height: 100vh; align-items: center; display: flex; justify-content: center; }
I hope it helps!
Other than that, great job!
Happy coding.
Marked as helpful - P@danielmrz-dev
Hello
Your solution looks great!
I have two suggestions for improvement:
- Use
<main>
to wrap the main content instead of<div>
.
📌 Tags like
<div>
and<span>
are typical examples of non-semantic HTML elements. They serve only as content holders but give no indication as to what type of content they contain or what role that content plays on the page.This tag change does not impact your project visually and makes your HTML code more semantic, improving SEO optimization as well as the accessibility of your project.
- Also, using
margin
is not the best option to center an element. Here's a very efficient (and better) way to place an element in the middle of the page both vertically and horizontally:
📌 Apply this to the body (in order to work properly, don't use position or margins):
body { min-height: 100vh; display: flex; /* it works with grid too */ justify-content: center; align-items: center; }
I hope it helps!
Other than that, great job!
Marked as helpful - Use
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