Search code examples
phpcsstextjustify

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


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


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;