Web Design Stuff
HTML Tutorials    CSS Tutorials    Web Hosting   Resources
Create a Web Page 101
Making Web Pages Intro What is a Web Page? Why Make a Web Page? The History of HTML Learn HTML or XHTML?
Basic HTML
Basic HTML Tutorials Basic HTML Necessities How to Make a Web Page How to Edit a Web Page The Basics of HTML Tags Basic HTML Page Structure HTML Attributes
HTML Font Codes
HTML Font Codes Intro HTML Font Color Codes HTML Font Size Codes HTML Font Style Codes HTML Bold/Italic Codes Combining Font Codes
Formatting Text
Formatting Text Intro Making Paragraphs Miscellaneous Formatting Headings & Subheadings Creating Hyperlinks
Using Graphics
Using Graphics on the Web Add Graphics to Your Pages Graphics and Accessibility How to Align Graphics Page Color & Background Graphics as Hyperlinks Horizontal Rules
Creating Tables
HTML Tables Tutorials HTML Table Fundamentals Background & Border Color Table Frames & Rules Table Width and Alignment Cells 1 -Space & Alignment Cells 2 -Row Column Span Cells 3 -Width & Height
Making Lists
HTML Lists Tutorials Bulleted Lists Numbered Lists Definition Lists
HTML Frames
HTML Frames Tutorials Using Frames for Layout Advanced Frame Layouts Putting Hyperlinks in Frames Frame Border Width Color, Margin and Control Problems with Frames SmartFrames: A Solution SSI: An Alternative to Frames
Web Page Forms
Making Feedback Forms A Simple Feedback Form Installing NMS FormMail Debugging Your Setup My Web Host is Out to Lunch User Input Components Text Fields Checkboxes & Radio Buttons Dropdown Menus Push Buttons Layout and Presentation
Basic CSS
Basic CSS Tutorials What is CSS? Why You Should Use CSS How to Use CSS Inline Styles Embedded Style Sheets External Style Sheets Class Selectors ID Selectors Combining Selectors
CSS Properties
CSS Properties Intro Font Styles Width, Height & Spacing Borders Backgrounds Position Float & Alignment Hyperlinks
All About Web Hosting
Hosting Your Own Website What is a Web Host? Your Website's Home Page Building a Website Offline About Free Web Hosting Best Free Web Hosting Commercial Web Hosting How to Get a Domain Name Ecommerce Web Hosting Web Hosting Terminology
Free Web Design Tools
Best Free Website Tools Best Free Text Editors Best Free Graphics Editors Free Website Analysis Tools
Setting Up HTML Kit
HTML Kit Introduction How to install HTML Kit Screenshot Breakdown Basic Configuration Overall Appearance Shortcuts and Startup Editing Window Customizing Toolbars Using the Favorites Tab Making a New Actions Bar Odds and Ends
Free Templates
Free Website Templates Two Column Fixed Width Three Column Liquid Layout Miscellaneous Templates Dynamic Menu Effects Two Column Experimental Terms of Use About These Templates
Website Templates Help
Getting Started Template Zip File Download How to Edit Your Template What to Edit in the HTML How to Add Your Logo Making a Website
Web Design Tips
Web Design Basics Tables vs. Tableless Using Tables for Layout Example Table Layouts World's Crappiest Web Page
Twitter Backgrounds
Twitter Backgrounds Intro Cool Twitter Backgrounds Cool Twitter Backgrounds 2 Plain Twitter Backgrounds Dark Twitter Backgrounds Best Twitter Backgrounds Cute Twitter Backgrounds Music Twitter Backgrounds Music Twitter Backgrounds 2 Twitter Backgrounds 101 TERMS OF USE
All About Web Browsers
What is a Web Browser? Mozilla Firefox Internet Explorer Opera How to Set Up Firefox Top 5 Firefox Extensions
 
Contact
Post Some Feedback Send Me An Email Iron Spider Blog About Iron Spider... Site Conventions
 
 
 

 

CSS Properties - Font Styles

 
The CSS properties in the table below can be used to define all manner of font stylings on your web page text. These properties may be applied to all HTML elements used in the document body (except the script element) which includes the following:

body, p, div, blockquote, A, table, tr, td, ul, ol, li, span, form, input, textarea, select

