PrintedExistence[dot]com


(x)html & css


How to Code...




Donate


All this information & code is provided completely free of charge, but if you have some spare money, and wish to send me some for my trouble, please hit the button below!




JukeBox



Sponsor Ads





Text Styles







Font Face (with HTML)

The problem with fonts on the internet is, if you choose one that your visitors don't have installed on their computer, your text will display in their browsers default font. Since different fonts often take up different amounts of space this can make a real mess of your carefully designed page, so it's generally a good idea to stick to the basic fonts which come pre-installed on most computers. Here's the list:


<font face="Times">Some text in Times</font>

<font face="Georgia">Some text in Georgia</font>

<font face="Courier">Some text in Courier</font>

<font face="Arial">Some text in Arial</font>

<font face="Verdana">Some text in Verdana</font>

<font face="Trebuchet MS">Some text in Trebuchet MS</font>

<font face="Comic Sans MS">Some text in Comic Sans MS</font>


Its also worth noting that you can specify more than one font, so that if the user doesn't have the first font on the list, the browser will go through it in order until it finds one that they do, for instance:

<font face="Arial, Verdana, Trebuchet MS, Sans">Some Text</font>

The above tag would try to render the text first in Arial, then Verdana, then Trebuchet MS, and finally if none of those fonts are available, any sans serif font it can find.

Nb, Sans Serif fonts are the ones like Arial and Verdana, which don't have fancy bits on the end of the letters. Times and Georgia are Serif fonts (with fancy bits).

serif and sans serif fonts

top



Font Color (with HTML)

Color (always spelled the American way) can be set using the colors name, or its Hex code.

Browsers recognize an increasing number of color names, such as deeppink, purple, orange and red. You can find a full list of widely recognized color names [ on the w3schools website ]

Hex codes are a fully supported version of color names. Every shade of every color imaginable has a hex code. It's a 6 character code started with a # sign, for instance #ffffff is the hex code for white, and #000000 is black. You can find a pretty long list of hex codes on [ Webmonkey ].


<font color="purple">Here's how to set font color by name</font>

<font color="#0000ff">And here's how to set it with a hex code.</font>


You may have heard of "Websafe" colors...

In the bad old days, when the majority of computers struggled to show more than 256 colors, the websafe hexadecimal color chart was invented. It consisted of 216 colors that these systems could display cleanly. However, with the advent of modern technology, it's probably no longer necessary to take such precautions, since most computers can now display millions of colors.


top



Font Size (with HTML)

Font size can be one to seven. (Nb if you set your font with CSS you can use pt or px sizes, which allows you to be a lot more precise).


<font size="1">Some size 1 text</font>

<font size="4">Some size 4 text</font>

<font size="6">Some size 6 text</font>



top



Combining Font Tags

You can combine font face, size and color in the same tag:


<font color="blue" size="1" face="Courier">Some size 1 blue Courier text</font>

<font face="Times" size="4">Some size 4 Times text</font>



top



Font Style (with HTML)



<i>Some Italic Text</i>

<b>Some Bold Text</b>

<u>Some Underlined Text</u>

<strike>Some Struck Out Text</strike>

<div align="center">Some Centered Text</div>




top



Scrolling Marquees

You can use marquees to make text or images scroll.
Nb, marquees are not valid HTML 4.1, but they do still work in most browsers.

<marquee>Default marquees scroll left...</marquee>
<marquee behavior="scroll" direction="right">But you can make them scroll right by adding a direction</marquee>
<marquee behavior="scroll" direction="up">Up and Down work too!</marquee>

Marquees have other behaviors...
*NB You may have to refresh the page to see the slide marquee, and Firefox doesn't support it (it scrolls instead).

<marquee behavior="slide">Sliding Marquee*</marquee>
<marquee behavior="alternate">Alternate Marquees Kind of Bounce</marquee>

You can change the speed using scrollamount:

<marquee scrollamount="4">Scrollamount 4</marquee>
<marquee scrollamount="20">Scrollamount 20</marquee>
<marquee scrollamount="8">Scrollamount 8</marquee>

Scrolldelay lets you make your marquees pause:

<marquee scrolldelay="500" scrollamount="100">Scrolldelay 500</marquee>

Finally, you can get creative with your marquees, to get cool effects like this:
*(Nb Browsers other than IE, Firefox and Opera may struggle with marquees within marquees).

<marquee direction="up" behavior="alternate">
<marquee direction="right" behavior="alternate">
Bouncy Bouncy Text...*</marquee></marquee>


top



Making Lists

HTML supports 2 different types of lists.

Unordered lists are the ones that have some kind of bullet point. The types are:

  • square
  • disc
  • circle

and the code for writing an unordered list is:

<ul type="square">
<li> Item 1
<li> Item 2
<li> Item 3
</ul>

