Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:18:51+00:00 2026-06-13T06:18:51+00:00

Alternative to CSS only onclick functioni.html When you click on any of the tabs

  • 0

Alternative to CSS only onclick functioni.html

When you click on any of the tabs it will kick you straight to the start of the tab menu. I cannot use javascript or jquery so cannot use onclick=”false”. Is there a CSS way to prevent this from happening.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:18:52+00:00Added an answer on June 13, 2026 at 6:18 am

    The problem you’re having stems from your use of the CSS :target selector (which requires the #item-1 in the URL to function). Setting href="#item-1" allows the :target selector to function at the cost of putting #item-1 in the URL, which is what causes the page to jump. It’s a vicious catch-22 and there’s no way around it using href attributes.

    The only way I know how to duplicate tab functionality using only CSS is to use a variation of “the checkbox hack” (substituting radio buttons for checkboxes).

    In essence, use a <label>Tab</label><input type="radio" /> element set where you are currently using <a href="">Tab</a> and then set CSS style rules to control visibility of the tab-content div based on the checked property of the radio button.

    Specific to your code:

    input[type=radio] {
       position: absolute;
       top: -9999px;
       left: -9999px;
       /* For mobile, it's typically better to position radio on top of clickable
          area and turn opacity to 0 instead. */
    }
    
    /* Default State */
    .noint11_menu > li > div {
       display: none;
    }
    
    /* Toggled State */
    input[type=radio]:checked ~ div {
       display: block;
    }
    

    will work when your markup is:

    <li id="item-1">
        <label for="toggle-Shipping">Shipping</label>
        <input type="radio" id="toggle-Shipping" name="toggleTabs" checked="checked">
        <div>
            <p>Tab Content: Shipping</p>
        </div>
    </li>
    <li id="item-2">
        <label for="toggle-Payment">Payment</label>
        <input type="radio" id="toggle-Payment" name="toggleTabs">
        <div>
            <p>Tab Content: Payment</p>
        </div>
    </li>
    <li id="item-3">
        <label for="toggle-Returns">Returns</label>
        <input type="radio" id="toggle-Returns" name="toggleTabs">
        <div id="notice">
            <p>Tab Content: Returns</p>
        </div>
    </li>
    <li id="item-4">
        <label for="toggle-Tab4">Tab4</label>
        <input type="radio" id="toggle-Tab4" name="toggleTabs">
        <div>
            <p>Tab Content: Tab4</p>
        </div>
    </li>
    

    Here’s a fiddle demonstrating it: http://jsfiddle.net/ezhDQ/

    Please note in the fiddle, I set <div class="footer"> to be a footer for all tabs, not each tab. This is because your markup uses the id attribute for the Facebook, Twitter, Skype, web, and Favorite images. The purpose of the id attribute is to identify one specific element on the page (meaning the id attribute of each element having one must be unique).

    If you want each tab to have its own footer, change your markup to use the name attribute instead.

    Also, below is your page with completely valid XHTML Transitional markup (which will help in the long run for cross-browser consistency):

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta name="viewport" content="width=device-width;" />
        <link rel="stylesheet" type="text/css" href="http://www.ubreakirepair.com/parts.css" media="screen" />
        <link rel="stylesheet" type="text/css" href="http://www.ubreakirepair.com/ebaysite/handheld.css" media="handheld" />
        <link rel="stylesheet" type="text/css" href="http://www.ubreakirepair.com/ebaysite/font.css" />
        <style type="text/css">
        .noint11_menu > li {
            list-style-type: none;
        }
        input[type=radio] {
           position: absolute;
           top: -9999px;
           left: -9999px;
           /* For mobile, it's typically better to position radio on top of clickable
              area and turn opacity to 0 instead. */
        }
    
        /* Default State */
        .noint11_menu > li > div {
           display: none;
        }
    
        /* Toggled State */
        input[type=radio]:checked ~ div {
           display: block;
        }
        </style>
    </head>
    <body>
        <div id="full">
            <div id="header100">
                <img id="header" alt="Our Logo" src="http://www.ubreakirepair.com/ebaysite/images/ubreakirepairheader.png" />
            </div>
            <div id="noint_box1">
                <table border="0" width="958">
                    <tbody>
                        <tr>
                            <td width="948" height="27" valign="top" class="content4">
                                <div id="tab2" class="css-tabs">
                                    <ul class="noint11_menu">
                                        <li id="item-1">
                                            <label for="toggle-Shipping">Shipping</label>
                                            <input type="radio" id="toggle-Shipping" name="toggleTabs" checked="checked" />
                                            <div>
                                                <p><img id="shippingtable" alt="Shipping Table" src="http://www.ubreakirepair.com/ebaysite/images/shippingtable.png" width="684px" height="242px" /></p>
                                                <div class="footer">
                                                    <img alt="next section" src="http://www.ubreakirepair.com/ebaysite/images/line.png" width="976" height="9" />
                                                    <p>
                                                        <a class="header3" href="http://contact.ebay.co.uk/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=irepair">Please click here if you wish to contact us about this product</a>
                                                    </p>
                                                    <p class="header3">or</p>
                                                    <p class="header3">use one of the links below</p>
                                                        <a href="http://www.facebook.com/ubreakirepair">
                                                            <img name="facebook" alt="Visit us on Facebook" src="http://www.ubreakirepair.com/ebaysite/images/facebook.png" />
                                                        </a>
                                                    <a href="https://twitter.com/ubreak_irepair">
                                                        <img name="twitter" alt="Visit us at Twitter" src="http://www.ubreakirepair.com/ebaysite/images/Twitter.png" />
                                                    </a>
                                                    <a href="skype:ubreakirepair?chat">
                                                        <img name="skype" alt="Open Skype" src="http://www.ubreakirepair.com/ebaysite/images/skype.png" />
                                                    </a>
                                                    <a href="http://www.ubreakirepair.com/contactus.php">
                                                        <img name="web" alt="Contact Us" src="http://www.ubreakirepair.com/ebaysite/images/website.png" style="text-align:center" />
                                                    </a>
                                                    <p>
                                                        <a href="http://my.ebay.co.uk/ws/eBayISAPI.dll?AcceptSavedSeller&amp;mode=0&amp;preference=0&amp;sellerid=irepair">
                                                            <img name="fav" alt="Favorite Us at Ebay" src="http://www.ubreakirepair.com/ebaysite/images/fav.png" />
                                                        </a>
                                                    </p>
                                                </div>
                                            </div>
                                        </li>
                                        <li id="item-2">
                                            <label for="toggle-Payment">Payment</label>
                                            <input type="radio" id="toggle-Payment" name="toggleTabs" />
                                            <div>
                                                <p>Tab Content 2</p>
                                                <div class="footer">
                                                    <img alt="next section" src="http://www.ubreakirepair.com/ebaysite/images/line.png" width="976" height="9" />
                                                    <p>
                                                        <a class="header3" href="http://contact.ebay.co.uk/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=irepair">Please click here if you wish to contact us about this product</a>
                                                    </p>
                                                    <p class="header3">or</p>
                                                    <p class="header3">use one of the links below</p>
                                                        <a href="http://www.facebook.com/ubreakirepair">
                                                            <img name="facebook" alt="Visit us on Facebook" src="http://www.ubreakirepair.com/ebaysite/images/facebook.png" />
                                                        </a>
                                                    <a href="https://twitter.com/ubreak_irepair">
                                                        <img name="twitter" alt="Visit us at Twitter" src="http://www.ubreakirepair.com/ebaysite/images/Twitter.png" />
                                                    </a>
                                                    <a href="skype:ubreakirepair?chat">
                                                        <img name="skype" alt="Open Skype" src="http://www.ubreakirepair.com/ebaysite/images/skype.png" />
                                                    </a>
                                                    <a href="http://www.ubreakirepair.com/contactus.php">
                                                        <img name="web" alt="Contact Us" src="http://www.ubreakirepair.com/ebaysite/images/website.png" style="text-align:center" />
                                                    </a>
                                                    <p>
                                                        <a href="http://my.ebay.co.uk/ws/eBayISAPI.dll?AcceptSavedSeller&amp;mode=0&amp;preference=0&amp;sellerid=irepair">
                                                            <img name="fav" alt="Favorite Us at Ebay" src="http://www.ubreakirepair.com/ebaysite/images/fav.png" />
                                                        </a>
                                                    </p>
                                                </div>
                                            </div>
                                        </li>
                                        <li id="item-3">
                                            <label for="toggle-Returns">Returns</label>
                                            <input type="radio" id="toggle-Returns" name="toggleTabs" />
                                            <div id="notice">
                                                <p>At uBreakiRepair customer satisfaction is paramount. If any item received,
                                                    deemed to be faulty or damaged, it will be replaced or refunded. All repairs
                                                    require specialised skill and we do not hold any responsibility for the
                                                    damage incured in the course of repairing your device. We offer an installation
                                                    service if you are not confident in the repair yourself.</p>
                                                <div class="footer">
                                                    <img alt="next section" src="http://www.ubreakirepair.com/ebaysite/images/line.png" width="976" height="9" />
                                                    <p>
                                                        <a class="header3" href="http://contact.ebay.co.uk/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=irepair">Please click here if you wish to contact us about this product</a>
                                                    </p>
                                                    <p class="header3">or</p>
                                                    <p class="header3">use one of the links below</p>
                                                        <a href="http://www.facebook.com/ubreakirepair">
                                                            <img name="facebook" alt="Visit us on Facebook" src="http://www.ubreakirepair.com/ebaysite/images/facebook.png" />
                                                        </a>
                                                    <a href="https://twitter.com/ubreak_irepair">
                                                        <img name="twitter" alt="Visit us at Twitter" src="http://www.ubreakirepair.com/ebaysite/images/Twitter.png" />
                                                    </a>
                                                    <a href="skype:ubreakirepair?chat">
                                                        <img name="skype" alt="Open Skype" src="http://www.ubreakirepair.com/ebaysite/images/skype.png" />
                                                    </a>
                                                    <a href="http://www.ubreakirepair.com/contactus.php">
                                                        <img name="web" alt="Contact Us" src="http://www.ubreakirepair.com/ebaysite/images/website.png" style="text-align:center" />
                                                    </a>
                                                    <p>
                                                        <a href="http://my.ebay.co.uk/ws/eBayISAPI.dll?AcceptSavedSeller&amp;mode=0&amp;preference=0&amp;sellerid=irepair">
                                                            <img name="fav" alt="Favorite Us at Ebay" src="http://www.ubreakirepair.com/ebaysite/images/fav.png" />
                                                        </a>
                                                    </p>
                                                </div>
                                            </div>
                                        </li>
                                        <li id="item-4" title="click for Tab 4">
                                            <label for="toggle-Tab4">Tab4</label>
                                            <input type="radio" id="toggle-Tab4" name="toggleTabs" />
                                            <div>
                                                <p>Tab Content 4</p>
                                                <div class="footer">
                                                    <img alt="next section" src="http://www.ubreakirepair.com/ebaysite/images/line.png" width="976" height="9" />
                                                    <p>
                                                        <a class="header3" href="http://contact.ebay.co.uk/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=irepair">Please click here if you wish to contact us about this product</a>
                                                    </p>
                                                    <p class="header3">or</p>
                                                    <p class="header3">use one of the links below</p>
                                                        <a href="http://www.facebook.com/ubreakirepair">
                                                            <img name="facebook" alt="Visit us on Facebook" src="http://www.ubreakirepair.com/ebaysite/images/facebook.png" />
                                                        </a>
                                                    <a href="https://twitter.com/ubreak_irepair">
                                                        <img name="twitter" alt="Visit us at Twitter" src="http://www.ubreakirepair.com/ebaysite/images/Twitter.png" />
                                                    </a>
                                                    <a href="skype:ubreakirepair?chat">
                                                        <img name="skype" alt="Open Skype" src="http://www.ubreakirepair.com/ebaysite/images/skype.png" />
                                                    </a>
                                                    <a href="http://www.ubreakirepair.com/contactus.php">
                                                        <img name="web" alt="Contact Us" src="http://www.ubreakirepair.com/ebaysite/images/website.png" style="text-align:center" />
                                                    </a>
                                                    <p>
                                                        <a href="http://my.ebay.co.uk/ws/eBayISAPI.dll?AcceptSavedSeller&amp;mode=0&amp;preference=0&amp;sellerid=irepair">
                                                            <img name="fav" alt="Favorite Us at Ebay" src="http://www.ubreakirepair.com/ebaysite/images/fav.png" />
                                                        </a>
                                                    </p>
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                    <p>&nbsp;</p>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top" class="estimate">
                                <p>&nbsp;</p>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </body>
    </html>
    

    UPDATE

    Here’s one way to have a working horizontal tab strip (also in valid XHTML):

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta name="viewport" content="width=device-width;" />
        <link rel="stylesheet" type="text/css" href="http://www.ubreakirepair.com/parts.css" media="screen" />
        <link rel="stylesheet" type="text/css" href="http://www.ubreakirepair.com/ebaysite/handheld.css" media="handheld" />
        <link rel="stylesheet" type="text/css" href="http://www.ubreakirepair.com/ebaysite/font.css" />
        <style type="text/css">
        li.noint11_menu {
            list-style-type: none;
            width: 10em;
        }
        input[type=radio] {
           position: absolute;
           top: -9999px;
           left: -9999px;
           /* For mobile, it's typically better to position radio on top of clickable
              area and turn opacity to 0 instead. */
        }
    
        /* Default State */
        li.noint11_menu > div {
           display: none;
        }
    
        /* Toggled State */
        input[type=radio]:checked ~ div {
            color: #EEE;
            display: block;
            margin-top: 13px;
            margin-bottom: 5px;
            position: absolute;
            left: 0;
            width: 700px;
            text-shadow: 1px 1px 1px black;
            font-family: 'MuliLight', Arial, sans-serif;
            font-size: 14px;
            text-decoration: none;
            text-align: center;
            padding: 5px 10px;
            background: #0272A7;
            box-shadow: inset 0px 0px 1px #EDF9FF;
            -moz-user-select: none;
            -moz-box-shadow: inset 0px 0px 1px #edf9ff;
            -webkit-box-shadow: inset 0px 0px 1px #EDF9FF;
        }
    
        div.css-tabs ul {
            width: 100%;
            height: 40px;
            position: absolute;
        }
    
        div.css-tabs ul li {
            float: left;
        }
    
        div.css-tabs {
            float: left;
        }
    
        div.footer {
            clear: both;
            position: fixed;
            bottom: 0;
            width: 100%;
        }
    
        div.footer div {
            margin: 0 auto;
        }
    
        </style>
    </head>
    <body>
        <div id="full">
            <div id="header100">
                <img id="header" alt="Our Logo" src="http://www.ubreakirepair.com/ebaysite/images/ubreakirepairheader.png" />
            </div>
            <div id="noint_box1">
                <div id="tab2" class="css-tabs">
                    <ul>
                        <li id="item-1" class="noint11_menu">
                            <label for="toggle-Shipping">Shipping</label>
                            <input type="radio" id="toggle-Shipping" name="toggleTabs" checked="checked" />
                            <div>
                                <p><img id="shippingtable" alt="Shipping Table" src="http://www.ubreakirepair.com/ebaysite/images/shippingtable.png" width="684px" height="242px" /></p>
                            </div>
                        </li>
                        <li id="item-2" class="noint11_menu">
                            <label for="toggle-Payment">Payment</label>
                            <input type="radio" id="toggle-Payment" name="toggleTabs" />
                            <div>
                                <p>Tab Content 2</p>
                            </div>
                        </li>
                        <li id="item-3" class="noint11_menu">
                            <label for="toggle-Returns">Returns</label>
                            <input type="radio" id="toggle-Returns" name="toggleTabs" />
                            <div id="notice">
                                <p>At uBreakiRepair customer satisfaction is paramount. If any item received,
                                    deemed to be faulty or damaged, it will be replaced or refunded. All repairs
                                    require specialised skill and we do not hold any responsibility for the
                                    damage incured in the course of repairing your device. We offer an installation
                                    service if you are not confident in the repair yourself.</p>
                            </div>
                        </li>
                        <li id="item-4" class="noint11_menu" title="click for Tab 4">
                            <label for="toggle-Tab4">Tab4</label>
                            <input type="radio" id="toggle-Tab4" name="toggleTabs" />
                            <div>
                                <p>Tab Content 4</p>
                            </div>
                        </li>
                    </ul>
                </div>
                <p>&nbsp;</p>
                <div class="estimate">
                    <p>&nbsp;</p>
                </div>
            </div>
            <div class="footer">
                <div>
                    <img alt="next section" src="http://www.ubreakirepair.com/ebaysite/images/line.png" width="976" height="9" />
                    <p>
                        <a class="header3" href="http://contact.ebay.co.uk/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=irepair">Please click here if you wish to contact us about this product</a>
                    </p>
                    <p class="header3">or</p>
                    <p class="header3">use one of the links below</p>
                        <a href="http://www.facebook.com/ubreakirepair">
                            <img name="facebook" alt="Visit us on Facebook" src="http://www.ubreakirepair.com/ebaysite/images/facebook.png" width="48" />
                        </a>
                    <a href="https://twitter.com/ubreak_irepair">
                        <img name="twitter" alt="Visit us at Twitter" src="http://www.ubreakirepair.com/ebaysite/images/Twitter.png" width="48" />
                    </a>
                    <a href="skype:ubreakirepair?chat">
                        <img name="skype" alt="Open Skype" src="http://www.ubreakirepair.com/ebaysite/images/skype.png" width="48" />
                    </a>
                    <a href="http://www.ubreakirepair.com/contactus.php">
                        <img name="web" alt="Contact Us" src="http://www.ubreakirepair.com/ebaysite/images/website.png" width="48" />
                    </a>
                    <p>
                        <a href="http://my.ebay.co.uk/ws/eBayISAPI.dll?AcceptSavedSeller&amp;mode=0&amp;preference=0&amp;sellerid=irepair">
                            <img name="fav" alt="Favorite Us at Ebay" src="http://www.ubreakirepair.com/ebaysite/images/fav.png" height="48" />
                        </a>
                    </p>
                </div>
            </div>
        </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Struts - Alternative of <html:errors /> to display error messages in Jsp?
What is firemonkey alternative to VCL Shortcut() function from Vcl.Menus? Didn't find any neither
Is there any generic alternative / implementation for MemoryCache? I know that a MemoryCache
I have the following HTML <li onclick=setServerID(this); class=server-item-item data-server=1 onmousedown=serverHold(this); onmouseup=serverRelease();><span>MyServer</span></li> My JS looks
In the below example, I want to create a CSS rule that applies only
I'm building a theme builder that will dynamically edit a CSS file on-the-fly. I
Lets say you have lots of html, css, js, img and etc files within
I am having trouble getting an alternate-row css class applied to a knockout template
I want to alternate rowcolor in a GridView, using pure CSS, ie: I don't
Alternative Titles (to aid searches) Compressing PNGs Reduce the size of an iPhone Archive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.