0

When the content exceeds the tag width, the content will auto break into new line. How to split the tag content by line?

Expect Result: each line content Same question but not solved: Read text within an HTML <p> tag line by line in JavaScript

ekirio
  • 1
  • Try looking at answers in [this](https://stackoverflow.com/questions/3738490/finding-line-wraps) post – AspectOfTheNoob Jan 09 '23 at 01:14
  • I think you can use regex for this – ITDW Jan 09 '23 at 01:30
  • What are you actually trying to solve? You're trying to determine how the rendering is working out? – Brad Jan 09 '23 at 01:59
  • I'm trying to figure out whether I can compute the container width, then divide the font size to get the each line word number, split according to the word number. – ekirio Jan 09 '23 at 02:20
  • @Brad: I'm facing a problem that split content in table element.when content height exceeds table height, I need to split content into a new table – ekirio Jan 09 '23 at 02:36
  • @ekirio I don't follow exactly what it is you're trying to do, but it sounds fishy. Why would you need to split data into a new table? Table elements follow semantics... can you elaborate? – Brad Jan 09 '23 at 06:31
  • @Brad yes. We have a HTML element which contains table element, we transfer the html content to the backend and convert it into pdf file. But when the table height exceeds paper height, the page bottom will lose table bottom border. And my idea is split the table into two new table and put content into it. This needs to calculate the height and split each line of content. – ekirio Jan 09 '23 at 07:19
  • Ah, ok, that makes much much more sense. There is a way in CSS to adjust your table rows in the way that they roll to the next page... I don't remember the specifics as I haven't messed with print CSS in probably a decade, but I'd recommend going that route rather than modifying the elements on the page, if at all possible. – Brad Jan 09 '23 at 18:44

1 Answers1

-1

Just a javascript alternative document.getElementById('P TAG').innerHTML+="\n your text"

Monke
  • 51
  • 6