Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Set navigation tab as selected on page load.

Featured Replies

Hello, so im using fake tabs on my site.

 

I have a navigation on each page that consists of 3 items.

 

I want to be able to set the tab to be selected on load, on each of the different pages so it looks like the page is in that tab.

 

Heres my html:

 

<ul id="tabs">
   <li><a href="index.php" title="tab1">Online Store</a></li>
   <li><a href="#" title="tab2">About</a></li>
   <li><a href="#" title="tab3">FAQ's</a></li>
</ul>

 

css:

 

#tabs
{
 overflow: auto;
 width: 100%;
 list-style: none;
 margin: 0;
 padding: 0;
}

#tabs li
{
   margin: 0;
   padding: 0;
   float: left;
}

#tabs a
{
background-color:#000;
   color: #fff;
   float: left;
   font: bold 12px/35px 'Lucida sans', Arial, Helvetica;
   height: 40px;
   padding: 0 30px;
   text-decoration: none;
}

#tabs a:hover
{
background-image:url(http://subtlepatterns.com/patterns/concrete_wall.png);
}

#tabs a:focus
{
   outline: 0;
}

#tabs #current a
{
background-image:url(http://subtlepatterns.com/patterns/concrete_wall.png);
   color: #fff;
}

 

In this one, i want the 'about' tab to have the selected state when it is on the page.

If I understand you correctly, and you just simply want to set the 'active' tab. Just modify your code slightly to the following:

 

#tabs a#current
{
       background-image:url(http://subtlepatterns.com/patterns/concrete_wall.png);
   color: #fff;
}
​

 

<ul id="tabs">
   <li><a href="index.php" title="tab1">Online Store</a></li>
   <li><a href="#" title="tab2" id="current">About</a></li>
   <li><a href="#" title="tab3">FAQ's</a></li>
</ul>​​​​​​​​

 

So whichever tab link has the id "current" they will be displayed as 'active'

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.