Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 2nd, 2004, 02:09 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default text-align:justify; and <BR>

suppose we are writing text-lines with <BR> between the lines.
i want 'text-align:justify;' to do its usual work; i mean to turn-off side-effect of <BR> 's
at the same time, i need blank lines between the text lines.
a line less than block-width should be automatically padded with spaces to keep it upto right, in sync. with all other lines.

is there a way ?
__________________
`~@#\^%&*/\.<.\/-|+|_!:;..=?>
PHP, SEO | anshul shrivastava | mediasworks.org | FB
Reply With Quote
  #2 (permalink)  
Old September 2nd, 2004, 02:38 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

What is the side effect of a <br>?

Reply With Quote
  #3 (permalink)  
Old September 2nd, 2004, 05:54 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Generally speaking it is good practice to avoid using the <br/> tag all together, and instead enclose text in paragraphs using the <p> tag and headings in heading tags <h1> - <h6>. This allows the markup to have meaning in its structure. By using the <p> element you can control all of the space around text using CSS margins and padding and this also has the benefit that the markup actually describes what it is structuring. Make sense?

If you need more space between the lines inside of a paragraph, you can also increase that space by using the line-height property.

As far as what you mean by the side-effects of a <br/>, I haven't a clue what you mean but I think I get what you're saying. If I'm off track, can you provide an example and a more elaborate description?

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
Reply With Quote
  #4 (permalink)  
Old September 5th, 2004, 03:26 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

<P style="width:200px; text-align:justify;">
    This is first line of text full-stop
    <BR>
    This is second line of text full-stop
    <BR>
    This is third line of text full-stop
    <BR>
    This is fourth line of text full-stop
</P>

<BR> is doing its usual work.
.. and usual use of text-align is to justify textual-paragraphs. yes.

i want both sentences start at left and justified right amidst BRs
or they should not die in between before going to right margin.

if <BR> is dropped from there; right-margin will be justified.
but i want new sentence to start in a fresh line.

no problem if all sentences i type are identical!

 
Quote:
quote:( no need of 'text-align' then )
Quote:
, can you provide an example and a more elaborate description?
Regards,
Rich
please see very first 2 lines of text. http://www.mediasworks.com/literature/nnbelle.htm

simply i say, i just wanted 'W' below 'D' :it is OK
in similar way i wanted to assure '!' below '?'
but this is not happening there.
Reply With Quote
  #5 (permalink)  
Old September 7th, 2004, 12:10 AM
Authorized User
 
Join Date: Aug 2004
Location: Yogyakarta, D.I. Yogyakarta, Indonesia.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It surely can't be done, this is similar to the working way at MS-Word and other word processors.

Reply With Quote
  #6 (permalink)  
Old September 10th, 2004, 10:14 AM
Authorized User
 
Join Date: Sep 2004
Location: , , United Kingdom.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if you use a external stylesheet whith the link tag in the head ie. <link type="text/css" rel="stylesheet" href="...."> and just use
<P>first line</P>
<p>second line</p>
<p>third line</p>
it will do the same as <br> and should work fine.
Reply With Quote
  #7 (permalink)  
Old June 17th, 2012, 09:25 AM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Still no answer

This problem (keeping text-align:justify when the <br> tag includes a left-justify as part of it's action) has still not been solved in June 2012. I have searched everywhere and cannot find a sensible workaround. To explain the problem simply, you can put p {text-align:justify;} or div.text1 {text-align:justify} or span.text1 {text-align:justify} and put your text within a <p> or <div class="text1"> or <span class="text1"> but as soon as you put a <br> inside the text then the line before it loses its justify alignment. Has anyone come up with an answer in the meantime?

I want to reproduce a newspaper item exactly as in the original paper with every line justified and matching the original. To get the words to match exactly I need to use <br> on each line but of course the justification is lost.
Reply With Quote
  #8 (permalink)  
Old June 17th, 2012, 09:48 AM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Still no answer (2)

The idea that <p> can replace <br> doesn't work as <p> introduces a blank line.
Reply With Quote
  #9 (permalink)  
Old June 17th, 2012, 09:53 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,960
Thanks: 79
Thanked 1,559 Times in 1,536 Posts
Default

Quote:
The idea that <p> can replace <br> doesn't work as <p> introduces a blank line.
it doesn't. It's the CSS that does this which you can remove by setting margin and padding to 0:

Code:
 
p
{
  margin: 0;
  padding: 0;
}
Quote:
then the line before it loses its justify alignment. Has anyone come up with an answer in the meantime?
You mean the line with the <br /> statement? Or the line before that one?

In the former case, I think it makes sense, and that's usually how text align works, in Word processign as well. Otherwise, you would get extremely large spaces between the words....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #10 (permalink)  
Old June 17th, 2012, 10:18 AM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Justify problem

Thanks Imar. I have used <p> at the start of each line and </p> at the end of each line after defining the style for p as {margin:0;padding:0;} as you suggested. The blank lines have gone but the justification has gone as well and I'm back to left align. I use Firefox 13 but I thought to check it in IE 9 and Google Chrome. It works in IE which keeps the justify but not in Chrome which is back to left alignment so it is obviously a browser interpretation. I would like to find a way that works for all three browsers.

This is the simple coding:
[code]
<head>
<style type="text/css">
p {margin:0;padding:0;}
</style>
</head>
<body>
<p>BOSBURY Horse Show and</p>
<p>Races - The proverbial fine</p>
<p>day again favoured the hold-/p>
<p>ing of this long-established</p>
</body>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace "<enter>" with "<br>" Varg_88 Classic ASP Basics 5 February 14th, 2011 12:33 PM
<br/> becomes <br></br> Kabe XSLT 1 July 6th, 2007 08:42 AM
to append <br> in XSLT dharus XSLT 4 August 1st, 2006 10:52 AM
Replacing Garriage Returns with <br /> rit01 ASP.NET 2.0 Basics 7 March 21st, 2006 03:33 AM
Replace vbcrlf with <br> using C# kgriffin ASP.NET 1.0 and 1.1 Basics 2 May 4th, 2005 10:29 AM



All times are GMT -4. The time now is 03:04 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.