HTML Tutorial


 /help/HTML Help Forum   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
CSS link size conflict
Post new topic   Reply to topic    HTML Help Forum -> CSS
View previous topic :: View next topic  
Author Message
iblum



Joined: 22 Aug 2005
Posts: 5

PostPosted: Mon Aug 22, 2005 10:05 am     CSS link size conflict Reply with quote

I am using Cascading Stylesheets in my website, so that I'm able to have links in different size in the same page. For example, I want regular links to be size 12 px, and links at the bottom of the document, smaller size 10 px.
I created 2 external stylesheets (so that I can use them in all the pages in the website). It seems that the 2nd stylesheet overrides the 1st one and all the links on the page are small 10 px.

The first one is mainfont.css:
a:link {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
}
a:active {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #333333;
}
a:visited {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #660066;
}
a:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #333333;
}
.mainfont {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
}


THE SECOND ONE is smalllink.css:

a:link {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #666666;
}
a:visited {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #666666;
}
a:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #666666;
}
a:active {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #999999;
}
.regulartext {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #666666;
}

I attached the stylesheets in the page:
<link href="mainfont.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
-->
</style>
<link href="smalllink.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
-->
</style>

When I have Regular links in the page, that are supposed to be size 12, they still look small - size 10 px, even though I put CLASS=mainfont:

<p class="mainfont"><a href="#" class="mainfont">test</a></p>
Corey Bryant
Site Admin


Joined: 15 May 2004
Posts: 8748
Location: Castle Pines North, CO USA

PostPosted: Mon Aug 22, 2005 10:24 am     Re: CSS link size conflict Reply with quote

iblum wrote:
It seems that the 2nd stylesheet overrides the 1st one and all the links on the page are small 10 px.

Hence the meaning of cascading styles.

You almost have it right. Try something like:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<style type="text/css">
a:link {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
}
a:active {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #333333;
}
a:visited {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #660066;
}
a:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #333333;
}
.mainfont {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
}
a.small:link {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #666666;
}
a.small:visited {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #666666;
}
a.small:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #666666;
}
a.small:active {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #999999;
}
.regulartext {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
color: #666666;
}
</style>
</head>
<a href="http://www.cnn.com">Hyperlink One</a>
<a class="small" href="http://www.yahoo.com">Hyperlink Two</a>
<body>

</body>

</html>
iblum



Joined: 22 Aug 2005
Posts: 5

PostPosted: Mon Aug 22, 2005 11:08 am     CSS link size conflict Reply with quote

thanks a lot. it worked!
Corey Bryant
Site Admin


Joined: 15 May 2004
Posts: 8748
Location: Castle Pines North, CO USA

PostPosted: Mon Aug 22, 2005 11:20 am     Reply with quote

Anytime - good luck with the site!
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum -> CSS All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial