473,698 Members | 2,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CSS display not working (or more likely Im doing something wrong)

I am trying to use DIV tags and a class to hide the DIV and the HTML
within. I will use JavScript to change it from hidden to visible but
that will come later.

Below is the code I am using

<div class="hide">
<tr>
<td nowrap>Name:</td>
<td nowrap>Monty</td>
</tr>
<tr>
<td nowrap>Name:</td>
<td nowrap>Homer</td>
</tr>
</div>

The CSS code required to hide it is:

..hide {
display: none;
}

Unfortunetely, it isnt hidden. It seems to work when I do something
like:

<div class="hide"><p >I am some hidden text</p></div>

Why wont it work for when I try to hide table rows?

Burnsy

Aug 10 '05 #1
4 2233
On 10 Aug 2005 08:31:31 -0700, <bi******@yahoo .co.uk> wrote:
I am trying to use DIV tags and a class to hide the DIV and the HTML
within. I will use JavScript to change it from hidden to visible but
that will come later.

Below is the code I am using

<div class="hide">
<tr>
<td nowrap>Name:</td>
<td nowrap>Monty</td>
</tr>
<tr>
<td nowrap>Name:</td>
<td nowrap>Homer</td>
</tr>
</div>

You are aware that table rows are part of tables?

<table class="hide">
<tr>
<td></td>
<tr>
</table>

Secondly, 'nowrap' is a depricated attribute with html 4.01 (and only available
with old transitional style html):
<http://www.w3.org/TR/html401/struct/tables.html#ade f-nowrap>
Use a style like table.hide td { white-space:nowrap; } or something.

Thirdly, rather than using a class name that describes the wanted visual
behaviour, one should use a class name that makes sense even if the behaviour
gets ignored or has to change in the future. So no 'hide' but rather the why it
has to be hidden.
The CSS code required to hide it is:
.hide {
display: none;
}

Unfortunetely, it isnt hidden. It seems to work when I do something
like:
<div class="hide"><p >I am some hidden text</p></div>

Why wont it work for when I try to hide table rows?


The last code example is valid html. The first (with the table rows in the div)
isn't. You don't know what happens if you write invalid code.

Create valid code and see if the behaviour still is not what you want. Then come
back here and ask again.

Also: providing an URL is almost always the best option, because rendering of
elements can be influenced by things you don't think of now, but others might
spot had they had the whole picture.

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'

Aug 10 '05 #2
> You are aware that table rows are part of tables?

Yes but I would like to hide a selection of table rows within a table.
Sorry, I really should have supplied more code
Secondly, 'nowrap' is a depricated attribute with html 4.01 (and only available
with old transitional style html):
<http://www.w3.org/TR/html401/struct/tables.html#ade f-nowrap>
Use a style like table.hide td { white-space:nowrap; } or something.
Unfortunetely, I have taken a job position that was filled by another
person before me. This is the code I have to work with in the mean
time. Its present throughout the entire page.
Thirdly, rather than using a class name that describes the wanted visual
behaviour, one should use a class name that makes sense even if the behaviour
gets ignored or has to change in the future. So no 'hide' but rather the why it
has to be hidden.


I'd rather stick with the name 'hide'. I can then apply it to other
elements and know that it simply hides that element (well, usually
does, lol). Anyway, thats not really too much of an issue in this case
but I appreciate the tip.

My idea:

What the final outcome will be is where you will click on a link and it
will show / hide a number of table rows within a <div> tag. The idea in
real, will be applied to a 'whats new' page where under every month
heading is a list and links of whats new on the Intranet I work on. As
mentioned previously, I am working with someones old code and it is
quite a large page (hopefully you get the idea why I am wanting to use
some space saving techniques, see working example below) so I would
like to apply this idea without having to retype the page another way
as this would be a lot of fiddly work.

Anyway, here is a simple example of a page that kinda does what I want:

http://www.martynbissett.co.uk/test/test_showhidetr.htm

As you can see, when you click the links it will show / hide the table
row below. This is the exact concept of what I am trying to achieve but
I need it to show / hide a number of rows so my solution was to nest
them within <div> tags. See below for this code:

http://www.martynbissett.co.uk/test/...howhidediv.htm

As you will be able to see, although I have done as intended with the
<div> tags (view source), it doesnt show / hide them. I would like to
know why and how to overcome this (if possible)

Anyway, sorry about the large reply but hopefully this is enough
information. If you have made it this far in the text then your doin
well, lol.

Burnsy

Aug 10 '05 #3
bi******@yahoo. co.uk schreef:
Anyway, here is a simple example of a page that kinda does what I want:

http://www.martynbissett.co.uk/test/test_showhidetr.htm

As you can see, when you click the links it will show / hide the table
row below.


