CSS text format
Text Color
The color property is used to set the color of text.
Colors are most often specified via CSS:
A hexadecimal value - such as "#FF0000"
An RGB value - "RGB (255,0,0 )"
The name of the color - such as "red"
The background color of a web page refers to the selection within the body:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> body {color:red;} h1 {color:#00ff00;} p.ex {color:rgb(0,0,255);} </style> </head> <body> <h1>多些書(shū)卷氣 少些書(shū)生氣</h1> <p>人有書(shū)卷氣,氣質(zhì)美如蘭。有書(shū)卷氣的人,身上有那么一股淡淡的書(shū)香,透著墨的芬芳,留著硯的韻味,帶著紙的氣息。 千百年來(lái),那一縷縷飄逸的書(shū)香,把一批批文人志士熏陶和浸潤(rùn)得文雅儒雅、優(yōu)雅高雅。</p> <p class="ex">漫步歷史長(zhǎng)廊,洋溢書(shū)卷氣的人不勝枚舉</p> </body> </html>
of the text Alignment
#The text alignment property is used to set the horizontal alignment of text.
Text can be centered or aligned to the left or right, justified on both ends.
When text-align is set to "justify", each line is expanded to have equal width, and the left and right margins are Alignment (such as magazines and newspapers).
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <style> h1 {text-align:center;} p.date {text-align:right;} p.main {text-align:justify;} </style> </head> <body> <h1>CSS text-align 實(shí)例</h1> <p class="date">xxxx 年 x 月 xx號(hào)</p> <p class="main">有一個(gè)年輕人去買(mǎi)碗,來(lái)到店里他順手拿起一只碗,然后依次與其它碗輕輕碰擊,碗與碗之間相碰時(shí)立即發(fā)出沉悶、渾濁的聲響,他失望地?fù)u搖頭。 然后去試下一只碗。。。他幾乎挑遍了店里所有的碗,竟然沒(méi)有一只滿意的,就連老板捧出的自認(rèn)為是店里碗中精品也被他搖著頭失望地放回去了。</p> <p><b>注意:</b> 重置瀏覽器窗口大小查看 "justify" 是如何工作的。</p> </body> </html>
Text decoration
The text-decoration property is used to set or delete text decoration.
From a design perspective, the text-decoration attribute is mainly used to remove the underline of the link:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> a {text-decoration:none;} </style> </head> <body> <p>鏈接到: <a href="#">php.cn</a></p> </body> </html>
You can also decorate the text like this:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <style> h1 {text-decoration:overline;} h2 {text-decoration:line-through;} h3 {text-decoration:underline;} </style> </head> <body> <h1>好好學(xué)習(xí)</h1> <h2>原價(jià)¥30</h2> <h3>現(xiàn)價(jià)¥10</h3> </body> </html>
Text conversion
Text conversion properties are used to specify uppercase and lowercase letters in a text.
can be used to make all words uppercase or lowercase, or to capitalize the first letter of each word.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <style> p.uppercase {text-transform:uppercase;} p.lowercase {text-transform:lowercase;} p.capitalize {text-transform:capitalize;} </style> </head> <body> <p class="uppercase">This is some text.</p> <p class="lowercase">This is some text.</p> <p class="capitalize">This is some text.</p> </body> </html>
Text indent
The text indent property is used to specify the indent of the first line of text.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> p {text-indent:30px;} </style> </head> <body> <p>無(wú)疑的,這些人都在做著一個(gè)相同的動(dòng)作:玩手機(jī)。 令人感到諷刺的是,盡管電視的廣告里不斷地重復(fù)著“不做低頭族,出行更安全”的提醒,可這些聚精會(huì)神的“低頭族們”壓根就當(dāng)沒(méi)聽(tīng)見(jiàn)似的, 繼續(xù)旁若無(wú)人地玩著手機(jī)不把自已的生命當(dāng)回事兒。有些用微信在聊天,有些在玩手游,有些在看影視劇,有些打電話等等。</p> </body> </html>
All CSS text properties.
text-indent Indent the first line of text in the element
text-shadow Set the text shadow
text-transform Control the letters in the element
unicode-bidi Set or return whether the text is rewritten
vertical-align Set the vertical alignment of the element
white-space Set the processing method of white space in the element
word-spacing Set word spacing