最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I display the text in pre tag in the default fonts that html uses? - Stack Overflow

programmeradmin2浏览0评论

I am developing an AngularJS application. In that, when I fetch data from the database to display it to the user, the extra spaces are trimmed to one space from the data which has more than one space between two words.

I tried <pre> tag of HTML and it works fine except one thing. It changes the style of the text. I applied different CSS in <pre> tag but I'm not getting the convenient result.

So how can I make it look like as it looks in normal HTML?

I'm attaching a sample:

<pre style="font-family: arial; font-size: 14px">{{name}}</pre>

It's working but it just doesn't help with the styles.

I am developing an AngularJS application. In that, when I fetch data from the database to display it to the user, the extra spaces are trimmed to one space from the data which has more than one space between two words.

I tried <pre> tag of HTML and it works fine except one thing. It changes the style of the text. I applied different CSS in <pre> tag but I'm not getting the convenient result.

So how can I make it look like as it looks in normal HTML?

I'm attaching a sample:

<pre style="font-family: arial; font-size: 14px">{{name}}</pre>

It's working but it just doesn't help with the styles.

Share Improve this question asked Jul 26, 2017 at 11:50 TheCleverIdiotTheCleverIdiot 4084 silver badges19 bronze badges 3
  • what do you want it to look like? – Luca Kiebel Commented Jul 26, 2017 at 11:54
  • Try to use <p ng-bind-html="name"></p> – Carnaru Valentin Commented Jul 26, 2017 at 11:54
  • Thank you friends, Sajin's answer helped. – TheCleverIdiot Commented Jul 26, 2017 at 12:11
Add a ment  | 

1 Answer 1

Reset to default 13

Try

<p style='white-space: pre;'>

instead of pre tag

发布评论

评论列表(0)

  1. 暂无评论