How to Use the Show/Hide Behavior in Dreamweaver CS3

It is easy to show and hide web page elements if you know how to use Dreamweaver’s Show/Hide behavior.  In this tutorial I will show you how to show and hide two different elements.

First, you need to set up the links and and CSS IDs:

  1. Create the links to show the elements.  Use “javascript:;” as the href (this gives you an empty link that can have Javascript attached to it).
  2. Create CSS IDs for the elements you will show and hide.  Style them how you want, but set visibility to hidden if you want to hide them when the page loads.
#showOne {
	width: 250px;
	position: absolute;
	left: 250px;
	top: 72px;
	border: 1px dotted #CC0000;
	visibility: hidden;
}
#showTwo {
	width: 250px;
	position: absolute;
	left: 250px;
	top: 110px;
	border: 1px dotted #0033FF;
	visibility: hidden;
}

Next, create the div tags for the hidden elements.  You can create these divs by choosing Insert (menu) > Layout Objects > div tag.  Choose where you want the div tag to be placed, then choose the appropriate ID.

Dreamweaver Show-Hide Elements

So your final HTML in the body tag should look like:

<a href="javascript:;">Use this link to show information 1</a>
<a href="javascript:;">Use this link to show information 2</a>
<div id="showOne">Content for  id "showOne" Goes Here</div>
<div id="showTwo">Content for  id "showTwo" Goes Here</div>

Now place your cursor in the first link, and select the plus (+) in the Behaviors panel then click on “Show-Hide Elements.”

Show Hide Elements in Dreamweaver

Next, select the element(s) that you want to show and select the element(s) that you will hide; click OK. You may already have these elements hidden, but this allows for hiding when another hide/show link is clicked.

Dreamweaver Show-Hide Elements

You should now have an OnClick event showing in the Behaviors panel when your cursor is in the first link.

Dreamweaver Show-Hide Elements

Now repeat the previous steps with link #2. Just put your cursor in link #2, select Behaviors “Show-Hide Elements,” and set #showOne to hide and #showTwo to show. This is the opposite of the previous link.

Dreamweaver Show and Hide

Save your page, view it in your browser, click on the links and you should be seeing your hidden elements hiding and showing. Neat, huh?

Dreamweaver Show-Hide ElementsShow and Hide Web Page elements
This entry was posted in Web Design, Web Design Best Practices and tagged . Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

3 Comments

  1. sachin
    Posted January 14, 2009 at 2:13 am | Permalink

    I will be thankful if you sent more behaviours to my email id

  2. Posted March 5, 2009 at 11:10 am | Permalink

    this tutorial was extremely helpful!! it solved an issue i’ve had for some time, thank you!!
    I have many divs to show/hide but i have one question. How do i get one of those divs to “show” when the page loads?
    Thank you for your help!

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">