当前位置: 首页 > 编程日记 > 正文

统计数字,空白符,制表符_为什么您应该在HTML中使用制表符空间而不是多个非空白空间(nbsp)...

统计数字,空白符,制表符

There are a number of ways to insert spaces in HTML. The easiest way is by simply adding spaces or multiple   character entities before and after the target text. Of course, that isn't the DRYest method.

有多种方法可以在HTML中插入空格。 最简单的方法是简单地添加空格或多个  目标文本前后的字符实体。 当然,这不是DRYest方法。

Instead, to keep your code easy to maintain and reduce repetition, you can use the <span> and <pre> elements, along with a bit of CSS:

相反,为了使代码易于维护并减少重复,可以使用<span><pre>元素以及一些CSS:

使用<span>元素 (Using the <span> element)

An example of how to use <span> to control the spacing between text can be seen below:

下面是一个如何使用<span>来控制文本之间的间距的示例:

<p>Hello my name is <span class="tab"> James</p>

Note that <span> tags are self closing, meaning they do not need a />.

请注意, <span>标记是自动关闭的,这意味着它们不需要/>

Then you can use an external or internal styling to give the class tab some properties. For example, the following code will work in an external stylesheet:

然后,您可以使用外部或内部样式为class tab一些属性。 例如,以下代码将在外部样式表中运行:

.tab {padding-left: 2px;
}

You can also give the <span> some inline-style properties, as shown below.

您还可以为<span>一些内联样式的属性,如下所示。

Alternatively, you can give <span> the same properties as inline styles as shown below:

另外,您可以赋予<span>与内联样式相同的属性,如下所示:

<p>Hello my name is <span style="padding-left: 2px;"> James</p>

使用<pre>元素 (Using the <pre> element)

For an easy way to add a tab space, simply wrap your text in <pre> tags. For example:

为了方便地添加制表符空间,只需将文本包装在<pre>标记中。 例如:

The <pre> element simply represents preformated text. In other words, any spaces or tabs in the inner text will be rendered. For example:

<pre>元素仅表示预格式化的文本。 换句话说,将显示内部文本中的任何空格或制表符。 例如:

<pre>
function greeting() {console.log('Hello world!');
}
</pre>

Just keep in mind that any actual tab characters (not a bunch of spaces that look like tabs), that you use with this method might appear ridiculously wide. This is because the tab-size property for the <pre> element is set to 8 spaces by default.

请记住,此方法使用的任何实际的制表符(不是一堆看起来像制表符的空格)可能看起来都非常可笑。 这是因为<pre>元素的tab-size属性默认设置为8个空格。

You can change this with a bit of CSS:

您可以使用一些CSS进行更改:

pre {tab-width: 2;
}

有关HTML的更多信息: (More info about HTML:)

HyperText Markup Language (HTML) is a markup language used to construct online documents and is the foundation of most websites today.

超文本标记语言(HTML)是用于构造在线文档的标记语言,并且是当今大多数网站的基础。

A markup language like HTML allows us to

HTML之类的标记语言使我们能够

  • create links to other documents,

    创建指向其他文档的链接,
  • structure the content in our document, and

    整理文档中的内容,并
  • ascribe context and meaning to the content of our document.

    将上下文和含义赋予我们的文档内容。

An HTML document has two aspects to it. It contains structured information (Markup), and text-links (HyperText) to other documents.

HTML文档有两个方面。 它包含结构化信息(标记)和指向其他文档的文本链接(超文本)。

We structure our pages using HTML elements. They are constructs of the language providing structure and meaning in our document for the browser and the element links to other documents across the internet.

我们使用HTML元素构造页面。 它们是语言的结构 ,在浏览器的文档中提供了结构和含义 ,并且该元素链接了整个互联网上的其他文档。

The internet was originally created to store and present static (unchanging) documents. The aspects of HTML discussed above were seen perfectly in these documents which lacked all design and styling. They presented structured information that contained links to other documents.

互联网最初是用来存储和呈现静态(不变)文档的。 在缺少所有设计和样式的这些文档中,可以完美地看到上面讨论HTML方面。 他们介绍了结构化信息,其中包含指向其他文档的链接。

