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
  #11 (permalink)  
Old June 17th, 2012, 09:20 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 (2)

Sorry I got a typing error in the code and didn't end it correctly.

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
  #12 (permalink)  
Old June 17th, 2012, 09:30 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 (3)

Of course the text-align property is set as well.

Code:
<head>
<style type="text/css">
p {text-align:justify;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
  #13 (permalink)  
Old June 17th, 2012, 10:27 AM
Imar's Avatar
Wrox Author
Points: 71,611, Level: 100
Points: 71,611, Level: 100 Points: 71,611, Level: 100 Points: 71,611, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,008
Thanks: 79
Thanked 1,575 Times in 1,552 Posts
Default

I think this is by design; I think text-align is just applied to implicit linebreaks (by wrapped text) and not by line breaks or pagragraph ends. Otherwise you end up with wide spaces on the last sentence.

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
  #14 (permalink)  
Old June 17th, 2012, 11:33 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 (4)

I have found a website that seems to have solved it but I cannot locate the key bit of coding that does the job.

http://www.williamkolean.com/williamblog/?p=23

I shall have to live with it. This is how my newspaper extract looks. It would have been good to have it justified as in the original but there you go.

http://www.bosburyhistoryresource.or...ewspapers.html
Reply With Quote
  #15 (permalink)  
Old June 17th, 2012, 11:37 AM
Imar's Avatar
Wrox Author
Points: 71,611, Level: 100
Points: 71,611, Level: 100 Points: 71,611, Level: 100 Points: 71,611, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,008
Thanks: 79
Thanked 1,575 Times in 1,552 Posts
Default

The text in your article is not aligned in any of the browsers I tested it on so I wonder why you would go down the road of separating each line in its own p element. Wouldn't it justify nicely with a single paragraph except for the last line of text?

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
  #16 (permalink)  
Old June 17th, 2012, 01:11 PM
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 (5)

I have changed it to one long paragraph and uploaded the page as Newspapers2.html

The problem is that, however I adjust text margins, I cannot get the text to divide at the proper words. For example down to the line 8 beginning '20 miles' is fine in Firefox (not IE or Chrome) but 'remark-' should be at the end of line 10 and 'able' at the start of line 11. The only way I can see to have the correct words on the correct line so that it matches the original newspaper article is to break lines using <br> or <p> but then I lose the justification. Aargh!

I hope to transcribe a number of newspaper clippings, hence my search for a display method. I'll keep searching the web for an example with understandable coding.
Reply With Quote
  #17 (permalink)  
Old January 11th, 2015, 10:09 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2015
Location: Memphis, TN
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default break in text-align=justify

I frequently have equations like "5/50 = 10%" and html can spit up the equation. The original complaint that
Code:
<br>5/50 = 10%
doesn't work because the <br> effectively changes text-align=justify to text-align=left for the line the <br> is on.

In this case, it is better technique to use
Code:
5/50&nbsp;=&nbsp;10%
to prevent html from splitting up the equation. In general, this is a better technique anyway for non fixed width web pages.

However, there are other characters that I do not now how to use that technique with. Any help for me?
Reply With Quote
  #18 (permalink)  
Old March 21st, 2018, 04:35 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2018
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by richard.york View Post
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
Thanks you! It's true!
Reply With Quote
  #19 (permalink)  
Old March 22nd, 2018, 12:40 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2015
Location: Memphis, TN
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default making [code]text-align:justify[/code] after [code]<br>[/code]

The HTML code
Code:
<br>
automatically changes the alignment to left. However there is one workaround. What is needed is to prevent the breaks between the next several words. code should look like
Code:
This is the start of a very long line.
<span style="white-space: nowrap;">I have just prevented a line break between any of the words in this sentence.</span> You may continues with more words.
The trick is once the "span" code is too long to fit on the previous line HTML will end the line at the start of the "span" code and use the justify alignment as asked for. Of course you can use styling to shorten the coding. with HTML5 you might try
Code:
New_L {white-space: nowrap;}
and later
Code:
<New_L>Start a new line here:</New_L>
Reply With Quote
  #20 (permalink)  
Old March 31st, 2018, 03:04 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2018
Location: Ukraine
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure this code will work. I'd recommend do not use <br> tag in your code.
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 11:33 AM
<br/> becomes <br></br> Kabe XSLT 1 July 6th, 2007 07:42 AM
to append <br> in XSLT dharus XSLT 4 August 1st, 2006 09:52 AM
Replacing Garriage Returns with <br /> rit01 ASP.NET 2.0 Basics 7 March 21st, 2006 02:33 AM
Replace vbcrlf with <br> using C# kgriffin ASP.NET 1.0 and 1.1 Basics 2 May 4th, 2005 09:29 AM



All times are GMT -4. The time now is 06:18 AM.


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