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

How to indent a line after <br />

Hi everyone, I've just joined your group!

I'm pretty new to HTML etc. Here's my problem:

I'm attached to the idea of keeping content separate from formatting
information, so I like putting content in a .xml document and then
making a stylesheet for it.

At the moment I'm working on a lot of prose-style text, and having to
enclose everything in double-sided <xyz></xyz> tags in order to get any
kind of indentation between blocks is not so convenient. This is
especially true when formatting dialogue in fiction, where you need
line breaks and indentation for lots of very short, consecutive lines
of text.

The approach I'm currently pursuing is to put an emtpy node called <br
/> in the .xml source where I need a line break, and then use .xsl and
..css stylesheets to instuct the browser to interpret this as "do a line
break, but indent the first character of the next line".

The only way to do this that I've currently found is a rather inelegant
'cheat' using the zero width non-joiner &zwnj; (*), thus
(extracting from the stylesheet):

<xsl:template match="br">
<br />
<span id="indent">&zwnj;</span>
</xsl:template>

where "indent" pads on the left by 1em.

(De-confuser: the matched "br" is the empty node that lives in the .xml
source.)

This works o.k., and doesn't upset the "text-align: justify" which is
in effect throughout the document (and which for example, if I
substitute the <span></span> expression with &emsp, leaves the indented
text misaligned as the space character is factored into the
justification). I guess it's an o.k. work-around, but it's still a
misuse of an entity (&zwnj;), which can't be good practice and leaves a
bitter taste in the mouth.

Is there a way of achieving the same result in a more concrete manner
using CSS? Or is there a safer 'placeholder entity' I can use instead
of &zwnj; to put inside the <span> so it actually indents the following
character? A crucial consideration here seems to be the justified text,
and how to avoid mucking it up.

I'd really appreciate any advice on this!

Best wishes,

T.

Mar 14 '06 #1
8 9983
tintagel wrote:
I'm attached to the idea of keeping content separate from formatting
information, so I like putting content in a .xml document and then
making a stylesheet for it.
Don't overdo this.

- Don't expect CSS to be an adequate stylesheet language for this.
You'll need XSLT if you want duplication, ordering, attribute
generation and a whole lot more.

- You'll need a DTD to specify the XML you use to represent your
content. If your content is "publications for the web", then XHTML is a
reasonable DTD to use (Can you see where I'm leading here?)

HTML / XHTML is a useless DTD for document semantics, but it's not
actually that bad for text formatting - or at least formatting hooks
sufficient to attach CSS formatting rules onto.

The only way to do this that I've currently found is a rather inelegant
'cheat' using the zero width non-joiner &zwnj; (*), thus
(extracting from the stylesheet):


Use the CSS text-indent property
http://www.w3.org/TR/CSS21/text.html#indentation-prop
You don't have to hack on the web. Pretty much everything works these
days (if you ignore M$oft getting it wrong). If you're having to build
ugly hacks, then chances are you're doing it wrongly.

Mar 14 '06 #2
tintagel escribió:
...
The approach I'm currently pursuing is to put an emtpy node called <br
/> in the .xml source where I need a line break, and then use .xsl and
.css stylesheets to instuct the browser to interpret this as "do a line
break, but indent the first character of the next line".
...
Is there a way of achieving the same result in a more concrete manner
using CSS? ...


In the CSS:

br + * { text-indent: 1em }

(not tested, but should work)
--
To reply by e-mail, please remove the extra dot
in the given address: m.collado -> mcollado

Mar 14 '06 #3
Hi Andy,

Thanks for the advice. The indentation property only applies to block
elements, not inline ones like <br />. But I'll bear your advice in
mind.

T

Mar 19 '06 #4
Hi Manuel,

Thanks for the advice. I don't quite understand the syntax in your
suggestion. What does the '+*' in the CSS declaration do?

Cheers,

T

Mar 19 '06 #5
Manuel Collado wrote:
br + * { text-indent: 1em }

(not tested, but should work)


No, it shouldn't. Since it will match the next element, not the text
immediately following the element.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Apr 2 '06 #6
tintagel wrote:
Thanks for the advice.
What advice? http://www.safalra.com/special/googlegroupsreply/
I don't quite understand the syntax in your
suggestion. What does the '+*' in the CSS declaration do?


+ adjacent sibling

* any element

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Apr 2 '06 #7
tintagel wrote:
The approach I'm currently pursuing is to put an emtpy node called <br
/> in the .xml source where I need a line break, and then use .xsl and
.css stylesheets to instuct the browser to interpret this as "do a line
break, but indent the first character of the next line".


Browsers are really geared up for indentation of blocks (and the first line
of blocks), not lines. From your description of your content, it sounds
like you should be organising your content into multiple logical blocks
(e.g. paragraphs), and not a single logical block with line breaks in it.

Then you can just use the text-indent property to acheive the effect you
want.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Apr 2 '06 #8
David Dorward wrote:
Manuel Collado wrote:
br + * { text-indent: 1em }
No, it shouldn't. Since it will match the next element, not the text
immediately following the element.


.... and only applies to elements that are display: block.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Apr 2 '06 #9

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

Similar topics

4
by: fis | last post by:
Hi all, I've problem because there are needed break lines in my texts on the web site but i can't do it :( My pipeline looks like: XMS -> I18N -> XSLT -> HTML I have lot of texts in my...
6
by: Lasse | last post by:
I have done this simple function, it seems to work as intended, to solve a problem i have had for a while. I couldnt find any sample around that was working for me. I would like to test it with...
2
by: John D | last post by:
can anyone explain why a site would use this in their page <!--<BR>--> Presumably it is hiding the <BR> from ... ??? TIA John
9
by: Wayne | last post by:
$a = $_POST; # txt_content = This is a<CR><LF>Test $p = str_replace ("%0D%0A", "<br>", $a); That is the above code that I am using, however, it is not picking up the CR/LF from the textarea. I...
4
by: Christofer Dutz | last post by:
Hi, I am having a small problem, that is driving me nuts. My application reads some Xml and runs 2 Xsl Transformations to generate HTML. As soon as my second XSL introduces some <br/tags, the...
3
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt,...
6
by: JoeS | last post by:
I'm new to XSLT, it what our old website developer used but he has now left our company. I have been given the task of making our site output as valid XHTML as I can get it. Currently in the .XSL...
7
by: Nathan Sokalski | last post by:
Something that I recently noticed in IE6 (I don't know whether it is true for other browsers or versions of IE) is that it renders <br/and <br></br> differently. With the <br/version, which is what...
4
by: ismailc | last post by:
Hi, I need help please. In <TD> certain length/max length then force <BR> I would like within a <TD> to allow certain amount of char and then force a <br>. Is this possible, Please Assist!...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.