HTML5 is the latest version, or specification, of HTML. The World Wide Web Consortium (W3C) is the organization that develops the standards for the World Wide Web, including those for HTML. As web pages and web apps grow more complex, W3C updates HTML’s standards.

HTML5是HTML的最新版本或规范。 万维网联盟(W3C)是开发万维网标准(包括HTML标准)的组织。 随着网页和Web应用程序变得越来越复杂,W3C更新了HTML的标准。

HTML5 introduces a whole bunch of semantic elements. While HTML helps provide meaning to our document, it wasn’t until the introduction of semantic elements with HTML5 that its potential was fully known.

HTML5引入了很多语义元素。 尽管HTML有助于为我们的文档提供含义,但直到HTML5引入语义元素后,它的潜力才被人们充分认识。

HTML文档的简单示例 (A simple example of an HTML Document)

<!DOCTYPE html>
<html>
<head><title>Page Title</title>
</head>
<body><h1>My First Heading</h1><p>My first paragraph.</p></body>
</html>

!DOCTYPE html: Defines this document to be HTML5

!DOCTYPE html:将此文档定义为HTML5

html: The root element of an HTML page

html:HTML页面的根元素

head: The element contains meta information about the document

head:元素包含有关文档的元信息

title: The element specifies a title for the document

title:元素指定文档的标题

body: The element contains the visible page content

正文:该元素包含可见的页面内容

h1: The element defines a large heading

h1:元素定义大标题

p: The element defines a paragraph

p:元素定义一个段落

HTML版本 (HTML Versions)

Since the early days of the web, there have been many versions of HTML

自网络初期以来,已经有许多版本HTML

  • HTML1991

    HTML1991
  • HTML 2.01995

    HTML 2.01995
  • HTML 3.21997

    HTML 3.21997
  • HTML 4.011999X

    HTML 4.011999X
  • HTML2000

    HTML2000
  • HTML52014

    HTML52014

其他资源 (Other Resources)

  • HTML Elements

    HTML元素

  • Semantic HTML

    语义HTML

  • HTML Attributes

    HTML属性

翻译自: https://www.freecodecamp.org/news/tab-space-instead-of-multiple-non-breaking-spaces/

统计数字,空白符,制表符

相关文章:

Python20-Day02

1、数据 数据为什么要分不同的类型 数据是用来表示状态的&#xff0c;不同的状态就应该用不同类型的数据表示&#xff1b; 数据类型 数字&#xff08;整形&#xff0c;长整形&#xff0c;浮点型&#xff0c;复数&#xff09;&#xff0c;字符串&#xff0c;列表&#xff0c;元组…

Android网络框架-OkHttp3.0总结

一、概述 OkHttp是Square公司开发的一款服务于android的一个网络框架&#xff0c;主要包含&#xff1a; 一般的get请求一般的post请求基于Http的文件上传文件下载加载图片支持请求回调&#xff0c;直接返回对象、对象集合支持session的保持github地址&#xff1a;https://githu…

第一天写,希望能坚持下去。

该想的都想完了&#xff0c;不该想的似乎也已经尘埃落定了。有些事情&#xff0c;终究不是靠努力或者不努力获得的。顺其自然才是正理。 以前很多次想过要努力&#xff0c;学习一些东西&#xff0c;总是不能成&#xff0c;原因很多&#xff1a; 1.心中烦恼&#xff0c;不想学…

mac gource_如何使用Gource显示项目的时间表

mac gourceThe first time I heard about Gource was in 2013. At the time I watched this cool video showing Ruby on Rails source code evolution:我第一次听说Gource是在2013年 。 当时&#xff0c;我观看了这段很酷的视频&#xff0c;展示了Ruby on Rails源代码的演变&a…

insert语句让我学会的两个MySQL函数

我们要保存数据到数据库&#xff0c;插入数据是必须的&#xff0c;但是在业务中可能会出于某种业务要求&#xff0c;要在数据库中设计唯一索引&#xff1b;这时如果不小心插入一条业务上已经存在同样key的数据时&#xff0c;就会出现异常。 大部分的需求要求我们出现唯一键冲突…

