Tech-101 Free Computer Support Tech-101 Free Computer Support

Home Forum FAQs Terms of Service
Go Back   Tech-101 Free Computer Support > General > Web Design and SEO
Connect with Facebook

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-2010, 09:13 AM
rev_olie's Avatar
Super Moderator

 
Join Date: Apr 2009
Location: UK
Posts: 549
Send a message via MSN to rev_olie Send a message via Yahoo to rev_olie
Default CSS: Pseudo Classes

Hey,

We have been delving into CSS and XHTML at Uni and just need to double check on CSS Pseudo Classes.

Say I had the following:
Code:
a:link {color:#FF0000;}      /* unvisited link */
a:visited {color:#00FF00;}  /* visited link */
a:hover {color:#FF00FF;}  /* mouse over link */
a:active {color:#0000FF;}  /* selected link */

attributed to W3Schools http://www.w3schools.com/css/css_pseudo_classes.asp
Where would that go?
If it went on the CSS Style sheet how would you define the hyper-link in the main page?

But it if went in with the HTML would it go in the head section? Which again implies how do you define the link you want to effect
Or would it actually go around the hyper-link?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!twitterShare on Facebook
Reply With Quote
  #2 (permalink)  
Old 02-08-2010, 10:40 AM
Blind Dragon's Avatar
Site Admin

 
Join Date: Dec 2008
Location: Florida
Posts: 1,498
Send a message via MSN to Blind Dragon Send a message via Yahoo to Blind Dragon Send a message via Skype™ to Blind Dragon
Default

jobeard can probably give a better answer on this but...

If you put it in the CSS file (better option) you would define the link normally. Unless you wanted to get specific. I'll explain near the end.

HTML Code:
<a href="YOUR LINK">YOUR LINK TEXT</a> 
If you put it in the html file, then you would include it in the header.

The order you define these in is important. If you rearrange them your hover effects may stop working, as they will be overridden.

Let's say you only wanted to apply it to your navigation bar.

You could use something like:

HTML Code:
a.nav:link {color: #FF0000; text-decoration: none; }
a.nav:visited {color: #00FF00; text-decoration: none; }
a.nav:hover {color: #FF00FF; text-decoration: underline; }
a.nav:active {color: #0000FF; }
Then on your html page you would use:
HTML Code:
<a class="nav" href="YOUR LINK">YOUR LINK TEXT</a> 
Quote:
how would you define the hyper-link in the main page
In your scenario, i don't see any reason to define the link, unless you wanted to only apply it to a certain portion of the page like I said above with the navbar, in which case you would define it with a class
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!twitterShare on Facebook
Reply With Quote
  #3 (permalink)  
Old 02-08-2010, 11:14 AM
jobeard's Avatar
Site Admin

 
Join Date: Dec 2008
Location: Southern Calif.
Posts: 1,176
Default

well done

Order is important as noted, but you can still use the < style > ... </ style > anywhere (albeit poor programming 'style' ).

There's a performance boost to having external style.css files; the server can load them in parallel to the xxx.html or yyy.php primary file.
External files also make the base content more readable via View Source.
The HEAD is the ideal location for all CSS stylesheets.
[hint: for debugging, I use inline styles in the body until I get what I want
and then externalize the sheet and move the include into the head. ]

Caution: a:hover was not supported in IE, so use onMouseOver() and onMouseOut() Javascript to do the same thing by changing the class name or directly altering the background or text colors.

BD make a point on deciding which object will be effected by what css.
Typically, you can use class="name" (which can be applied to multiple objects even of different HTML tags),
the id="unique_id" which can only be applied ONCE in the HTML,
or a context HTML tag sequence, eg: div table tr td p {something}
would only apply to the P inside a CELL.

I think that < span ...> visible html </ span> is the ONLY time we wrap CSS around html content.
__________________
J. O. Beard; you + tech-101.com => synergism. Secure your system now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!twitterShare on Facebook
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:55 AM.

Copyright © 2009 Tech-101.com. All rights reserved.

Tech-101 Free Computer Support Tech-101 Free Computer Support