1

I have a homepage with a navigationBar on top of the Viewport contains two buttons.

One is the default selected home button which calls/displays home.html. The other for example is Ubuntu which calls UbuntuTutorial.html.

When home is selected, the home-buttons bottom-border is colored while the bottom-border from Ubuntu-button is transparent to show the user that he is actually at the home-section of my website

Now, from a professional view, is it a common pattern to create two nearly similar CSS where the only difference is the colored bottom-border of the clicked button (i.e home or ubuntu) or, which I would prefer, fetch the current displayed html-file and color the bottom-border of the specific button with js... avoiding multiple css where just one line differs. (But also keeping in mind that some(high amount, low amount?) of user disabled js..)

Everything is kept, in my opinion, professional. I am using external CSS and external JS-Files.

asked Apr 3, 2015 at 12:21

1 Answer 1

4

The usual solution in this situation is to have a selected class that defines the style of a button that represents the current page - i.e. a different color for the bottom border.

When the current page changes, use JS to remove the selected class from all buttons and add it to the one that was just clicked.

answered Apr 3, 2015 at 13:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.