473,394 Members | 1,761 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,394 software developers and data experts.

White space, new lines in tags

What rules deal with attribute values with trailing spaces, or tags or
attribute values with embedded newlines? Examples below: the HREF with
embedded newline, the SRC with trailing spaces, and IMG tag spread over
multiple lines.

<a href="myself.html
">
<img src="/images/picture.gif " width="80"
height="65"
alt="What, me worry?"></a>
Mar 25 '06 #1
13 2671
Harlan Messinger wrote:
What rules deal with attribute values with trailing spaces, or tags or
attribute values with embedded newlines? Examples below: the HREF with
embedded newline, the SRC with trailing spaces, and IMG tag spread over
multiple lines.

<a href="myself.html
">
<img src="/images/picture.gif " width="80"
height="65"
alt="What, me worry?"></a>


White space (including linebreaks) between attributes is not significant,
use it as much as you like - I use this often to keep lines short.

Regarding white space in attribute values: the HTML Spec says
User agents may ignore leading and trailing white space in CDATA
attribute values.
<http://www.w3.org/TR/REC-html40/types.html#h-6.2>
I have not tested this in detail, but I think that most browsers do strip
the white space - I have seen various sites with such links and it seems to
work. But you should not rely on it, some UAs may not do it and encounter a
broken link.

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
Mar 25 '06 #2
Harlan Messinger wrote:
What rules deal with attribute values with trailing spaces, or tags or
attribute values with embedded newlines? Examples below: the HREF with
embedded newline, the SRC with trailing spaces, and IMG tag spread over
multiple lines.

<a href="myself.html
">
<img src="/images/picture.gif " width="80"
height="65"
alt="What, me worry?"></a>


<span id=foo onclick="alert('Don\'t \
forget&nbsp;to include &#x5C;
this')">Click me</span>

Csaba Gabor from Vienna

Mar 27 '06 #3
VK

Harlan Messinger wrote:
What rules deal with attribute values with trailing spaces, or tags or
attribute values with embedded newlines? Examples below: the HREF with
embedded newline, the SRC with trailing spaces, and IMG tag spread over
multiple lines.

<a href="myself.html
">
<img src="/images/picture.gif " width="80"
height="65"
alt="What, me worry?"></a>


Space characters (space, tab, form feed, new line) are not significant
and being collapsed to a single space by parser (unless in <pre>
block).

This is HTML rule equal for all UA's (including Amaya).

You may want to watch instead line breaks and spaces *between* tag
because on some surrent implementations it leads to phantom nodes in
DOM Tree.

Mar 27 '06 #4

Harlan Messinger wrote:
What rules deal with attribute values with trailing spaces, or tags or
attribute values with embedded newlines?


Supposedly not much is significant.

In practice whitespace around the outside of tags sometimes shows up
when you don't want it (particularly <a> in IE).

Also IE5/Mac infamously dislikes extra whitespace inside class
attributes, such as around class names, or doubled spaces between
multiple class names.

Mar 27 '06 #5
In article <11**********************@u72g2000cwu.googlegroups .com>,
"VK" <sc**********@yahoo.com> wrote:
Space characters (space, tab, form feed, new line) are not significant
and being collapsed to a single space by parser (unless in <pre>
block).


Not true in the real world. Even in cases where they are collapsed in
*layout* they aren't collapsed in the *parser*.

--
Henri Sivonen
hs******@iki.fi
http://hsivonen.iki.fi/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Mar 27 '06 #6
VK

Henri Sivonen wrote:
In article <11**********************@u72g2000cwu.googlegroups .com>,
"VK" <sc**********@yahoo.com> wrote:
Space characters (space, tab, form feed, new line) are not significant
and being collapsed to a single space by parser (unless in <pre>
block).


Not true in the real world. Even in cases where they are collapsed in
*layout* they aren't collapsed in the *parser*.


I did really not understand the last opposition. There is not *layout*
issue here, because it is not a layout: these are *indentations* used
in the source code (aka pretty-prints or beautifying) They have not -
and should not have - any effect on layout of anything. Or you mean to
say that after the source code is served to the client, some block on
the client side remembers that say:

<link rel="stylesheet"

type="text/css"

href="foobar.css">

was served with new_line - new_line - space between attributes? Which
one then and for what purpose?

Mar 27 '06 #7
In article <11**********************@i39g2000cwa.googlegroups .com>,
"VK" <sc**********@yahoo.com> wrote:
Henri Sivonen wrote:
In article <11**********************@u72g2000cwu.googlegroups .com>,
"VK" <sc**********@yahoo.com> wrote:
Space characters (space, tab, form feed, new line) are not significant
and being collapsed to a single space by parser (unless in <pre>
block).


Not true in the real world. Even in cases where they are collapsed in
*layout* they aren't collapsed in the *parser*.


