Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Linking CSS to HTML
healingsilver
post Mar 8 2005, 01:21 AM
Post #1





Guests






CODE


<LINK REL="StyleSheet" HREF="basic.css" TYPE="text/css" TITLE="Preferred Style" MEDIA="screen, projection">

<LINK REL="Alternate StyleSheet" HREF="altstyle.css" TYPE="text/css" TITLE="Alternate Style" MEDIA="screen">



Linking to an External Style Sheet
---

LINK tag
The link tag is used between the HEAD tags. It is the most common way to link CSS to HTML.

REL Attribute
The REL attribute defines the differences between a persistent or preferred style and an alternate style.
- Preferred style is the style that is automatically applied to the page.
- Alternate style is a style which the user could choose to replace the preferred style.


MEDIA Attribute
screen - (default value) for computer screens
print - output to a printer
projection - for projected presentations
aural - for speech synthesizers
braille - for presentation on braille tactile feedback devices
tty - for character cell displays (using a fixed-pitch font)
tv - for televisions
all - for all output devices


CODE


<LINK ... HREF="basic.css" ... TITLE="Preferred" ...>

<LINK ... HREF="tables.css" ... TITLE="Preferred" ...>

<LINK ... HREF="forms.css" ... TITLE="Preferred" ...>[/color]



Multipal Linked Style Sheets
You can have multipal preferred style sheets on the same page by simply linking them all, and giving each the same TITLE.


----------


CODE


<STYLE TYPE="text/css" MEDIA="screen">

<!--

 @import url(basic.css);

-->

</style>



Importing an External Style Sheet
---

@import
The @import statement must be the first thing that shows up in your STYLE tag before any other CSS is added. This is a second way of linking your CSS to HTML. It is used in conjunction with the LINK tag because older versions of Netscape didn't recognize the LINK tag. Because Internet Explorer picks up on both the LINK and @import tags, the LINK is put first, followed by the start of the STYLE tags and the @import as shown below.

CODE


<LINK ... HREF="basic.css" ... TITLE="Preferred" ...>



<STYLE TYPE="text/css" MEDIA="screen">

<!--

 @import url(basic.css);

-->

</style>




----------


CODE


<STYLE TYPE="text/css" MEDIA=screen>

<!--

 BODY { background: url(dog.gif); color: white; ... }

 P BR { background: yellow; color: black; ... }

 .th01 { color: black; ... }

-->

</STYLE>



Embedding a Style Sheet
---

Embedding a style sheet is the same as you would to @import one, except all the style sheet code is between the STYLE tags instead of on a seperate file.


----------


CODE


<P STYLE="color: black; font-family: Arial, ...">This paragraph has black font with Arial font.</P>



Enjoy :wink:
Go to the top of the page
 
+Quote Post
NAGISA
post Mar 10 2005, 02:46 AM
Post #2





Guests






Wooow that's a good summary.

Thanks for sharing it
Go to the top of the page
 
+Quote Post
scrtcrnr
post Mar 16 2005, 06:38 AM
Post #3





Guests






Which one is the better method, <link> or @import url()? I've heard that <link> is better, but I prefer @import because every of my styles are inside the <style> tag. Someone told me that @import isn't as efficient. I don't know why, though. Does anyone have any idea?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Your Favorite Html/webdesign Boards?(2)
  2. Basic HTML Tutorial(17)
  3. How Long Did it take you to learn HTML(78)
  4. More HTML templates(12)
  5. html pages in php-nuke(2)
  6. I need simple html editor script(3)
  7. html and php(7)
  8. php and html help(2)
  9. HTML(7)
  10. HTML(7)
  11. Can we use HTMl as first language(6)
  12. html in php(12)
  13. HTML(4)
  14. HTML(2)
  15. HTML/vWar Panel(0)
  1. Getting HTML source code of a remote page.(2)
  2. Need: Public_html file...(2)
  3. html(6)
  4. Need How MAny On HTML Code or etc.(2)
  5. html imput file(0)
  6. html imput select help(0)
  7. Javascript/HTML form submissions On a Mac(1)
  8. html bilder(4)
  9. How to send HTML mail to yahoo inbox(1)
  10. http://www.cheapdesign.co.uk/pulseradio/index.html(7)
  11. Newpass2.html malware(0)
  12. Does This Link Work For You?(6)
  13. Html Email(3)


 



- Lo-Fi Version Time is now: 23rd November 2008 - 12:29 AM