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 9275065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:30:05+00:00 2026-06-18T16:30:05+00:00

How can the background be changed to the exact same color when the tab

  • 0

How can the background be changed to the exact same color when the tab is clicked on? Currently, it just remains the same color. Also would it be possible to have the first tab colored the same as the background color of the content area when the page is loaded?

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSS-TABS | CSS-Only "DOM TABS"</title>

<style type="text/css">

    #pagewidth { width: 760px; margin: 0 auto 0 auto; }

    #navigation { margin: 0 10em 0 0; background: #000000; color: #FFFFFF; }
    #navigation li { display: inline; padding: 0 2em 0 2em; }

    .content { background: #CCCCCC; height: 20em; padding: 1em;}

    a { color: #0066FF; }
    a:hover { color: #00CCFF; }
    a:active { font-weight:bold; }

    #container { height: 20em; overflow: hidden; }

</style>

</head>

<body>

<div id="pagewidth">

    <ul id="navigation">
        <li><a href="#c1">Content Block 1</a></li>
        <li><a href="#c2">Content Block 2</a></li>
        <li><a href="#c3">Content Block 3</a></li>
    </ul>

    <div id="container">

        <div class="content">
            <a name="c1" id="c1"></a>
            <h1>Heading 1</h1>
            <p>Here is some content, I hope that you like it!</p>
        </div>

        <div class="content">
            <a name="c2" id="c2"></a>
            <h2>Heading 2</h2>
            <p>Now that you have read content block 1, you can learn more in this block</p>
        </div>

        <div class="content">
            <a name="c3" id="c3"></a>
            <h3>Heading 3</h3>
            <p>In conclusion, content blocks are fun</p>
        </div>

    </div> <!-- end container -->

</div> <!-- end pagewidth -->

</body>
</html>
  • 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-18T16:30:07+00:00Added an answer on June 18, 2026 at 4:30 pm

    You just need a little more HTML, and a little more CSS, like so:

    CSS Added:

    .content .sub{ height: 20em; padding: 1em; }
    ...
    #sub1{ background: blue; }
    #sub2{ background: green; }
    #sub3{ background: yellow; }
    

    And:

    <div class="sub" id="sub1">...</div>
    

    … as wrappers for the tab contents.

    The final page would look like this:

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>CSS-TABS | CSS-Only "DOM TABS"</title>
    <style>
        #pagewidth { width: 760px; margin: 0 auto 0 auto; }
    
        #navigation { margin: 0 10em 0 0; background: #000000; color: #FFFFFF; }
        #navigation li { display: inline; padding: 0 2em 0 2em; }
    
        .content { background: #CCCCCC; }
        .content .sub{ height: 20em; padding: 1em; }
    
        a { color: #0066FF; }
        a:hover { color: #00CCFF; }
        a:active { font-weight:bold; }
    
        #container { height: 20em; overflow: hidden; }
    
        #sub1{ background: blue; }
        #sub2{ background: green; }
        #sub3{ background: yellow; }
    </style>
    </head>
    <body>
    <div id="pagewidth">
    
    <ul id="navigation">
        <li><a href="#c1">Content Block 1</a></li>
        <li><a href="#c2">Content Block 2</a></li>
        <li><a href="#c3">Content Block 3</a></li>
    </ul>
    
    <div id="container">
    
        <div class="content">
            <a name="c1" id="c1"></a>
            <div class="sub" id="sub1">
            <h1>Heading 1</h1>
            <p>Here is some content, I hope that you like it!</p>
            </div>
        </div>
    
        <div class="content">
            <a name="c2" id="c2"></a>
            <div class="sub" id="sub2">
            <h2>Heading 2</h2>
            <p>Now that you have read content block 1, you can learn more in this block</p>
            </div>
        </div>
    
        <div class="content">
            <a name="c3" id="c3"></a>
            <div class="sub" id="sub3">
            <h3>Heading 3</h3>
            <p>In conclusion, content blocks are fun</p>
            </div>
        </div>
    
    </div> <!-- end container -->
    
    </div> <!-- end pagewidth -->
    
    </body>
    </html>
    

    Here is a JSFiddle showing how it works: http://jsfiddle.net/fDk3z/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read this post but I can't get it working: Change Background Color... I
How can I change the BACKGROUND color of the MDI FORM in C#? I
Using AppleScript, how can I change the background color of cells ranging from A3
here is the sample: http://jsfiddle.net/Zg55k/ How can I change css background image and color
How I can change the individual region background color of viewport extjs 4. Here
I have a complex background image and images, that should be on exact positions
I can add several scrollviews with its background colours changed and it works fine.
I am wondering why sometimes I can change the webpage background color and sometimes
I want a widget that behaves like a togglebutton and can have its background
Background I have a BLL DLL that uses NHibernate. I share the same BLL

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.