473,888 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strip white space

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>
<span class="adj">3</span>

--
Stanimir

Jul 20 '05 #1
17 9139
Stanimir Stamenkov <s7****@netscap e.net> wrote:
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>
<span class="adj">3</span>


Not 100% sure what you mean, but does this do it?

<span class="adj">1</span><span class="adj">2</span><span
class="adj">3</span>

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #2
Steve Pugh wrote:
Stanimir Stamenkov <s7****@netscap e.net> wrote:
Is it possible to make two inline elements to appear adjacent
stripping any white space appearing in between in the source?


Not 100% sure what you mean, but does this do it?

<span class="adj">1</span><span class="adj">2</span><span
class="adj">3</span>


:-) Yeah, but I've asked about the case where there's (think of it
like: there should be) a white space between the elements in the source.

--
Stanimir

Jul 20 '05 #3
Stanimir Stamenkov wrote on 04 nov 2003 in
comp.infosystem s.www.authoring.stylesheets:
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>


<style>
.adj {font-size:40pt;}
.outer {font-size:0;}
.corr {margin-left:-12px;}
</style>

<span class="adj">1</span><span class="adj">2</span>

<br>

<span class="outer">
<span class="adj">1</span>
<span class="adj">2</span>
</span>

<br>

<span class="adj">
<span class="adj">1</span>
<span class="adj corr">2</span>
</span>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4
Stanimir Stamenkov <s7****@netscap e.net> wrote:
Steve Pugh wrote:
Stanimir Stamenkov <s7****@netscap e.net> wrote:
Is it possible to make two inline elements to appear adjacent
stripping any white space appearing in between in the source?


Not 100% sure what you mean, but does this do it?

<span class="adj">1</span><span class="adj">2</span><span
class="adj">3</span>


:-) Yeah, but I've asked about the case where there's (think of it
like: there should be) a white space between the elements in the source.


Fix whatever is the cause of the whitespace in the source.

..adj {float: left;] works for your simple test case, but probably
isn't appropriate for whatever real world problem you're trying to
solve.

I thought about display: run-in; but that doesn't seem to be the
solution (not supported by IE, has no effect in this case in Moz 1.5,
works for the 2 and 3 but causes the 1 to vanish in O7.21).

A negative margin-left is, of course, the brute force approach and is
likely to cause as many problems as it solves.

I think that any solution will depend on what else is in the
surrounding markup. The problem is more complex if the code snippet
provided is preceeded and/or followed by text than if it is alone
inside a block element.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #5
Steve Pugh wrote:
Stanimir Stamenkov <s7****@netscap e.net> wrote:
Steve Pugh wrote:
<span class="adj">1</span><span class="adj">2</span><span
class="adj">3</span>
:-) Yeah, but I've asked about the case where there's (think of it
like: there should be) a white space between the elements in the source.


Fix whatever is the cause of the whitespace in the source.


There's nothing to fix - the data should contain the white space. I
want to have such visual style presentation where this white space
doesn't appear, just like I could hide certain (non-white space)
elements (the 'display' property).
.adj {float: left;] works for your simple test case, but probably
isn't appropriate for whatever real world problem you're trying to
solve.
I've though of floats too, but then I don't know the height of the
inline element boxes and I want them baseline aligned.
I thought about display: run-in; but that doesn't seem to be the
solution (not supported by IE, has no effect in this case in Moz 1.5,
works for the 2 and 3 but causes the 1 to vanish in O7.21).

A negative margin-left is, of course, the brute force approach and is
likely to cause as many problems as it solves.
Yeah, negative margins are pretty relative because there's no unit
to specify exact 1 space width for the current element's font.
I think that any solution will depend on what else is in the
surrounding markup. The problem is more complex if the code snippet
provided is preceeded and/or followed by text than if it is alone
inside a block element.


I though there may be something which I've missed from the CSS specs
about stripping/collapsing white space, that's why I've given such a
generic example.

BTW, the example which Evertjan. gave in another reply with
'font-size: 0' on the parent element - almost did it :-) , though IE
and Opera still leave a pixel space.

--
Stanimir

Jul 20 '05 #6
Stanimir Stamenkov <s7****@netscap e.net> wrote:
Steve Pugh wrote:
Stanimir Stamenkov <s7****@netscap e.net> wrote:
Steve Pugh wrote:

<span class="adj">1</span><span class="adj">2</span><span
class="adj">3</span>

:-) Yeah, but I've asked about the case where there's (think of it
like: there should be) a white space between the elements in the source.
Fix whatever is the cause of the whitespace in the source.


There's nothing to fix - the data should contain the white space. I
want to have such visual style presentation where this white space
doesn't appear, just like I could hide certain (non-white space)
elements (the 'display' property).


The display property is exactly what you should be using.

<span class="adj">1</span><span class="foo">
</span><span class="adj">2</span><span class="foo">
</span><span class="adj">3</span>

..foo {display: none;}

The white space is part of the data, as you say, and not just an
artifact of how you format the source code. Therefore any display of
the whitespace/data should be handled by marking up that
whitespace/data.

Though I am curious what this data is that has meaningful whitespace
in it, but which doesn't lose meaning when that whietspace isn't
displayed.
BTW, the example which Evertjan. gave in another reply with
'font-size: 0' on the parent element - almost did it :-) , though IE
and Opera still leave a pixel space.


