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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:37:41+00:00 2026-05-19T15:37:41+00:00

I am writing a simple little nameplate page and am using multiple paragraphs hidden

  • 0

I am writing a simple little nameplate page and am using multiple paragraphs hidden and shown with javascript to get all the sections in one document.
Here is my html:

<header>
<h1><span>Scott Colby</span></h1>
<nav>
    <div id="twitternav"><a href="javascript:showTwitter()">Twitter</a></div>
    <div id="tumblrnav"><a href="javascript:showTumblr()">Tumblr</a></div>
    <div id="flickrnav"><a href="javascript:showFlickr()">Flickr</a></div>
    <div id="facebooknav"><a href="javascript:showFacebook()">Facebook</a></div>
    <div id="linksnav"><a href="javascript:showLinks()">Links</a></div>
    <div id="aboutnav" class="active"><a href="javascript:showAbout()">About Me</a></div>
</nav>
</header>

<div id="content">
<p id="twitter">
    Placeholder text for Twitter
</p>

<p id="tumblr">
    Placeholder text for Tumblr
</p>

<p id="flickr">
    Placeholder text for Tumblr
</p>

<p id="facebook">
    Placeholder text for Tumblr
</p>

<p id="links">
    Placeholder text for Links
</p>

<p id="about" class="active">
    <div id="portrait"><img src="img/portrait.jpg" width="188" height="221" alt="-----" /><br /><span class="credit">Image: &copy; 2011 Jim Thomas</span></div>
    <div>Placeholder text for About Me</div>
</p>
</div>

My CSS:

nav {
    color: white;
    margin: 0 5px -8px 0;
    text-align: right;
    z-index: 1;
}

nav div{
    display: inline;
    margin: 0 0 0 .9em;
    padding: .25em .25em .25em .25em;
    z-index: 1;
}

nav div:hover {
    background: #F77D00;
}

nav div.active {
    background: #FF9900;
}

#content p {
    display: none;
    font-size: 85%;
    z-index: -1;
}

#content p.active {
    display: block;
}

And my javascript:

    function hideAll() {
    document.getElementById('twitter').className = '';
    document.getElementById('twitternav').className = '';

    document.getElementById('tumblr').className = '';
    document.getElementById('tumblrnav').className = '';

    document.getElementById('flickr').className = '';
    document.getElementById('flickrnav').className = '';

    document.getElementById('facebook').className = '';
    document.getElementById('facebooknav').className = '';

    document.getElementById('links').className = '';
    document.getElementById('linksnav').className = '';

    document.getElementById('about').className = '';
    document.getElementById('aboutnav').className = '';
}

function showTwitter() {
    hideAll();
    document.getElementById('twitter').className = 'active';
    document.getElementById('twitternav').className = 'active';
}
function showTumblr() {
    hideAll();
    document.getElementById('tumblr').className = 'active';
    document.getElementById('tumblrnav').className = 'active';
}

function showFlickr() {
    hideAll();
    document.getElementById('flickr').className = 'active';
    document.getElementById('flickrnav').className = 'active';
}


function showFacebook() {
    hideAll();
    document.getElementById('facebook').className = 'active';
    document.getElementById('facebooknav').className = 'active';
}

function showLinks() {
    hideAll();
    document.getElementById('links').className = 'active';
    document.getElementById('linksnav').className = 'active';
}

function showAbout() {
    hideAll();
    document.getElementById('about').className = 'active';
    document.getElementById('aboutnav').className = 'active';
}

Now, I know that’s a lot of code to go through, but it’s pretty simple stuff I think.

Here is my problem: even when the #about p is not active and has display:none (i.e. another section is active and visible), the image and the div with “Placeholder text for About” are both visible. When I investigated this in firebug, it shows something like this:

<p id="about">  </p>
<div id="portrait"><img .... /></div>
<div>Placeholder text for About</div>

Why do the two div’s migrate outside their parent element? How can I make them disappear along with their parent?

  • 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-05-19T15:37:42+00:00Added an answer on May 19, 2026 at 3:37 pm

    The <p> element does not allow block level elements like <div> inside it. When the HTML parser sees the <div> tag, it assumes that the </p> tag has been omitted (it’s optional) and that the p element is complete. Hence the DOM you see with the div elements as following siblings of the p element.

    Tip: It’s always a good idea to validate your HTML before posting a question on SO. Had you done so, the validator would have indicated the error to you.

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

Sidebar

Related Questions

I am writing a simple php registration page using MySQL as the database. I
I'm practising with C, writing simple programs. The little program below should just get
I'm writing a simple templating layer in PHP but I've got myself a little
I'm trying to learn a little more on vectormath through writing a simple ray
I'm writing a simple little application, which is a booking system. In the system
I am writing a little application that performs some simple actions on some specific
I'm teaching myself C++, and in the process I'm writing simple little programs to
I'm writing a simple little game for my kids - it doesn't really matter
I'm writing a simple little ocaml program that reads an algebraic statement in from
I'm writing a simple ini file parser and I'm having a little problem with

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.