473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

table element: vertical expansion: CSS height property?


Hello,

Consider the height property in the code shown below...

I am dissatisfied with the height propery. When I set
it to 100% the table does not fill the entire vertical
space available to the browser. On the other hand, I
could set it to some large value like 780px but that
would be more of a hack than a real solution (when I
resize the browser window to large proportion I can
indeed see that it would be just a hack). So what's
the _right_ way of doing it? I have seen people use
a one pixel image and use the fill-y property just
for this, but there must be a better way! What is
it?

I just want a clean solution to fill the vertical
space in the table 100% of the user agent's height.
Is there such a solution?

Thanks!

Neil

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Table Height</title>
<style type="text/css">
table { background-color: blue; width: 100%;
text-align: center; height: 780px }
</style>
</head>
<body>
<table>
<tr>
<td>
Hello!
</td>
</tr>
</table>
</body>
</html>
Jul 20 '05 #1
4 16282
In article <Pi*************************************@garfield. cs.mun.ca>,
Neil Zanella wrote:
I am dissatisfied with the height propery. When I set
it to 100% the table does not fill the entire vertical
space available to the browser.
Which browser. Did you remember to have
html, body {height:100%;}?¹

height property means height of parent, and if parent (body) is not as
height as viewport, neither will be table
On the other hand, I
could set it to some large value like 780px but that
would be more of a hack than a real solution (when I
resize the browser window to large proportion I can
indeed see that it would be just a hack).
That would be extreamily bad.

This works on Opera 7.2b1, and I think also Opera 5+ and Mozilla. IE
propably don't like your doctype, so it might not work - but IE don't
support XML anyway.
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Table Height</title>
<style type="text/css"> body, html, table {height:100%;padding:0;margin:0} table { background-color: blue; width: 100%;
text-align: center; /* snip */}
</style>
</head>
<body>
<table>
<tr>
<td>
Hello!
</td>
</tr>
</table>
</body>
</html>


[1] if you wan't to use borders on body, you need to use min-height, so
there won't be overflow

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #2
@import "dtd-switch.rant"

*Lauri Raittila* <la***@raittila.cjb.net>:
Neil Zanella wrote:

IE propably don't like your doctype, so it might not work - but IE
don't support XML anyway.
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


Actually IE was fine with the doctype declared, i.e. would render the
document in Standards Compliant Mode (as _HTML), but just like Opera 7.0x
chokes on the XML prolog (unnecessary here btw.), thus Quirks Mode.

--
"Space may be the final frontier,
but it's made in a Hollywood basement."
Red Hot Chili Peppers - Californication
Jul 20 '05 #3
Lauri Raittila <la***@raittila.cjb.net> wrote in message news:<MP************************@news.cis.dfn.de>. ..
In article <Pi*************************************@garfield. cs.mun.ca>,
Neil Zanella wrote:
I am dissatisfied with the height propery. When I set
it to 100% the table does not fill the entire vertical
space available to the browser.
Which browser. Did you remember to have
html, body {height:100%;}?


AHA! I did not know that I could apply the height property to the html and body
elements. Out of curiosity, how did you come to know that? I mean, with html
there are document type definitions and you can see what attributes are allowed
for which elements by examining the <!ELEMENT ... > stuff and then you can
figure out what values the attributes can be set to by again examining
the <!ATTRIBUTE ... > stuff, but there is no DTD for CSS (because CSS
is not an XML application), so how can someone know which properties
apply to which elements?
height property means height of parent, and if parent (body) is not as
height as viewport, neither will be table
On the other hand, I
could set it to some large value like 780px but that
would be more of a hack than a real solution (when I
resize the browser window to large proportion I can
indeed see that it would be just a hack).
That would be extreamily bad.


Exactly. Sadly several sites still do this (perhaps because they do
not know about the alternative you describe above).
This works on Opera 7.2b1, and I think also Opera 5+ and Mozilla. IE
propably don't like your doctype, so it might not work - but IE don't
support XML anyway.


Did you try a browser upgrade (http://www.microsoft.com/ie/).
Personally, I like mozilla though.
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Table Height</title>
<style type="text/css">

body, html, table {height:100%;padding:0;margin:0}
table { background-color: blue; width: 100%;
text-align: center; /* snip */}
</style>
</head>
<body>
<table>
<tr>
<td>
Hello!
</td>
</tr>
</table>
</body>
</html>


[1] if you wan't to use borders on body, you need to use min-height, so
there won't be overflow


Could you please elaborate on this footnote?

Thanks!

Neil
Jul 20 '05 #4
Neil Zanella wrote:
so how can someone know which properties
apply to which elements?


By reading the CSS spec: <http://www.w3.org/TR/REC-CSS2/propidx.html>

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)

Jul 20 '05 #5

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

Similar topics

1
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
3
by: kAldam | last post by:
I am currently using IE 6.0 and 5.5 and the scenario is the following. I have a span that contains text, and the span is beign contained by a table cell (this is the way thing need to be in my...
1
by: dumblede | last post by:
Hello fellows, i would like to center a 800px wide 600px high content area without using frames. I have "come up" with the following solution so far. It works under IE 6.0, Firefox 1 (under...
1
by: R0bert Nev1lle | last post by:
Here's my next IE challenge (or frustration). It deals with the overflow attribute. Overflow property was a challenge on my page since the page emulates position fixed for IE. The present...
2
by: Stanimir Stamenkov | last post by:
I'm trying to clear some sizing issues relative to the initial containing block and the root document element. The sample document I'm trying with: http://stanio.info/viewport_fill.html ...
4
by: eomer | last post by:
I would like my table header to have a border on the bottom. What I have written works in Mozilla (1.7.12) but not IE (6). I have included the snippet of html and the snippets of CSS. Any...
1
by: Bart Lateur | last post by:
I'm trying to put a utton at the bottom (right) of a TD cell, irrespective of what else is in there. Usually, with other HTML block elements, we're told to use position: relative on the...
9
by: dli07 | last post by:
Hello, I'm trying to convert a piece of code that creates a dynamic vertical resizing bar in a table from internet explorer to firefox. It's based on a post from...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.