I am trying to set the the attributes (border, width, etc) of a href tag using CSS.

But it is being very annoying!

Padding is working and color and thats just about it.

Width, height, borders (only see 2/3 out of the 4 sidded box), etc.

Any ideas?

Thanks, Regards X

PS: Note when I use the style on other tags there are different outcomes.

Recommended Answers

All 6 Replies

A href tag is only link, you can't set border, height, width.

These attributes you can set to any <div id="">, <img> tags and other, which be bounded between <a href="#"></a>.

Show here your code, because we don't know, what you need create with code.

pretty much just using css to make a href a box.

style="border: 3px solid; etc";

so you saying if i encapsulate it inside a div tag it will work?

E.g. like this

In HTML file will be:

<a href="#"><div id="box">Active box</div></a>

In CSS file will be:

#box{
	width: 160px;
	height: 180px;
	background-color: black;
	border: 3px solid #A2A2F2;
	color: white;
	font-size: 36px;
}

This is only short example..

sounds cool ill try it and get back to you, thankyou :)

That won't validate - it's tag soup.

The anchor tag is an inline tag, and you can't put a block tag pair inside an inline tag pair. Div is a block tag.

You can't put box properties on inline tags either.

Put the anchor inside the div instead, and attach the box properties to the div.

Thats what I thought so should be like:

<div>
 <a href>
  LINK
 </a>
</div>

Thats it?

Been to busy at work to test it.

Regards, X

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.