目录
[1]文字阴影 [2]首行缩进 [3]水平对齐 [4]垂直对齐 [5]字间隔 [6]字母间隔 [7]文本转换 [8]文本修饰 [9]空白符 [10]文本换行 [11]文本溢出 [12]文本方向文字阴影(IE8-不支持)
text-shadow:none(默认)text-shadow:[颜色color] x轴位移(x-offset) y轴位移(y-offset) 模糊半径(blur-radius),*
[注意]不要加太多层阴影,会有性能问题
【文字阴影代码查看】
首行缩进
text-indent:0(默认值)text-indent:具体值(可以为负值)text-indent:x%(相对于包含块的宽度)text-indent:2em(2个汉字的字体大小)
[注意]text-indent只可用于块级元素,且可继承
【悬挂缩进】
div{ width: 200px; border: 1px solid black; text-indent: -1em;//关键代码 padding-left: 1em;//关键代码}
【首字下沉】
<style>div{ width: 200px; border: 1px solid black; text-indent: 0.5em;}div:first-letter{ font-size: 30px; float: left;}
水平对齐
text-align: left(左对齐)text-align: right(右对齐)text-align: center(居中对齐)text-align: justify(两端对齐)(IE浏览器无效)
[注意]text-align只应用于块级元素,且可继承
div:nth-child(1){text-align: left;}div:nth-child(2){text-align: right;}div:nth-child(3){text-align: center;}div:nth-child(4){text-align: justify;}
垂直对齐
【1】行高
line-height属性是指文本行基线之间的距离
行间距 = line-height - font-size
line-height: normal;(默认) line-height: 100%/1em/16px;(%相对于元素的字体大小)line-height: 1;(1表示缩放因子,相对于当前元素的字体大小)
[注意]行高适用于任何元素,且可继承
【2】垂直对齐文本
vertical-align:baseline(基线对齐)vertical-align:sub(下标)vertical-align:super(上标)vertical-align:bottom(底端)vertical-align:text-bottom(文本底端)vertical-align:top(顶端)vertical-align:text-top(文本顶端)vertical-align:middle(居中)vertical-align:(+-n)px(元素相对于基线上下偏移npx)vertical-align:x%(相对于元素的line-height值)
[注意]vertical-align只用于行内元素和替换元素,且不可继承
字间隔(单词间距)
word-spacing:normal(默认normal=0)word-spacing:具体值(可为负值)
[注意]单词之间用空格分开,单词之间的间距 = word-spacing + 空格大小
字母间隔(字符间距)
letter-spacing: normal(默认normal=0)letter-spacing: 具体值(可为负值)
[注意]word-spacing和letter-spacing都可用于所有元素,且可继承
文本转换
text-transform:none(默认)text-transform:uppercase(全大写)text-transform:lowercase(全小写)text-transform:capitalize(首字母大写)
[注意]text-transform可用于所有元素,且可继承
文本修饰
text-decoration: none(默认,无修饰)text-decoration: overline(上划线)text-decoration: line-through(中划线或删除线)text-decoration: underline(下划线)
[注意]text-decoration可用于所有元素,但不可继承
空白符(IE7-不支持pre-wrap和pre-line)
空白符是指空格、制表符和回车;HTML默认会把所有空白符合并成一个空格
white-space:normal;(默认)white-space:pre;(保留空白符,且防止文本换行)white-space:nowrap;(防止文本换行)white-space:pre-wrap;(保留空白符,文本正常换行)white-space:pre-line;(合并空白符,但保留换行符)
[注意]white-space可用于所有元素,但不可继承
<div>They can stay 72-hours within the Shandong province after they have entered China via the Qingdao International Airport.</div>
文本换行
word-wrap:normal(默认)word-wrap:break-word(截断单词换行,长单词从下一行开始)word-break:normal(默认)word-break:break-all(截断单词换行,长单词占据当前行剩余空间)word-break:keep-all(不允许截断单词[包括汉语],长单词从下一行开始)
文本溢出
text-overflow:clip(文本裁剪)text-overflow:ellipsis(显示省略标志)
【常用文本溢出代码】
text-overflow:ellipsis;//显示省略标志 white-space:nowrap;//强制不换行overflow: hidden;//溢出隐藏
文本方向(IE8-不支持)
direction:ltr(normal,left to right)direction:rtl(right to left)unicode-bidi:normalunicode-bidi:embedunicode-bidi:bidi-override

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
