Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Creating a box around link

Posted on 2004-09-13
6
Medium Priority
?
181 Views
Last Modified: 2008-03-06
I am new to CSS and I was wondering if there is anyway to have a colored box around a link. The box will have a specfic background color, specfic height of 25, and no specfic width (it should adjust to fit the width of the cell it is in). The text in the box should be centered in the middle of the box. If you need more information please let me know. Thanks.
0
Comment
Question by:thecode101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 15

Accepted Solution

by:
Daydreams earned 375 total points
ID: 12048084
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<style type="text/css">
 a, a:link    {background-color:orange;text-decoration: none;display:block;height:25px;text-align:center;}
 a:visited {text-decoration: none;}
 a:hover   {background-color:yellow;text-decoration: none;}
</style>
<body>
<table><tr>
<td><a href="somelink.html">Click here</a></td></tr>
</table>
</body>
</html>
0
 
LVL 3

Author Comment

by:thecode101
ID: 12056358
Daydreams,
Thanks for your help that is what I want, except the text is not vertically aligned in the middle of the box. Is there anyway to make this change?
0
 
LVL 15

Expert Comment

by:Daydreams
ID: 12057371
Hi thecode101,

You could use padding:

(I changed the css somewhat here and added padding)

a {display: block; height:25px;background-color:blue;padding:10px; }
a:link    {text-align:center;text-decoration: none;}
a:visited {text-decoration: none;}
a:hover   {background-color:yellow;text-decoration:none;}

If you only want padding on the top and bottom, you can specify:
 padding-top:5px; padding-bottom:5px;

..or any value of padding you like.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Author Comment

by:thecode101
ID: 12057492
Thanks for your help, I will give you the points since you help give me the right idea. What I did instead was use:

 display:table-cell;
 height:25px;
 width:500em;  //If there is a better way to make it fill the width of the cell let me know =)
 text-align:center;
 vertical-align: middle

Since the width is set to such a high number, the width of each cell that it is in will never be greater then that. So, it takes up the whole width of the cell.

I don't know why but 100% width didn't work for me.
0
 
LVL 15

Expert Comment

by:Daydreams
ID: 12058155
>width:500em;  //If there is a better way to make it fill the width of the cell let me know

width:auto;
0
 
LVL 3

Author Comment

by:thecode101
ID: 12058191
I tried that but it does the same thing as 100% it only covers the text and not the width of the cell.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question