Secondly, there's ordered lists. These are the ones with letters, numbers, or roman numerals before the items. For a numbered list, type="1". For letters, type="a" or "A" (big letters). If you want numerals, then type should be "I". Finally if you want to start your numbered list from the middle, just set the type to the number you want to start from, eg, type="5".

The ordered list code is pretty similar to unordered. Just replace ul with ol:

<ol type="a">
<li> Item 1
<li> Item 2
<li> Item 3
</ol>


top



Making Text Links

Here's the code to make your text clickable:

<a href="http://www.page to link to.com"> Your Clickable Text Here </a>

If you want your link to open in a new window, just add target="_blank" into the link tag, eg:

<a href="http://www.page to link to.com" target="_blank"> Your Clickable Text Here </a>


top



HTML Vs CSS Methods

Talk to any web design geek, and they'll tell you that HTML font tags are depreciated and you shouldn't use them. They're half right- W3C (the body that sets web design standards) is in fact phasing the font tag out. But all this actually means is that people who design websites and choose to include a W3C doctype declaration for a version of HTML that doesn't support the font tag, won't be able to use font tags on their website if they want it to validate.


top



CSS Text Editing

As well as coloring individual bits of text, CSS also allows you to style large blocks of text all at once, or if you're styling a profile, bits you don't have access to directly so can't wrap font tags around.

HTML tags know which bit of text you want to edit because you wrap them around it. Similarly with CSS you have to identify the text you want to affect. Let's say you want to affect all of the text on your page. You should apply your styles to body (which means page body, or the entire page). Here's how:

<style type="text/css">
body { color: red; }
</style>

Most of the time you're going to want to edit more than one property of your text at once, and CSS makes this easy- you can just list the properties you want to change one after the other, like this:

<style type="text/css">
body {
color: red;
font-family: "Times New Roman", Times, serif;
font-size: 14px;
font-weight: bold;
font-style: italic;
text-decoration: underline;
letter-spacing: 5px;
font-variant: small-caps;
}
</style>

As you can see, CSS has a whole bunch of handy properties like text-decoration and letter-spacing that you don't get with plain HTML text formatting. For a full list of CSS text properties, [ Click Here ].


Being More Specific

So what if you just want to edit text in a certain table or div box? Well if it happens to be the only one on your page, or you want the text in all of your tables (or div boxes) to have these styles, you could just apply them to table (or div) like this:

<style type="text/css">
table {
color: red;
font-family: "Times New Roman", Times, serif;
}
</style>

Alternatively you can give the particular object you want to affect a class. A class is a sort of ID by which CSS can refer to it, for example:

<div class="mybox"> some text to style </div>

<style type="text/css">
.mybox {
color: red;
font-family: "Times New Roman", Times, serif;
}
</style>

Classes in CSS are always preceded by a dot, so that the browser knows it's looking for a class, rather than a tag to style. If you only want the styles to affect this one div or table, you also have the option of putting styles directly in its tag, like this:

<div style="color: red; font-family: "Times New Roman", Times, serif;"> some text to style </div>

top



Mouseover Links

CSS is great for messing with your text links, because you can edit the styles of unvisited, visited, and hover links separately (and so make them change color when the mouse hovers over them). There is actually a fourth link state, called "active" which is how the link looks when it has just been pressed, but since this only shows for a millisecond before the browser moves off to wherever the link leads, I'm going to skip it.

So let's take a look at the other link states.


and this is the CSS code that makes it the colors it is:

<style type="text/css">
a:link { color: maroon; }
a:visited { color: deeppink; }
a:hover { color: teal; }
</style>

The example link goes to the top of the page. If you've clicked on it, or any of the "top" links on this page, then you've been there before, and it will show up in the visited state color (deeppink) to begin with. If you haven't clicked a "top" link yet, it should be maroon (default unvisited link color). Finally, when you hover over it, it should change to teal (the hover color). Pretty simple, right?

Of course you can do things to your links other than change the colors. How about making it grow massive, and have a bright red background on hover, like this:

and the code:

<style type="text/css">
a:link { color: maroon; font-size: 10px; }
a:visited { color: deeppink; font-size: 10px; }
a:hover { color: teal; background: red; font-size: 16px; }
</style>

As you can see, you can set as many properties as you like for each of the different link states. For a full link of CSS text properties, [ Click Here ].


Styling Specific Links

If you only want to apply your styles to a few links on your page, you can stick them in a table or div, with a class, like this:

<div class="mylinkbox">
<a href="http://www.printedexistence.com">[ Link 1 ]</a>
<a href="http://www.vampirefreaks.com">[ Link 2 ]</a>
<a href="http://www.skem9.com">[ Link 3 ]</a>
</div>

Then just adjust your link styles so they only affect that div, ie:

<style type="text/css">
.mylinkbox a:link { color: maroon; font-size: 10px; }
.mylinkbox a:visited { color: deeppink; font-size: 10px; }
.mylinkbox a:hover { color: teal; background: red; font-size: 16px; }
</style>