I did really not understand the last opposition.


White space between attributes is not preserved in the DOM. White space
in text content is preserved in general--not only inside <pre>. However,
by *default*, white space is collapsed in layout except for <pre>.

--
Henri Sivonen
hs******@iki.fi
http://hsivonen.iki.fi/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Mar 27 '06 #8
How about something like this:

<div id="content" class="example TemplateExample">whatever</div>

How is that handled? Also what is the benefit?
-j

Apr 10 '06 #9
js********@gmail.com wrote:
How about something like this:

<div id="content" class="example TemplateExample">whatever</div>

How is that handled? Also what is the benefit?


That declares a <div> element that belongs to two distinct classes. The
benefit might be some elegance/efficiency in the associated CSS.

--
Jack.
Apr 11 '06 #10
On Tue, 11 Apr 2006, Jack wrote:
js********@gmail.com wrote:
How about something like this:

<div id="content" class="example TemplateExample">whatever</div>

How is that handled? Also what is the benefit?


That declares a <div> element that belongs to two distinct classes.
The benefit might be some elegance/efficiency in the associated CSS.


It might also hide the associated styling from some lesser
browser/versions which don't understand the multiple-class construct.
Whether one considers that a disadvantage or a benefit depends on
one's attitude to web design. (no smiley)

regards
Apr 11 '06 #11
Alan J. Flavell wrote:
On Tue, 11 Apr 2006, Jack wrote:
js********@gmail.com wrote:
How about something like this:

<div id="content" class="example TemplateExample">whatever</div>

How is that handled? Also what is the benefit?


That declares a <div> element that belongs to two distinct classes.
The benefit might be some elegance/efficiency in the associated CSS.


It might also hide the associated styling from some lesser
browser/versions which don't understand the multiple-class construct.


Browsers/versions such as...? I haven't encountered that particular
limitation yet, so I'd like to know where it pops up.
Apr 11 '06 #12
On Tue, 11 Apr 2006, Tony wrote:
Alan J. Flavell wrote:

It might also hide the associated styling from some lesser
browser/versions which don't understand the multiple-class
construct.


Browsers/versions such as...? I haven't encountered that particular
limitation yet, so I'd like to know where it pops up.


I don't have details at my fingertips, but google search for terms e.g

multiple.classes css bugs

suggests, among other things,

http://www.richinstyle.com/bugs/table.html

http://www.pixelsurge.com/experiment/multiplestyles.htm

- which don't necessarily agree with each other; but it seems the
affected browsers are old enough by now that their users may be
presumed to encounter quite enough problems with other people's web
pages that a few missing CSS styles on ours would be of no great
consequence to them. After all, CSS is meant to be optional, by
design.

As ever, YMMV ...

regards
Apr 11 '06 #13
Alan J. Flavell wrote:
It might also hide the associated styling from some lesser
browser/versions which don't understand the multiple-class construct.


IMHE there aren't any browsers that suffer from this.

Counter-examples welcome. I'm sure there are some, but they're not
examples that are going to worry me or make me stop using the multiple
class technique.

Apr 12 '06 #14

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

Similar topics

6
by: Grumble | last post by:
Hello all, I want to read lines from a text file, where each line has the following syntax: token1:token2:token3 There could be white space between tokens and ':'
17
by: Stanimir Stamenkov | last post by:
Is it possible to make two inline elements to appear adjacent stripping any white space appearing in between in the source? Example: <span class="adj">1</span> <span class="adj">2</span>...
20
by: Stephen Poley | last post by:
People in these groups, and on web-pages, not infrequently suggest that it is worthwhile cutting down on white-space and comments in HTML and CSS in order to reduce loading times. I and others have...
38
by: Xah Lee | last post by:
sometimes i wish to add white space in <p> as to achived effects similar to tab. what should i do? using empty image seems the sure way but rather complicated. (and dosen't change size with...
1
by: Amar | last post by:
I have a web form with several fields. Depending on user selection in one combo box, i populate a text box and a check box in one line. For example if the user selects 2 years, then i show the...
3
by: Prince | last post by:
I have some <RequiredFieldValidator> on my page and everything works fine except that there are lots of white spaces between the web server controls that are being validated. I've set the Display...
12
by: JA | last post by:
Is there a way to remove all the white space in the fields? I have been using Find-and-replace - looking for 2 or 3 or 4 or 10 spaces and replacing them with none. I don't want to replace single...
4
by: Don Miller | last post by:
When an ASP.NET 2.0 web page is rendered with multiple web controls hidden from view (.visible=false) there is a noticeable gap between a rendered element (like a table) and the next visible...
15
by: Spiros Bousbouras | last post by:
I'm thinking of adding a command to vim for removing white space from the end of each line of a C source file. Can anyone think of a situation where such white space might be useful ?
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...

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.