html5 收缩段落,HTML5(7)——段落

1437896972e1?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

想法很多,已没有经历实现

现在不得不感叹,很多事情有想法,却找不到人一起去实现。

继续学习HTML5,来讲一讲段落。

HTML段落

元素是用来定义段落的,并且是由结束标签的。而且网页在解析时,会自动在段落前和段落后添加一些空格区域。

This is a paragraph.

This is another paragraph.

HTML段落显示

你是没有办法去控制网页到底会怎么样显示,小的屏幕,大的屏幕等情况都会变得不一样。而且你也不能添加空格和换行来改变段落显示,网页会自动移除这些空格和空行,比如:

This paragraph

contains a lot of lines

in the source code,

but the browser

ignores it.

This paragraph

contains a lot of spaces

in the source code,

but the browser

ignores it.

The number of lines in a paragraph depends on the size of the browser window. If you resize the browser window, the number of lines in this paragraph will change.

1437896972e1?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

显示结果

HTML换行

HTML中换行,你需要
元素来进行实现。你可以在你想换行的地方添加
元素来进行换行。

This is
a paragraph
with line breaks.

诗的显示问题

In HTML, spaces and new lines are ignored:

My Bonnie lies over the ocean.

My Bonnie lies over the sea.

My Bonnie lies over the ocean.

Oh, bring back my Bonnie to me.

1437896972e1?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

单行显示了

如果想要正常的显示诗,且能够保存空格,那么我们需要用到

元素,它是用来预格式化文本的,能够保存文本原本的空格和换行且能够使字体宽度固定。

The pre tag preserves both spaces and line breaks:

 
 

My Bonnie lies over the ocean.

My Bonnie lies over the sea.

My Bonnie lies over the ocean.

Oh, bring back my Bonnie to me.

1437896972e1?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

正常显示诗

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值