top



CSS Text Properties



Color

For more information about colors and hex codes, see the [ HTML Color ] bit.


color: deeppink;

color: lime;

color: #990000;

color: #00ccff;





Font Family

For more information about fonts, see the [ HTML Fonts ] bit.


font-family: Arial, Helvetica, sans-serif;

font-family: 'Times New Roman', Times, serif;

font-family: 'Courier New', Courier, mono;

font-family: Georgia, 'Times New Roman', Times, serif;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-family: Geneva, Arial, Helvetica, sans-serif;





Font Size

Setting font size with CSS is a little different to HTML, because you have the benefit of a whole range of different measurements. Px (pixels) and pt (point) are the ones your probably going to want to use. They're a nice simple, fairly static measurements. The key difference between them is that px sizes change depending on the users screen resolution. Pt maintains its size regardless of screen rez.


font-size: 10px;

font-size: 12px;

font-size: 14px;

font-size: 10pt;

font-size: 12pt;

font-size: 14pt;





Background Color (links only)

For links, CSS has the option to set a background color just for the text. (nb you can't do this with plain text, as the equivalent style is used to set page background). You can set background color using color names or hex codes (see the [ HTML Color ] bit for an explanation of these).


background-color: orange;

background-color: #9999cc;

background-color: #990000;





Font Weight

Font weight is for making text bolder or lighter. Values include bold, bolder, light, and 100 (thin text), 200 (thicker), etc. upto 900. In small fonts the difference is negligible.


font-weight: bold;

font-weight: bolder;

font-weight: lighter;

font-weight: 400;   (400 is equivalent to normal text. Can also be "normal").

font-weight: 900;





Font Style


font-style: italic;

font-style: oblique;   (no it's not a mistake. Oblique text does look err.. rather like italic).




Text Decoration


text-decoration: none;   (can be used to erase the underline from links)

text-decoration: underline;

text-decoration: overline;

text-decoration: underline overline;

text-decoration: line-through;

text-decoration: blink;   (Supported by Firefox, Netscape & Opera)





Font Variant


font-variant: Small-Caps;





Letter Spacing


letter-spacing: 5px;

letter-spacing: 2px;

letter-spacing: 10px;



top



Opacity / Transparency

This code works in IE*, Firefox and newer versions of Opera. It may work in other browsers too, but these are the ones I've tested. If you want the text to fade in or out, you can use the [ IE fade ] filter, but that won't work in any browsers other than Internet Explorer. Opacity (in case your wondering) is simply the opposite to transparency. 100% Opaque is completely visible, while 100% transparent is completely invisible. Anyhow, on with the filters. Let's write over an image so you can see whats happening:


opacity demo

And here's the code:

<span style="width: 200px; height: 20px; filter: alpha(opacity=50); -moz-opacity: .50; opacity: .50;"> This code would produce 50% opacity!</span>

Nb, Opacity works on images too.

*Internet Explorer filters, including Opacity are not valid under HTML 4.1 when applied to text!


top



Glow / Shadow / Flip / Fade (IE Only)

Filters are not valid HTML 4.1 when applied to text like this, and they are still IE only though, other browsers will just see the plain text.

For filters to work, you must set the width and height of your text. Of course it's unlikely you know that off the top of your head, but approximate values are fine. Your text wont stretch, but too large a width or height will create a space around it in some browsers, and too small a width or height might cut off the edges of your filter. Once you preview your text and see what's happening, you can adjust your width or height accordingly. All these filters work on images too.



Glow Text (IE Only)
glow filter
<span style="width: 200px; height: 20px; filter: glow(color=deeppink, strength=5);"> Text Here </span>



Shadow Text (IE Only)
shadow filter
<span style="width: 250px; height: 20px; filter: shadow(color=teal, direction=200);"> Text </span>



Vertically Flipped Text (IE Only)
flipv filter
<span style="width: 200px; height: 20px; filter: flipv;"> Text </span>



Horizontally Flipped Text (IE Only)
fliph filter
<span style="width: 200px; height: 20px; filter: fliph;"> Text </span>



Fading Text (IE Only)
fade in filter
<span style="width: 200px; height: 20px; filter: alpha(opacity=0, finishopacity=100, style=1);"> Text </span>

fade out filter
<span style="width: 200px; height: 20px; filter: alpha(opacity=100, finishopacity=0, style=1);"> Text </span>


top



Sideways Writing (IE Only)

You can make your text appear sideways in the Internet Explorer browser using writing mode:

This text is sideways in IE!

<span style="writing-mode: tb-rl;"> some sideways text! </span>

top
All content copyright PrintedExistence.com 2006 - 2007 ©
PrintedExistence.com is a subsidiary of StephensPhoto™

W3c Valid XHTML  W3c Valid HTML  W3c Valid Css  Get Macromedia Flash Player  Viewable With Any Browser  PHP Powered  MySql Powered
preloading...