portal123
asked on
Change margin-top at <a href>
Hello, If I set margin-top 30px; of the following image link by CSS. What do I need to??
<a href="b.html"><img src="a.jpg" border="1" width="300" height="100"></a>
<a href="b.html"><img src="a.jpg" border="1" width="300" height="100"></a>
ASKER
I'd like to keep top margin space 30px for href link
I put attribute margin-top:30px; in href tag with style. But, margin-top space could not be chnaged. I'd like to know how to make margin-top at <a href><img src="" border=""></a>
I made like <a href="b.html" style="margin-top:30px; margin-left:50px;"><img src="a.jpg" border="1" width="300" height="100"></a>.
margin-left works, but margin-top does not work. I would like to know how to do this.
I put attribute margin-top:30px; in href tag with style. But, margin-top space could not be chnaged. I'd like to know how to make margin-top at <a href><img src="" border=""></a>
I made like <a href="b.html" style="margin-top:30px; margin-left:50px;"><img src="a.jpg" border="1" width="300" height="100"></a>.
margin-left works, but margin-top does not work. I would like to know how to do this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> You can also make your link a block element using style="display: block".
But this has side effects.
But this has side effects.
ASKER
Thanks. I have one more question. If lining up two elements horizontally like <a href="a.html"><img src="a.jpg"></a> <a href="b.html"><img src="b.jpg"></a>, How can I set up CSS attribute?
What do you mean exactly?
First you should not use and use CSS instead.
And don't forget to supply an alt value for the images.
Example:
<span class="MyClass">
<a href="a.html"><img src="a.jpg" alt="a"></a>
<a href="b.html"><img src="b.jpg" alt="b"></a>
<span>
Then you define your styles in an external css file:
span.MyClass {
white-space: nowrap;
}
span.MyClass img {
margin-top: 50px;
border: 1px solid red;
}
First you should not use and use CSS instead.
And don't forget to supply an alt value for the images.
Example:
<span class="MyClass">
<a href="a.html"><img src="a.jpg" alt="a"></a>
<a href="b.html"><img src="b.jpg" alt="b"></a>
<span>
Then you define your styles in an external css file:
span.MyClass {
white-space: nowrap;
}
span.MyClass img {
margin-top: 50px;
border: 1px solid red;
}
Do you mean how can you specify CSS styles inline? Use the style="" attribute.
<a href="b.html" style="margin-top: 30px"><img src="a.jpg" border="1" width="300" height="100"></a>