Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 17th, 2012, 09:20 AM
Registered User
 
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>
 
Old June 17th, 2012, 09:30 AM
Registered User
 
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>
 
Old June 17th, 2012, 10:27 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 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!
 
Old June 17th, 2012, 11:33 AM
Registered User
 
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
 
Old June 17th, 2012, 11:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 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!
 
Old June 17th, 2012, 01:11 PM
Registered User
 
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.
 
Old January 11th, 2015, 11:09 PM
Registered User
 
Join Date: Jan 2015
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?
 
Old March 21st, 2018, 04:35 AM
Registered User
 
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!
 
Old March 22nd, 2018, 12:40 AM
Registered User
 
Join Date: Jan 2015
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>
 
Old March 31st, 2018, 03:04 PM
Registered User
 
Join Date: Mar 2018
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.





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 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 03:33 AM
Replace vbcrlf with <br> using C# kgriffin ASP.NET 1.0 and 1.1 Basics 2 May 4th, 2005 09:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.