对PInvoke函数函数调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。...

C#引入外部非托管类库时&#xff0c;有时候会出现“对PInvoke函数调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配”的报错。 通常在DllImport标签内加入属性CallingConventionCallingConvention.Cdecl即可解决该问题。 如&#xff1a; [Dll…

Python字符串方法用示例解释

字符串查找方法 (String Find Method) There are two options for finding a substring within a string in Python, find() and rfind().在Python中的字符串中有两个选项可以找到子字符串&#xff1a; find()和rfind() 。 Each will return the position that the substring …

关于命名空间namespace

虽然任意合法的PHP代码都可以包含在命名空间中&#xff0c;但只有以下类型的代码受命名空间的影响&#xff0c;它们是&#xff1a;类&#xff08;包括抽象类和traits&#xff09;、接口、函数和常量。在声明命名空间之前唯一合法的代码是用于定义源文件编码方式的 declare 语句…

一 梳理 从 HDFS 到 MR。

MapReduce 不仅仅是一个工具&#xff0c;更是一个框架。我们必须拿问题解决方案去适配框架的 map 和 reduce 过程很多情况下&#xff0c;需要关注 MapReduce 作业所需要的系统资源&#xff0c;尤其是集群内部网络资源的使用情况。这是MapReduce 框架在设计上的取舍&#xff0c;…

huffman树和huffman编码

不知道为什么&#xff0c;我写的代码都是又臭又长。 直接上代码&#xff1a; #include <iostream> #include <cstdarg> using namespace std; class Node{ public:int weight;int parent, lChildren, rChildren;Node(int weight, int parent, int lChildren, int …

react 监听组合键_投资组合中需要的5个React项目

react 监听组合键Youve put in the work and now you have a solid understanding of the React library.您已经完成工作&#xff0c;现在对React库有了扎实的了解。 On top of that, you have a good grasp of JavaScript and are putting its most helpful features to use …

Unity 单元测试(PLUnitTest工具)

代码测试的由来 上几个星期上面分配给我一个装备系统,我经过了几个星期的战斗写完90%的代码. 后来策划告诉我需求有一定的改动,我就随着策划的意思修改了代码. 但是测试(Xu)告诉我装备系统很多功能都用不上了. Xu: 我有300多项测试用例,现在有很多项都无法运行了. 你修改了部分…

Best Time to Buy and Sell Stock II

题目&#xff1a; Say you have an array for which the i th element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multipl…

求给定集合的幂集

数据结构中说这个问题可以用类似8皇后的状态树解法。 把求解过程看成是一棵二叉树&#xff0c;空集作为root&#xff0c;然后遍历给定集合中的元素&#xff0c;左子树表示取该元素&#xff0c;右子树表示舍该元素。 然后&#xff0c;root的左右元素分别重复上述过程。 就形成…

angular 命令行项目_Angular命令行界面介绍

angular 命令行项目Angular is closely associated with its command-line interface (CLI). The CLI streamlines generation of the Angular file system. It deals with most of the configuration behind the scenes so developers can start coding. The CLI also has a l…

oracle-imp导入小错filesize设置

***********************************************声明*********************************************************************** 原创作品&#xff0c;出自 “深蓝的blog” 博客。欢迎转载&#xff0c;转载时请务必注明出处。否则追究版权法律责任。表述有错误之处&#xf…

CentOS 7 下用 firewall-cmd / iptables 实现 NAT 转发供内网服务器联网

自从用 HAProxy 对服务器做了负载均衡以后&#xff0c;感觉后端服务器真的没必要再配置并占用公网IP资源。 而且由于托管服务器的公网 IP 资源是固定的&#xff0c;想上 Keepalived 的话&#xff0c;需要挤出来 3 个公网 IP 使用&#xff0c;所以更加坚定了让负载均衡后端服务器…

八皇后的一个回溯递归解法

