File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes height tag is not working correctly in 'body' element. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "height tag is not working correctly in Watch "height tag is not working correctly in New topic

height tag is not working correctly in 'body' element.

sharath kumar reddy karnati

Joined: Jul 23, 2007
Posts: 5
Hi All,

Please find below script in written in HTML

<body height="500px;" style="background-color: yellow;" >
<table width="100%" border="1" cellpadding="0" cellspacing="0" style="background-color: #FFFFFF; border: 2 solid #0000C0">
<td> first </td>
<td> second </td>
<td> three </td>
<td> four </td>

When I run this HTML code it is dislaying yellow background in form and table is showing on top. When I do same thing in JSF with following code


<body style="height:500px" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">

<h:panelGrid width="100%" columns="2" border="0" columnClasses ="column1,column2" >

<hutputText value="User Id:" />
<h:inputText id="userId" value="#{LoginValidation.loginname}" />

<hutputText value=" " />
<h:commandButton value="Login" action="#{LoginValidation.CheckValidUser}" />

<hutputText value="New User?" />
<h:commandLink value="Register Here" action="newuser" />


When I'm executing this script, it is not showing the hight which I mentioned in <body> tag, it is taking default height depending upon the values mentioned in <h:panelGrid>.

In case, if I give height in <h:panelGrid> then it is working fine.

Please help.

Thanks in advance.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

You've got some seriously messed-up HTML/JSF there. You start with <html> but end with <f:view> and your form/f:form construct isn't any better. Also, the HTML body tag goes outside the form tags. In JSF, all the tags have to match up properly and be in their proper places. Actually, that's true in HTML as well, but web browsers are more likely not to complain about bad tags. Though they may display unreliably.

I'm not sure a body tag can have a height attribute, since the height of a web page body is whatever the user sizes the window to be.

When you set dimensions in web page components, they will tend to "stretch" their containing components, which appears to be what you're seeing.
[ July 30, 2007: Message edited by: Tim Holloway ]

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: height tag is not working correctly in 'body' element.
It's not a secret anymore!