(Notice I did not include the font element in the above because essentially you won't be needing it anymore so you might as well just say your goodbyes right now and kick it to the curb once and for all. Meet the span element which will now take over most of your inline formatting needs.)


CSS Properties List 1 - Font Styles
Property NameSome Possible ValuesWhat It Does
font-family(Any font name)Sets the text typeface
font-size15px | 12pt | 0.5emSets the text size
font-weightbold | normalSet bold typeface?
font-styleitalic | normalSet italics typeface?
background(Any color) | url('example.jpg')Sets background
color(Any color)Sets the text color
line-height17px | normalSets line spacing


NOTES:
  • Pixels (px) ~ This sets the font-size or line-height in pixels. The syntax is any number followed by px. Example: font-size: 15px; (a nice size for a font). Use pixels for measurements when you want to closely control the font sizes on your web page. (More about pixels...)
  • Points (pt) ~ This sets a font-size or line-height in points. The syntax is any number followed by pt. Example: font-size: 12pt; (a nice size for a font). 1 point is the equivalent of 1/72nd of an inch. Measurements in points are typically used for printed material and hence some web authors feel more comfortable with this because they can 'relate' to it better than using pixels or ems. Be advised, however, that Macintosh and Windows display points measurements measurements differently (Macintosh displays smaller).
  • Ems (em) ~ This sets a font-size relative to the font-size of the parent element. The syntax is any number followed by em. Example: font-size: 0.5em; (displays font at half the size of the parent element font).

    A parent element is an element that contains another element. For example, in the following, the div element is the parent of the span element:


    <div><span style="font-size: 0.5em">This text will be displayed at half of font size of the parent DIV element.</span></div>


    The idea behind using em measurements is to use them throughout the web page so that all font sizes are relative to one another. This is ultimately predicated upon the base font size which is left to be defined by the user (by setting options in his web browser). If the user goes with the default browser settings then the base font size typically defaults to 3 (see font size). Hence em measurements are ideal for allowing the user define how big the font sizes should be. (Be advised that some users like really big text so this can produce some wacky results.)
  • Normal ~ This value takes on various meanings according to the CSS property it's used in. These are described in the following:

    • font-weight: normal; - The text is not rendered in bold type face.
    • font-style: normal; - The text is not rendered in italics.
    • line-height: normal; - The line height is rendered at what would be reasonable for the font-size being currently applied.
  • span (generic inline element) ~ The span element is a generic inline HTML element which will essentially replace the font element as you make the switch from formatting text with HTML to formatting text with CSS. It requires both start and end tags <span>...</span>, the latter of which does not force a line break in the visible text. In other words, it behaves just like the font element with the exception that it does not support any special attributes. You will primarily use it with core attributes such as id, class and style to apply CSS properties to the enclosed text.

    Here's an example of using the span element with the style attribute:


    <span style="font-family: arial;">Some text...</span>


    This is exactly the same as:


    <font face="arial">Some text...</font>


    However, the span element becomes much more robust when it's used with the class or id attribute in conjunction with an embedded or external style sheet.

EXAMPLES:

Here's an example of an inline style applied to a paragraph tag using some of the CSS properties described in the table above:


Example 1 - INLINE STYLE

<p style="font-family: verdana; font-size: 15px; font-weight: bold; font-style: italic; background: #ffffcc; color: green; line-height: 18px;">How now brown cow</p>



OR...

The same thing could be declared as an embedded stylesheet in the document head:


Example 2 - EMBEDDED STYLE SHEET

<style type="text/css">
<!--
p {
   font-family: verdana;
   font-size: 15px;
   font-weight: bold;
   font-style: italic;
   background: #ffffcc;
   color: green;
   line-height: 18px;

}
-->
</style>



...and in the document body, you would simply put this:


<p>How now brown cow</p>



Both Example 1 and Example 2 will produce the following effect:

How now brown cow

*   *   *


Okay so we got the font thing down.

Now to exercise some real fine control over your web page layout, you'll want to know what CSS properties will set widths, heights, padding and margin...






Best Free Stuff
for webmasters

Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates

See also:

Best Free Web Hosting
How to Make a Web Page

 

If you need a .COM web address, you can get one quick and easy at...

www.GoDaddy.com
INTRO TOP NEXT ~>
 
HTML Tutorials |  CSS Tutorials |  Web Hosting |  Domain Names |  Web Design Resources
Iron Spider © Copyright 2004-2011 Robert Darrell