Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS How to make text responsive?

Chris

Coder
Hi,
I currently try to make a page responsive for the first time and have a problem concerning my text.
This is the mobile version how I want it.

Unbenannte Präsentation.jpg

The desktop version is also (more or less) fine for me:
Unbenannte Präsentation.jpg

My problem is, what comes in between:
Unbenannte Präsentation.jpg
I don't want these single words.

Maybe anybody can tell me a better way to make texts responsive?

Here you find the page: https://christophgrothe.github.io/home_plants/
This text is at the end of the page.
(I hope it's ok to insert a link to the page instead of directly posting the code?)

Best wishes,
Chris
 
I'm not sure you're able to control those single words, unless you add padding so that more words go on that line or make the text overflow out of the screen (not recommended).


(I hope it's ok to insert a link to the page instead of directly posting the code?)
Yeah, that's okay. :)
 
I'm not sure you're able to control those single words, unless you add padding so that more words go on that line or make the text overflow out of the screen (not recommended).



Yeah, that's okay. :)
Ok, and would you say, the way I edit the text and try to make it responsive is generally fine? Or would "best practise" look different?
 
Hmm, I'm thinking what you may be after is the style property word-break, this will allow you to specify whether or not to break words for the next line.
  • word-break: break-word;
  • word-break: normal;
  • word-break: keep-all;
  • word-break: break-all;
You can find more about word-break from MDN Web docs by clicking here.
 
Hmm, I'm thinking what you may be after is the style property word-break, this will allow you to specify whether or not to break words for the next line.
  • word-break: break-word;
  • word-break: normal;
  • word-break: keep-all;
  • word-break: break-all;
You can find more about word-break from MDN Web docs by clicking here.
Thanks for the hint, didn't know this property. However, neither with "word-break" nor by changing the width (instead of using padding) I manage to make to text look nice no matter which size the display is ( I always find a size in which a single word is in a row). Maybe my problem is my html? Normally I used for such a text for example a div or a section and then a row of p's. This time I used a single p for the whole text and then used "white-space: pre-line" to create seperate paragraphs/white-space.
 

Attachments

  • 1647861365422.png
    1647861365422.png
    77.2 KB · Views: 2
  • 1647861410660.png
    1647861410660.png
    229.9 KB · Views: 2
This time I used a single p for the whole text and then used "white-space: pre-line" to create seperate paragraphs/white-space.
Idk what exactly you mean, but I use <br> for a line break.

HTML:
<p>
  Here's one line break
  <br>
  Here's another line break
  <br>
  You can also add multiple line breaks
  <br><br>
  Just some random text to finish it off
</p>
 

Buy us a coffee!

Back
Top Bottom