White space handling in XHTML - xhtml

Is there any information on how to correctly handle white spaces in XHTML (1.0 Transitional)? It seems as if XHTML does not use standard XML white space handling.
Edit: Mayby I was a bit unprecise about what I was exactly looking for. I'm more interested in how an element gets rendered than how it would be processed by an XML processor.
For example the following will render with 1 white space inbetween:
<em> em content </em> following text
The situation gets more complicated if the space actually has its own formatting, for example content of the hyperlink content after the hyperlink will have an underlined space at the end of the hyperlink, while content of the hyperlink content after the hyperlink<br /> will not underline the the space.
It seems as if the space is always appended to the previous formatting scope and white spaces are handled over (inline) element begin and end tags. But this is based solely on testing and I was wondering if there is some kind of specification on how excatly this behaves.

From the W3C Recommendation:
4.7. White Space handling in attribute values
When user agents process attributes,
they do so according to Section 3.3.3
of [XML]:
Strip leading and trailing white
space.
Map sequences of one or more
white space characters (including line
breaks) to a single inter-word space.
For whitespace in between tags, see the section 3.2 criteria 9:
3.2. User Agent Conformance
[1-8 snipped]
9. White space is handled according to the following rules. The following characters are defined in [XML] white space characters:
SPACE ( )
HORIZONTAL TABULATION ( )
CARRIAGE RETURN (
)
LINE FEED (
)
The XML processor normalizes different systems' line end codes into one single LINE FEED character, that is passed up to the application.
The user agent must use the definition from CSS for processing whitespace characters [CSS2]. Note that the CSS2 recommendation does not explicitly address the issue of whitespace handling in non-Latin character sets. This will be addressed in a future version of CSS, at which time this reference will be updated.
Also see section C.15:
C.15. White Space Characters in HTML vs. XML
Some characters that are legal in HTML documents, are illegal in XML document. For example, in HTML, the Formfeed character (U+000C) is treated as white space, in XHTML, due to XML's definition of characters, it is illegal.

It seems that there is no real documentation on how white spaces are rendered in XHTML. Here is what I found out by experiment:
White spaces are reduced into a single space even over begin and end tags within the same block
The space will be put into the formatting scope of the containing tag. If it spans two tags it will be added to the first tag.
Spaces at the begin and end of block elements or span elements which are the first child element/ the last child element in their block are ignored.
White spaces outside of block elements are ignored.
This is all I could figure out. It is kind of sad that the XHTML specifiaction does not contain information about rendering of white spaces.

Related

Line Height in SSRS

Is there a way to adjust the line height in SSRS? I have a requirement on a legal document to have a bigger line height.
From what I have read, the Textbox.LineHeight property only affects html. I have converted the text inside the textbox to html, set the LineHeight property, but nothing changed.
I also tried adding custom CSS to the report (using old school line-height: {x} pt; inside a style tag), but to no avail - that isn't supported in the SSRS environment.
Here is an example what I need - How can I achieve this?
Before:
After
Does SSRS even support this?
Edit
Converting the text to an expression and adding a double VbCrLf will not be feasible as I need to only add a partial line height
You could add an expression on the Padding.Bottom property.
=IIF(IncreaseHeight, "20pt", "2pt")
If the text is already multiple lines, format the textbox to accept HTML. Replace the line breaks with a white character in a larger font followed by a <br/> tag.
<span style=""font-size=12pt; color:white;"">|</span><br/>
If your text is all on the same line, do the above for each space in your text. Using a bar "|" should be enough to represent the space between words. If not, use a thicker character.

Inline elements not collapsing whitespace before the end of the tag, in modern browsers?

