Вы находитесь на странице: 1из 4

mobile_libraries@ncsu.edu.

http://userslib.com/category/library-websites/
http://www.freewebtemplates.com/users/freecsstemplate
In a typical CSS statement you have the following:
* SELECTOR { PROPERTY: VALUE }
"Property" is the CSS element you wish to manipulate and "VALUE" represents the
value of the specified property.
CSS Selector Name
The selector name creates a direct relationship with the HTML tag you want to ed
it. If you wanted to change the way a paragraph tag behaved, the CSS code would
look like:

<p style="background: blue; color: white;">A new background and


font color with inline CSS</p>

p.first{ color: blue; }


p.second{ color: red; }
HTML Code:
<html>
<body>
<p>This is a normal paragraph.</p>
<p class="first">This is a paragraph that uses the p.first CSS code!</p>
<p class="second">This is a paragraph that uses the p.second CSS code!</p>
...

Bookmark and Share


CSS Text
While CSS Font covers most of the traditional ways to format your text, CSS Text
allows you to control the spacing, decoration, and alignment of your text.
Advertise on Tizag.com
Text Decoration
Have you ever wondered how a website removed the underline that usually accompan
ies a link's text? This is done by removing text-decoration from the link. To le
arn how to create these types of links, please check out our CSS Links tutorial.
Besides the utility with links, text-decoration allows you to add horizontal li
nes above, below, or through your text.
CSS Code:
h4{ text-decoration: line-through; }
h5{ text-decoration: overline; }
h6{ text-decoration: underline; }
a { text-decoration: none; }
p { text-align: right; }
h5{ text-align: justify; }
p { text-transform: capitalize; }
h5{ text-transform: uppercase; }
h6{ text-transform: lowercase; }
p { white-space: nowrap; }
(scroll bar
p { word-spacing: 10px; }
p { letter-spacing: 3px; }

* default - Display the normal mouse cursor icon


* wait - The mouse icon to represent the computer "thinking"
* crosshair - A cross hair reticle
* text - An "I" shaped icon that is displayed when selecting text
* pointer - A hand icon that you see when you hover over an HTML link
* help - A question mark (usually)
CSS Cursor Code
Now let's try these puppies out. Here are a few cursor code examples that should
help you customize your site.
CSS Code:
p { cursor: wait }
h4 { cursor: help }
h5 { cursor: crosshair }

Display:
Hi, I am happy to see you.
Hi, I am happy to see you.
Hi, I am happy to see you.
Note: All sentences below originally were, "Hi, I am happy to see you." With the
use of the text-transform CSS attribute we were able to modify the capitalizati
on.
CSS White Space
The white-space attribute allows you to prevent text from wrapping until you pla
ce a break <br /> into your text.
CSS Code:
p { white-space: nowrap; }
Display:
This paragraph will not wrap until I tell it to with a break tag. As you can see
, it makes the page look
quite ugly.
In the above paragraph the page break occurred after "... page look", which caus
ed the text to resume on the following line.
Note: We set a CSS overflow property, above, so that the example could be shown
more readily.
CSS Word Spacing
With the CSS attribute word-spacing you are able to specify the exact value of t
he spacing between your words. Word-spacing should be defined with exact values.
CSS Code:
p { word-spacing: 10px; }
Display:
This paragraph has a word-spacing value of 10px.
CSS Letter Spacing
With the CSS attribute letter-spacing you are able to specify the exact value of
the spacing between your letters. Letter-spacing should be defined with exact v
alues.
CSS Code:
p { letter-spacing: 3px; }
Display:
This is a paragraph with letter-spacing of 3px.

Bookmark and Share

* Go Back
* Continue

Found Something Wrong in this Lesson?


Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improvin
g with time!
Try it out!
<html> <head> <style> body { text-align: justify; } p { text-transform: capitali
ze; } h2 { letter-spacing: 5px; } ul { word-spacing: 10px; } </style> </head> <b
ody> <h2>CSS Text</h2> <p>This paragraph was written in traditional english, but
text-transform is making every first letter capitalized. We also have the body
set to justify text. This makes for a nice, crisp looking website. Please feel f
ree to experiment with CSS Text and replace our CSS code with your own.</p> <ul>
<li>This list has a word-spacing</li> <li>value of 10px</li> <li>Very neat</li>
</ul> </body> </html>

* p { PROPERTY: VALUE }

Creating Internal CSS Code


CSS code is not written the same way as HTML code is. This makes sense because C
SS is not HTML, but rather a way of manipulating existing HTML. Below is an exam
ple of some simple, yet fully functional, CSS code.
CSS Code:
<html>
<head>
<style type="text/css">
p {color: white; }
body {background-color: black; }
</style>
</head>
<body>
<p>White text on a black background!</p>
</body>
</html>

CSS Code:
body{ background-color: gray;}
p { color: blue; }
h3{ color: white; }
Now save the file as a CSS (.css) file. Make sure that you are not saving it as
a text (.txt) file, as notepad likes to do by default. Name the file "test.css"
(without the quotes). Now create a new HTML file and fill it with the following
code.
HTML Code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="test.css" />
</head>
<body>
<h3> A White Header </h3>
<p> This paragraph has a blue font.
The background color of this page is gray because
we changed it with CSS! </p>
</body>
</html>
Then save this file as "index.html" (without the quotes) in the same directory a
s your CSS file. N

Вам также может понравиться