473,700 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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">&zw nj;</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 10028
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 "publicatio ns 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
7862
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 "languages" files and these are describes for things on my website. Example text looks like this:
6
12154
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 you and see if there are any improvments that i should make ;-) It should be fast and if possible compatible with todays modern browser-standards. It should be activated by the onload-event. This is my code, free for all to use:
2
1946
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
43151
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 have also attempted singular variations of the CR/LF combination and even reversed the sequence without success. Is it possible that it may be encoded differently and if so what is it? Thanks
4
4340
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 application crashes with the same error message I would get when writing <brand no closing tag. To make everything a little stranger, even <br></brseems to be bad while <lbr/is fine. Ive tried some other tag names and the problem only appears with...
3
3374
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, &gt ,&ltCompany&gt to display '<', '>' and '<Company>' respectively. But is there any freeware code available which could implement the above functionality without having to use &gt,&lt and such stuff???
6
2388
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 files I write self-closing tags like <br/> but in the output XHTML they come out as <br> and therefore the page doesn't validate. This happens for other self-closing tags like <img src=""/> too. I don't really know XSLT so I don't know how I can fix...
7
3624
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 most people use when they write static code (some people use <br>, but with xhtml you are required to close all tags), IE6 simply breaks to the next line like it is supposed to. However, with <br></br>, which is what is sometimes generated by...
4
3826
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! Regards
0
8726
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
8645
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9214
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9075
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...
1
8973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8925
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...
1
6561
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...
1
3089
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2028
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.