css去掉p标签上下空白

By default, HTML pages ignore anything more than a single space, and collapse the excess to take up no space at all. The most common way to compensate for this behaviour is to specify margin or padding to the left or right of an element as a substitute for spaces, which remains the best solution in most cases. But there are occasions in which you’ll want to preserve the actual space characters: indentation before lines of code, for example.

默认情况下,HTML页面会忽略除单个空格之外的所有内容,并将多余的部分折叠以完全不占用任何空间。 补偿此行为的最常见方法是在元素的左侧或右侧指定marginpadding以替代空格,这在大多数情况下仍是最佳解决方案。 但是在某些情况下,您需要保留实际的空格字符:例如,在代码行之前的缩进。

CSS supports this in the form of tab-size.

CSS以tab-size的形式支持此功能。

If I have some sample code:

如果我有一些示例代码:

<pre><code>ol.generic-class {property: value;
}</code></pre>

It's possible to preserve the tab before the “property: value" line with tab-size, currently supported by all browsers except IE / Edge.

可以使用tab-size保留“ property: value ”行之前的tab-size ,当前除IE / Edge以外的所有浏览器都支持该标签。

To enable the property, and provide a graceful fallback in IE, set the white-space property to pre, while setting tab-size to the equivalent of 4 spaces:

要启用该属性并在IE中提供优美的备用,请将white-space属性设置为pre ,同时将tab-size设置为等于4个空格:

code {white-space: pre;tab-size: 4;
}

Visually, this produces the following:

在视觉上,这将产生以下结果:

ol.generic-class {property: value;
}

You could also use :before or :after generated content to produce spaces, rather than trying to preserve tabs. Generally I’d suggest using margin or padding instead, but this is an option:

您也可以使用:before:after生成的内容来产生空格,而不是尝试保留制表符。 通常,我建议改用marginpadding ,但这是一个选择:

code:before {content: "        ";whitespace: pre;
}

翻译自: https://thenewcode.com/442/Preserving-Whitespace-With-CSS-tab-size

css去掉p标签上下空白

css去掉p标签上下空白_使用CSS标签大小保留空白相关推荐

  1. css设置a连接禁用样式_使用CSS禁用链接

    css设置a连接禁用样式 Question: 题: Links are one of the most essential aspects of any web page or website. Th ...

  2. css里外边框与内边框_基本CSS边框

    css里外边框与内边框 Every HTML element can be provided with a basic border via CSS, using one of 10 styles: ...

  3. css百分比跟em的区别_查看CSS单位:像素,EM和百分比

    单位在测量和建造房屋,桥梁或塔楼等物品方面起着重要作用,并且建造网站也不例外. Web上有多种测量方法,特别是CSS中的像素,EM和Percentage . 在本文中,我们将遍历这些单位,以进一步了解 ...

  4. css点击字变颜色_使用CSS颜色关键字

    css点击字变颜色 One of the two oldest methods of applying color to web pages, named colors remain very use ...

  5. css字太多了省略_纯CSS实现文字超过n行后省略功能

    在切图阶段,经常会遇到,设计稿要求超出n行后剩余文字省略,并用...代替的需求.类似于下图 单行文字 单行文字时实现比较容易,使用overflow: hidden和text-overflow: ell ...

  6. css 引用嵌入字体不起用_使用CSS嵌入字体

    css 引用嵌入字体不起用 Fonts can also be embedded into web pages: that is, the end-user sees the page text in ...

  7. css设置不显示超出内容_显示...,css设置内容超出后显示省略号

    1.使用overflow: hidden把超出的内容进行隐藏: 2.然后使用white-space: nowrap设置内容不换行: 3.最后使用text-overflow: ellipsis设置超出内 ...

  8. python提取p标签的文本_从p标签获取文本内容

    我正在尝试获取此页面上每个块的描述文本内容 用于p标签的html看起来像 http://DataMiningBlog.com  covers current challenges, interview ...

  9. html marquee初始空白_前端开发必会的HTML/CSS硬知识

    文/小魔女 1 本文简介 面试大厂,HTML/CSS,JS,网络基础这三块硬知识是必不可少的 我整理了一些备考笔记,分享给大家 初中级前端到高级前端的蜕变,从基础知识开始~ 2 块元素和行元素 2.1 ...

最新文章

  1. 2017计算机考研教材,【考研】2017计算机考研:四大科目参考书推荐
  2. 互联网思维-标签思维(1)
  3. RabbitMQ脑裂问题解决方案调查
  4. WebBrowser控件参数解释
  5. MPMovieplayercontroller
  6. hdu 4414 Finding crosses
  7. JSP→基本语法/静态内容/指令/动作/表达式/小脚本(Scriptlet)/声明/注释、JSP页面声明周期、代码样例、九大隐式内置对象及方法代码样例
  8. 【渝粤教育】 广东开放大学21秋期末考试会议运行管理10036k2
  9. 购买计算机键盘,键盘安装步骤是怎样的 怎样选购电脑键盘
  10. 百度收录自动化提交脚本 - python
  11. winxp笔记本和有线路由器通过网线连接情况下的设置方法
  12. Adjacent Bit Counts
  13. FeignException$InternalServerError [500] during [POST]同时出现converter.HttpMessageConversionException
  14. 蓝桥杯——单片机学习(3——点亮LED灯)
  15. IntelliJ IDEA 快捷键及模板Templates设置
  16. 车企数字化转型中的核心技术应用
  17. Android软键盘弹出和收起的监听
  18. VLAN原理和配置,交换机创建vlan的多种方法、三种接口模式的作用和配置方法、Access、Trunk、Hybrid接口的特性以及配置方法和命令
  19. 阿里巴巴淘系技术:超详|2020年你不应该错过的CSS新特性
  20. PyCharm免费使用,没有校园邮箱也可以(PyCharm学生认证邮箱失效同样可以)

热门文章

  1. C语言有以下几种取整方法
  2. 贪心算法-分配问题-分发糖果
  3. 3GPP TS 29244-g30 中英文对照 | 5.7.1 General
  4. 极米 H6 4K 版投影仪 评测
  5. r7 4800u是标压还是低压 r7 4800u能玩什么游戏
  6. SpringCloud——ELK搭建(Windows版)
  7. javascript功能插件大集合 前端常用插件 js常用插件
  8. 详解softmax函数
  9. 今日学到:Day 2
  10. 小型网络规划设计与实施(简单课设)