Why does my text has the justify effect when I didnt made it to have this effect (css/php)

StackOverflow https://stackoverflow.com/questions/2589941

  •  25-09-2019
  •  | 
  •  

Question

Why my text has the justify effect? In my whole site, I make echos and i dont specify a "text-align:justify;" but my text is still justifying. Justify is when you make the browser window smaller, the text moves so it fits in the window. I tryed making something like this: <?php echo "<h1>some stuff.</h1>"; ?> <html> <head> <style> h1 { text-align:center; } etc....

but it just makes the text go in the center and it keeps the justify effect.

please help me =[ thanks

Was it helpful?

Solution

Justify is when you make the browser window smaller, the text moves so it fits in the window.

That's not what justify is. Justify makes it so all lines of text are the same width, like this:

alt text
(source: pws-ltd.com)

If you don't want the text to stay inside the window when you shrink it (so if you want a horizontal scrollbar), you have to set a min-width on a <div> containing the text.

Edit: though maybe I misunderstood what you were actually trying to do, and you just want it centered. If so, use margin: 0 auto; not text-align: center;

OTHER TIPS

Justifying is when the spacing between the words is adjusted so text is fully aligned on both the left and the right of the block of text.

What you are describing sounds like even though you want the text centered, it is long enough to fill the page and thus doesn't really look centered. Consider adding something like this. The fixed width keeps the text from filling the window, and the margin: 0 auto centers the h1 tag itself:

<style type="text/css">
    h1 { text-align: center; width: 300px; margin: 0 auto }
</style>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top