473,404 Members | 2,137 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,404 software developers and data experts.

What's better: attribute or style?

Hi,

Going forward, what's better to use

<td height="20">

or

<td style="height:20;">

Has the time come to put everything into style?

Bura
Jul 20 '05 #1
7 2673
"Bura Tino" <bu*****@yahoo.com> wrote:
Going forward, what's better to use

<td height="20">

or

<td style="height:20;">


Given these alternatives, definitely the former, since the latter is
incorrect, and the CSS declaration in it shall be ignored by conforming
browsers - but not all browsers conform, so get quite inconsistent behavior.

But neither of them is really adequate. The preferred way is to use external
style sheets, or at least <style> elements, not style attributes. And for
setting a table cell height, you should normally use the em unit, not
pixels. Finally, table cell widths normally shouldn't be set - data tables
usually work best when you leave the width allocation to browsers, and
layout tables shouldn't be used at all. Well, that's the big picture. There
are situations where layout tables still have some justification. But you
were asking a general question, and the general answer is: neither.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 20 '05 #2

"Jukka K. Korpela" <jk******@cs.tut.fi> wrote in message
news:Xn*****************************@193.229.0.31. ..
"Bura Tino" <bu*****@yahoo.com> wrote:
Going forward, what's better to use

<td height="20">

or

<td style="height:20;">
Given these alternatives, definitely the former, since the latter is
incorrect, and the CSS declaration in it shall be ignored by conforming
browsers - but not all browsers conform, so get quite inconsistent

behavior.

Thank you for such an informative answer. I was hoping to receive a short
discussion in the reply but I am a little bit dissappointed that the latter
is incorrect. Would it be possible to ask, what exactly is incorrect about
it?

As far as not using the style attributes, it sounds like an FAQ. Can you
direct me to a discussion on that?

And finally, and perhaps this should be its own thread, but I am trying to
produce html pages that will print nicely, with disjoint tables aligning
properly, predictable page breaks, etc. That is why am specifying height in
pixels. Now I know that ultimately the user can change his/her fonts and
really screw up my intentions. Does that mean that my intention to produce
printable pages flawed by definition?

But neither of them is really adequate. The preferred way is to use external style sheets, or at least <style> elements, not style attributes. And for
setting a table cell height, you should normally use the em unit, not
pixels. Finally, table cell widths normally shouldn't be set - data tables
usually work best when you leave the width allocation to browsers, and
layout tables shouldn't be used at all. Well, that's the big picture. There are situations where layout tables still have some justification. But you
were asking a general question, and the general answer is: neither.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Jul 20 '05 #3
Bura Tino wrote:
"Jukka K. Korpela" <jk******@cs.tut.fi> wrote in message
"Bura Tino" <bu*****@yahoo.com> wrote:
Going forward, what's better to use

<td height="20">

or

<td style="height:20;">


Given these alternatives, definitely the former, since the latter is
incorrect, and the CSS declaration in it shall be ignored by conforming
browsers - but not all browsers conform, so get quite inconsistent
behavior.


Thank you for such an informative answer. I was hoping to receive a short
discussion in the reply but I am a little bit dissappointed that the latter
is incorrect. Would it be possible to ask, what exactly is incorrect about
it?


There's a unit missing. height:20 doesn't say anything about whether
it's pixel, percent, centimeter, etc.

As far as not using the style attributes, it sounds like an FAQ. Can you
direct me to a discussion on that?
I don't think there's a FAQ about it. Inline styles are simply less
"portable" and harder to maintain than external stylesheets.
And finally, and perhaps this should be its own thread, but I am trying to
produce html pages that will print nicely, with disjoint tables aligning
properly, predictable page breaks, etc. That is why am specifying height in
pixels. Now I know that ultimately the user can change his/her fonts and
really screw up my intentions. Does that mean that my intention to produce
printable pages flawed by definition?


Your implementation is flawed, but it's an attempt at working around
current limitations. Considering current browsers and their generally
crappy printing (not to mention horrible support for @media print
properties) there's no "good", working way for printing large HTML
tables. It works marginally better in Word - if the user can work with
Word files at all.
Matthias

Jul 20 '05 #4
Matthias Gutfeldt <sa************@gmx.net> wrote in message news:<bo*************@ID-16734.news.uni-berlin.de>...
Bura Tino wrote:
"Jukka K. Korpela" <jk******@cs.tut.fi> wrote in message
"Bura Tino" <bu*****@yahoo.com> wrote:Going forward, what's better to use

<td height="20">

or

<td style="height:20;">

Given these alternatives, definitely the former, since the latter is
incorrect, and the CSS declaration in it shall be ignored by conforming
browsers - but not all browsers conform, so get quite inconsistent
behavior.
Thank you for such an informative answer. I was hoping to receive a short
discussion in the reply but I am a little bit dissappointed that the latter
is incorrect. Would it be possible to ask, what exactly is incorrect about
it?


There's a unit missing. height:20 doesn't say anything about whether
it's pixel, percent, centimeter, etc.


