Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL -> HTML - zero cellpadding / cellspacing impossible?

Status
Not open for further replies.

allywilson

Technical User
Nov 27, 2002
157
GB
I've been coming across this problem for a while now and it's part of the reason I don't fully use XML/XSL for web designing at the moment...

Basically the problem is that when I have the following in my XSL document <table cellspacing="0" cellpadding="0">... the output doesn't actually look like no cellspacing/cellpadding. It DOES in internet explorer, but in every other browser I've tried it seems to give it some spacing/padding. I mainly use firefox (doesn't everyone these days?) by the way.

It's not that it's ignoring the attributes, but it's giving them a value other than zero. If I increase it to 1 or 2 then you can see the difference, if I change it to -1 or -2 it doesn't help.

It's only when used in an XSL document it does this however. If you wrote that same line in a plain HTML doc it'd work fine. Now...I know it's not my browser/system 'cause I've got 2 dual-boot PCs (XP and Gentoo on one, 2K and Mandrake on another!).

The only reason I can think of is that IE displays it fine due to it not really caring if it conforms to W3 standards or not...but others do. Surely there must be a workaround for this? I've tried as much as I can think of concerning HTML that might help.

I tried putting the attributes in an XML doc, and calling them forth that way as well as actually putting the attributes in myself within the XSL doc.

I can't be the only person who's noticed this can I? I mean - firefox is a pretty damn popular browser these days - so more and more websites will be looking dodgy, as well as web designers getting more and more frustrated!

Please, please, please, put me out of my misery!

~A~
 
Are you using a valid doctype? This is probably the cause. Post an example of XSL you're using.
 
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl:eek:utput method="html"/>

<xsl:template match="/">


That's the top of my XSL doc. I didn't have the xsl:eek:utput before yesterday, just added it to see if it helps - didn't do anything.

Does it look good/bad?
 
IE allows a lot of sloppy code to be presented. This is good in one sense, as you can easily and quickly develop. However, it can be a real pain in the ass when you need to do something specific and can't work out where you're going wrong. Most of the other browsers require a valid doctype to make sure everything is how it should be.

What version/type of html are you using?

To output XHTML strict, for instance, you need to use:

Code:
<xsl:output method="xml" doctype-system="[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[/URL] doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
Then run your output code through the validator at
 
I've not specified the version of HTML within the XSL document, so I'm assuming it's defaulting to HTML 4.01 (the last one created?)

When I add that xml:eek:utput code you added all I get is text in a row. No tables, images or anything.

 
You code won't work because it's not XHTML (that particular DOCTYPE I gave as an example).

If you don't specify a DOCTYPE, you're at the mercy of the browser implementation. If you really want a cross-browser HTML solution, you MUST specify a DOCTYPE. It's also very advisable to make sure your code validates.

See this for more DOCTYPE info:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top