Hmm, this works OK in Explorer, but in Firefox clicking on the links
keeps adding space; the space under the revealed text isn't removed when
you click the link again, and every time you show/hide the text, the
whitespace increases. But if everyone on your intranet uses only IE,
that isn't a problem, of course.

Berna

--
( )_( ) Berna M. Bleeker-Slikker
/ . . \ be***********@g mail.com
\ \@/ / http://www.volksliedjes.nl
Aug 11 '05 #4
Berna Bleeker wrote:
bi******@yahoo. co.uk schreef:
Anyway, here is a simple example of a page that kinda does what I want:

http://www.martynbissett.co.uk/test/test_showhidetr.htm

As you can see, when you click the links it will show / hide the table
row below.

Hmm, this works OK in Explorer, but in Firefox clicking on the links
keeps adding space; the space under the revealed text isn't removed when
you click the link again, and every time you show/hide the text, the
whitespace increases. But if everyone on your intranet uses only IE,
that isn't a problem, of course.


That is because the OP is using display: block for a table row which
should be display: table-row. IE does not understand table-row and is
happy with the non-standards compliant 'block'.

The simple, cross-browser solution is to toggle the display between
'none' and '' so that the row is returned ot its default (table-row for
CSS 2 compliant browsers and whatever for those that aren't).

Here's a modified version that will work correctly in most browsers -
standards compliant or otherwise:
<style type="css/text">

..hide { display: none; }
..show { display: ; }

</style>
<script type="text/javascript">

function showhide(el) {
var elem;
if (document.getEl ementById && (elem = document.getEle mentById(el))){
if ( elem.className ) {
elem.className = ('hide' == elem.className) ? 'show':'hide';
}
}
}

</script>

--
Rob
Aug 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1371
by: Charles May | last post by:
I have a listview which checkboxes containing items to invoice. The Create Invoice button (button1) is disabled unless there are items checked. However, I had to use an if..then..else statement to make it work. My question is, why can I not get it to work using an IIF statement? In the mouseup event of the listview I tried the following methods to achieve the result. This doesn't work
1
1261
by: Chiller | last post by:
Ok, I've implemented a few changes to the code and the bool functions now seem to be functioning correctly; however, I think I'm doing the convertions incorrectly because the values printed out from my TEST_DISTANCE driver haven't converted correctly. I'm possibly using enum incorrectly, so I'd appreciate some assistance with its use. Also, when outputing the Distance objects, numbers are displayed but the value isn't displayed correctly....
6
6576
by: Michael Sparks | last post by:
Hi, I suspect this is a bug with AMK's Crypto package from http://www.amk.ca/python/code/crypto , but want to check to see if I'm being dumb before posting a bug report. I'm looking at using this library and to familiarise myself writing small tests with each of the ciphers. When I hit Crypto.Cipher.ARC4 I've
9
1374
by: Eric Lilja | last post by:
Hello, I have two code snippets I want you to look at. My program compiles without warnings (warning level set to max, gcc 3.4.3) with either snippet but the latter one causes a segfault at run-time. I know it contains non-standard constructs (using the MySql C api) but I wanted to know if it's printf() I'm misuing. Here are the snippets: /* m is of type MYSQL* */ unsigned int code = mysql_errno(m); const char *description =...
4
1577
by: David R | last post by:
Here's the relevant XHTML: ------------------------------------------------------------------------------------- <dl> <dt>Add...</dt> <dd><label for="radSection" ><input type="radio" id="radSection" runat="server" value="1" /> Section</label> <label for="radCategory"><input type="radio" id="radCategory" runat="server" value="2" /> Category</label></dd>
6
1361
by: rwsims | last post by:
This works in firefox, not at all in ie6. I'm not getting any errors, but only the doalert() function works, not the click() function. I'm sure there's something obvious, but I'm just not seeing it. Help would be greatly appreciated. -- Ryan W
9
1729
by: Randy | last post by:
Hi all, I've been working on a simple two column layout for a site, but according to browsershots.org, my desing is not showing up correctly in Win/IE 5.01, 5.5 & 6 ! Please see details here: http://browsershots.org/screenshots/8403b5f07d234613073ae00a03fcbbf9/ Please note that only IE7 got the design right.
5
2910
by: Simon Brooke | last post by:
This is supposed to be a very simple XSL stylesheet to strip styling information out of HTML documents - it could not be more basic. And yet, it doesn't work. I'm obviously getting something very basic wrong and for the life of me I can't see it. Please, somebody, cast your eyes over this and tell me what's wrong! First, the XSL stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"
0
1111
by: Pat | last post by:
Hi Guys, Please help me. I am having a strange issue. Not sure if I am doing something wrong or this is a bug. This is a sample code. This contains 2 text boxes(txtName, txtPhone) and 2 buttons (btnAdd, btnSave) Table(dtCustomers) contains three rows, with customer name "a", "b" and "c". Now I press "btnAdd" button to add a new row. Then I type "d" as name and "123" ad phone number.
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.