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

Dropdown navigation using html, css and vanilla javascript

Akanksha 80

@akankshav108

Desktop design screenshot for the Intro section with dropdown navigation coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


Can someone tell me what is the difference when we do element.style.display = "block"; vs element.classList.add("show") where show is css class => .show{ display:block; }. Why do these two behave differently?

Also if you go through my code, please let me know if there is anything I can improve in HTML, CSS or JavaScript. I welcome all suggestions.

Community feedback

@Rexer-Glitch

Posted

There shouldn't be any difference between the 2 approaches. Though I would prefer using classes to change styles since this obeys the separation of concerns - Javascript should be only for logic, not for applying styles. It's a better approach in my experience.

Marked as helpful

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