解法来自严蔚敏的数据结构与算法。 代码如下&#xff1a; #include <iostream> using namespace std; const int N 8;//皇后数 int count 0;//解法统计 int a[N][N];//储存值的数组const char *YES "■"; const char *NO "□"; //const char *Y…

即时编译和提前编译_即时编译说明

即时编译和提前编译Just-in-time compilation is a method for improving the performance of interpreted programs. During execution the program may be compiled into native code to improve its performance. It is also known as dynamic compilation.即时编译是一种提…

bzoj 2588 Spoj 10628. Count on a tree (可持久化线段树)

Spoj 10628. Count on a tree Time Limit: 12 Sec Memory Limit: 128 MBSubmit: 7669 Solved: 1894[Submit][Status][Discuss]Description 给定一棵N个节点的树&#xff0c;每个点有一个权值&#xff0c;对于M个询问(u,v,k)&#xff0c;你需要回答u xor lastans和v这两个节点…

.Net SqlDbHelper

using System.Configuration; using System.Data.SqlClient; using System.Data;namespace ExamDAL {class SqHelper{#region 属性区// 连接字符串private static string strConn;public static string StrConn{get{return ConfigurationManager.ConnectionStrings["Exam&…

C语言的一个之前没有见过的特性

代码&#xff1a; #include <stdio.h>int test(){int a ({int aa 0;int bb 1;int cc 2;if(aa 0 && bb 1)printf("aa %d, bb %d\n", aa, bb);//return -2;cc;});return a; }int main(){typeof(4) a test();printf("a %d\n", a); } …

如何构建顶部导航条_如何构建导航栏

如何构建顶部导航条导航栏 (Navigation Bars) Navigation bars are a very important element to any website. They provide the main method of navigation by providing a main list of links to a user. There are many methods to creating a navigation bar. The easiest…

SPSS聚类分析:K均值聚类分析

SPSS聚类分析&#xff1a;K均值聚类分析 一、概念&#xff1a;&#xff08;分析-分类-K均值聚类&#xff09; 1、此过程使用可以处理大量个案的算法&#xff0c;根据选定的特征尝试对相对均一的个案组进行标识。不过&#xff0c;该算法要求您指定聚类的个数。如果知道&#xff…

[ 总结 ] nginx 负载均衡 及 缓存

操作系统&#xff1a;centos6.4 x64 前端使用nginx做反向代理&#xff0c;后端服务器为&#xff1a;apache php mysql 1. nginx负载均衡。 nginx编译安装&#xff08;编译安装前面的文章已经写过&#xff09;、apache php mysql 直接使用yum安装。 nginx端口&#xff1a;80…

中国剩余定理(孙子定理)的证明和c++求解

《孙子算经》里面的"物不知数"说的是这样的一个题目&#xff1a;一堆东西不知道具体数目&#xff0c;3个一数剩2个&#xff0c;5个一数剩3个&#xff0c;7个一数剩2个&#xff0c;问一共有多少个。 书里面给了计算过程及答案&#xff1a;70*2 21*3 15*2 -105*2 2…

osi七层网络层_OSI层速成课程

osi七层网络层介绍 (Introduction) Have you ever wondered how data is sent through the network from one machine to another? If yes, then the Open System Interconnected model is what you are looking for.您是否曾经想过如何通过网络将数据从一台机器发送到另一台机…

KMP算法求回溯数组的步骤

KMP算法到底是什么原理就不说了&#xff0c;各种资料上讲的明明白白&#xff0c;下面我就如何用代码来实现做一下说明和记录. KMP的核心思想就是&#xff0c;主串不回溯&#xff0c;只模式串回溯。而模式串匹配到第几位时失配&#xff0c;要回溯多少&#xff0c;由模式串本身来…

【.Net】vs2017 自带发布工具 ClickOnce发布包遇到的问题

一、遇到的问题 在安装了vs2017 社区版&#xff08;Community&#xff09;之后 想打包安装程序&#xff08;winform&#xff09; 还是想用之前的 installshield来打包 发现居然打不了&#xff0c;在官网查了 installshield不支持社区版&#xff08;Community&#xff09;&…