I didn't know whether that would work for you because I didn't know
whether there was text to either side of the spans in your real data.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #7
Steve Pugh wrote:
The white space is part of the data, as you say, and not just an
artifact of how you format the source code. Therefore any display of
the whitespace/data should be handled by marking up that
whitespace/data.

Though I am curious what this data is that has meaningful whitespace
in it, but which doesn't lose meaning when that whietspace isn't
displayed.
It's a separating space. An application could process it whatever it
wants. :-)

I though more of a "generic" way (if CSS provides such) to suppress
the white space as a text node (in the DOM means).

Just like this:

<p>
<span>
text
</span>
</p>

A HTML application should strip the leading and trailing space but
this can't be expressed with CSS (as far as I find out).
Stanimir Stamenkov <s7****@netscap e.net> wrote:
BTW, the example which Evertjan. gave in another reply with
'font-size: 0' on the parent element - almost did it :-) , though IE
and Opera still leave a pixel space.


I didn't know whether that would work for you because I didn't know
whether there was text to either side of the spans in your real data.


If I markup even the white space then it really doesn't matter.

--
Stanimir

Jul 20 '05 #8
Steve Pugh <st***@pugh.net > wrote:
The display property is exactly what you should be using.
I wouldn't vote on the solutions before knowing the real problem.
<span class="adj">1</span><span class="foo">
</span><span class="adj">2</span><span class="foo">
</span><span class="adj">3</span>

.foo {display: none;}

The white space is part of the data,
In this case, it isn't. There is no white space in the textual content
above, by the specifications. There is just white space generated by white
space bugs, which are known to be common in browsers. By SGML rules,
the line breaks between <span ...> and </span> tags above shall be ignored
on two accounts: the line breaks immediately follow a start tag _and_
precede an end tag.

So if you use such a trick, you should at least use real spaces between the
tags.
Though I am curious what this data is that has meaningful whitespace
in it, but which doesn't lose meaning when that whietspace isn't
displayed.


Me too. I'm just making wild guesses right now, and thinking whether
letter-spacing or word-spacing with a negative value might be a solution.
But knowing the problem would surely help.

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

"Stanimir Stamenkov" <s7****@netscap e.net> wrote in message
news:bo******** *****@ID-207379.news.uni-berlin.de...
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>
<span class="adj">3</span>

--
Stanimir


I asked a very similar question a while ago in relation to making sure
images display adjacently regardless of whether there's a cr/lf in the HTML
between the <img>'s. I didn't get any definite answer, but it was probably
when everyone was on holiday.
--
Tony T
Replace 'from' with 'to' (twice) for e-mail
Jul 20 '05 #10

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

Similar topics

5
3335
by: qwweeeit | last post by:
Hi all, I need to limit as much as possible the lenght of a source line, stripping white spaces (except indentation). For example: .. . max_move and AC_RowStack.acceptsCards ( self, from_stack, cards ) must be reduced to: .. . max_move and AC_RowStack.acceptsCards(self,from_stack,cards) My solution has been (wrogly): ''.join(source_line.split())
2
2256
by: Malcolm Dew-Jones | last post by:
I am looking at xslt 1.0 and trying to understand if empty text nodes are supposed to be stripped or not as the default behaviour. 3.4 starts by listing rules for when white space is not stripped and then says "Otherwise the text node is stripped". which appears to contradict a later paragraph that discusses the details of the selection of nodes to be stripped ("Initially ... preserve ... all element names").
0
15201
by: Mark Moore | last post by:
I'm trying to layout a couple text input fields and their corresponding labels without using a table. When I was trying to debug my understanding of CSS, I was *very* surprised to see that span's with borders behave counter-intuitively (IMHO) when using style="white-space: nowrap;". Below is a fairly small chunk of XHTML that demonstrates what I'm talking about. What gives? -Mark
38
24025
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 font) Woudl some of the space character in unicode work? (my html files uses unicode) Xah
6
2175
by: Mark Miller | last post by:
I have a scheduled job that uses different XSL templates to transform XML and save it to disk. I am having problems with the code below. The problem shows up on both my development machine (Windows XP Pro SP 1, .Net Framework 1.1) and on our production server (Windows 2K SP 4, .Net Framework 1.1). I have simplified the code and data to isolate the problem. When I use the xsl:strip-space (Line 12) declaration in conjunction with the xsl:sort...
2
6770
by: shagy | last post by:
Hi, I'm having a problem with a <select><option> which has white space in values... When I post the data I only get the first word (up to the white space). "Testing white space" becomes "Testing" after posting code... <select name="descr" id="descr">
6
2609
by: rtilley | last post by:
s = ' qazwsx ' # How are these different? print s.strip() print str.strip(s) Do string objects all have the attribute strip()? If so, why is str.strip() needed? Really, I'm just curious... there's a lot don't fully understand :)
4
1515
by: Nathan Sokalski | last post by:
I have two asp:ImageMaps in a table cell as follows: <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="center"> <asp:ImageMap ID="mapBanner" runat="server" BorderWidth="0px" Height="82px" ImageUrl="../images/top_banner.jpg" Width="1000px" style="margin:0px;padding:0px;"> <asp:RectangleHotSpot Left="125" Top="5" Right="200" Bottom="22"
4
2134
by: mosesdinakaran | last post by:
Can any one explain how the rule is applied for the following Regular expression $Str = 'the red king'; $Pattern = '/((red|white) (king|queen))/'; preg_match($Pattern,$Str,$Val); Result:
0
9961
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10439
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9597
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7990
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5824
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4245
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.