Example: http://jsfiddle.net/9e81ytwg/
<div>Foo <span> Bar </span> Baz</div>
*{font-size:30px;font-family:monospace}
span{background:red;}
Rendered in legacy browsers:
Rendered in modern browsers:
BEFORE Bar there are TWO spaces, they get collapsed into ONE single space that appears WHITE
AFTER Bar there are TWO spaces, they get collapsed into ONE single space that appears RED
why this difference? and why it's different from how it used to work just few months ago?
Is there a specific spec / point where the rendering changed? I'd have expected it working like it used to in legacy browsers. Or is it a bug?
http://www.w3.org/TR/CSS2/text.html#white-space-model (emphasis mine):
If 'white-space' is set to 'normal', 'nowrap', or 'pre-line'
every
tab (U+0009) is converted to a space (U+0020)
any space (U+0020)
following another space (U+0020) — even a space before the inline, if
that space also has 'white-space' set to 'normal', 'nowrap' or
'pre-line' — is removed.
The behaviour you are seeing is therefore completely correct: all whitespace is collapsed from back to front, and therefore the preceding whitespace is not red (it collapsed into the 'space before the inline') and the trailing one is (as the other spaces collapse into it).
I have no clue which 'legacy browsers' you refer to but likely this was a bugfix in their engine somewhere along the way, as this has been in the standards like this for several years.
Update: the standards were not explicit on this back in 2008 when CSS2 was last updated, and it was explicit in the 2011 CSS 2.1 final drafts. Hence it's not really strange that browsers weren't uniform on how to handle this.

Respect space in code but ignore with CSS?

With CSS can I make a browser ignore the character but respect normal white space?
So this:
Some text More text
Is displayed like this:
Some text More text
Not:
Some text More text
UPDATE There is actually more white space in my code. I need the default behavior where extra white space doesn't get rendered on the page so I dont think I can use white-space: pre or pre-wrap
So this shouldn't be excessively indent before the initial word.
Some text More text
I don't think there's a pure CSS way of doing that, since is an actual character that is different from the whitespace created by the spacebar in a text editor (what gets ignored by HTML renderers). However, depending on how those are appearing, you may be able to use a script that searches for and removes that character wherever it sees it.

XHTML - How can I make a piece of text drop on to a new line or wrap without putting a space in it?

I have a small space in which I would like to put writing. Problem is, if a long word is inputted, it flows off the side because there is no space.
I could do overflow:hidden, but this isn't what I am looking for. Ideally I would like the word to drop to a new line with a - before it.
The word is on a line of its own to begin with so a <br/> will not fix the problem.
word-wrap:break-word in CSS does this (ok, without the - in the newline), but it had some browser issues back when I tried it, so be careful ;).
Second solution is wrapping letters in text (or packets of 3 or 5 letters etc.)in <span></span> so that they'll wrap but have no spaces when fitting the line.
to add the hyphen You could then use jquery and search for elements having certain left offset to prepend hyphens.

asp.net continuous string wrap

Okay, so it seems, for some reason (I might be doing it wrong, obviously), that I have some problem wrapping continuous lines, using Asp.net.
Let's say I have 800 pixels worth of the "m" character, well, my table cell gets extended to that length. I don't want that, I want the cell to automatically break the continuous line after 300px.
To do that, I tried to apply the word-wrap:break-word css style. Didn't work. Now what?
Do I parse the line, to insert explicit linebreaks after a certain number of characters? That doesn't seem very clean to me. Any ideas?
You can insert a <wbr> (little known html element) every few m's. It's not 100% compatible with everything, but it works in most browsers:
<wbr> (word break) means: "The browser may insert a line break here, if it wishes." It the browser does not think a line break necessary nothing happens.
So you would do something like this:
mmmmmmmmm<wbr>mmmmmmmmmm<wbr>mmmmmmmmmmm<wbr> (etc.)
Here's some more info: http://www.quirksmode.org/oddsandends/wbr.html
Do you really have 800px of "m" or is that just test data? If that is real data then yes you will have to create some whitespace in there somewhere. HTML parsers don't wrap text that overflows an element unless that text has spaces in it that allow the text to be wrapped.
If the m's are a test string and do not reflect real data I would suggest you use some dummy text (like Lorem Ipsum) to test with as it has spacing more akin to regular text.

Resources