Good point, thank you.
As far as not using the style attributes, it sounds like an FAQ. Can you
direct me to a discussion on that?
I don't think there's a FAQ about it. Inline styles are simply less
"portable" and harder to maintain than external stylesheets.

Yes, I agree with this point, especially if you write HTML directly.
However, I work almost exclusively with servets. So for me HTML
maintainence is _not_ issue, but java code maintainence _is_. In my
java code, I set the heights and other parameters (like positioning of
divs) in a single logical place so it is very easy to maintain.

With this in mind, is there still anything wrong with using style
attributes?
And finally, and perhaps this should be its own thread, but I am trying to
produce html pages that will print nicely, with disjoint tables aligning
properly, predictable page breaks, etc. That is why am specifying height in
pixels. Now I know that ultimately the user can change his/her fonts and
really screw up my intentions. Does that mean that my intention to produce
printable pages flawed by definition?
Your implementation is flawed, but it's an attempt at working around
current limitations. Considering current browsers and their generally
crappy printing (not to mention horrible support for @media print
properties) there's no "good", working way for printing large HTML
tables. It works marginally better in Word - if the user can work with
Word files at all.


Suppose I don't want to print, but still want things to align nicely.
For example, I want my data table be as tall as a 300x200 image. Is
that doable in a consistent fashion?

Matthias

Jul 20 '05 #5
On Mon, 10 Nov 2003 07:47:51 GMT, "Bura Tino" <bu*****@yahoo.com> wrote:
Going forward, what's better to use

<td height="20">

or

<td style="height:20;">

Has the time come to put everything into style?


Well, answering what I *think* you wanted to ask: yes, the time has come
when it's better to use CSS rather than HTML attributes for layout.
(With the one exception, that I know of, of the height and width
attributes on images, as this assists the browser in laying out the
page.)

As to what you *actually* asked: your first example is better, because
the second is syntactically incorrect. :-/

And further: it's generally better to use an external stylesheet than
actually place styles inline.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #6
In article <b7**************************@posting.google.com >,
bu*****@yahoo.com (Bura Tino) wrote:

:With this in mind, is there still anything wrong with using style
:attributes?

Umm, not sure what you mean. The "style" attribute is okay in xhtml, but
not all attributes are.

The CSS specs <http://www.w3.org/Style/CSS/> allow for using external
stylesheets, or a style declaration in the head element of your
document, or as an element style attribute. It's tidier to use the
external sheets, convenient to use a declaration, and a quick way to get
something done using the attribute. I usually work "upwards" moving the
attributes to a declaration and finally to an external sheet when I'm
happy with the way things are marked up and styled and I've removed all
the redundancies and so forth.

Using styles to center elements (instead of CENTER) and set fonts is
absolutely necessary if you want to validate your document as strict
xhtml. I've found that working to strict xhtml actually makes designing
a page easier, because the rules are concise and everyone agrees on what
they are; also, it throws your user-agent into "standards compliance
mode" which makes for quicker rendering. It's the way of the future, and
I suggest you work towards separating your content from your style.

He said long-windedly ...
--
Looks like more of Texas to me.
.... Arizona, where the nights are warm and the roads are straight.
Jul 20 '05 #7
Matthias Gutfeldt wrote:
As far as not using the style attributes, it sounds like an FAQ.
Can you direct me to a discussion on that?


I don't think there's a FAQ about it. Inline styles are simply less
"portable" and harder to maintain than external stylesheets.


Added to that a simple style="bla" is not media-specific, so when it
comes to the intention of printing that's especially bad.

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #8

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

Similar topics

5
by: nawfer | last post by:
for to resize and copy original photos into a new directory and to use for a thumbnail gallery on the web; what is better: GD, Netpbm or imagemagick and why? very thank
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
9
by: ForHimself Every Man | last post by:
What's better about Rattlesnakes than Python. I'm sure there's something. What is it? This is not a troll. I'm a snake shooping and I want people's answers. I don't know beans about...
1
by: Arjen | last post by:
Hi, Sometimes I see this: (string)DataBinder.Eval(Container.DataItem, "Answer") And sometimes this: Eval(Container.DataItem, "Answer") What is better (faster/performance) when publishing...
2
by: samcomm | last post by:
Hello All.. I'm a student and studing C++. Could you tell me what can I develop in C++? I konw that C++ can develop almost programs. Just I want to know....
2
by: =?gb2312?B?wNbA1rTzzOzKpg==?= | last post by:
I deal with some text and the result is "ʳ......" (these words are chinese) how to distinguish what is the encoding style of the text? Could some give some experence?
58
by: LuisC | last post by:
What is better for holding small numbers in a program? I know that char uses less memory, but, with 32 or 64 bits systems, there are advantages (such as processing time) in using int instead of...
7
by: Rolf Mander | last post by:
What performs better, theoreticaly? This <? echo date("d",time()); echo date("m",time()); echo date("Y",time()); ?> Or that? <? $time = time();
6
by: ManicQin | last post by:
Let's ignore for a minute design decisions , readability and any other of those parameters , In the most raw form of c++ (purely efficiency if you want) what is better, bloating up a classes or...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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,...
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.