Re: How can I prevent spaces between <a> tags being rendered?
- From: Andy Dingley <dingbat@xxxxxxxxxxxxxx>
- Date: Mon, 18 Feb 2008 06:53:32 -0800 (PST)
On 18 Feb, 12:28, "mark4asp" <mark4...@xxxxxxxxx> wrote:
How can I prevent spaces between <a> tags being rendered?
By not embedding whitespace (spaces or linebreaks, or even a few
others) between the <a> tags that you embed in your HTML.
Whatever the rules for rendering HTML & CSS say, there are browsers
(infamously IE) that regard the appearance of any whitespace between
elements as an excuse to slip in rendered whitespace that's hard to
get rid of afterwards. Best option is to not give them the opportunity
in the first place.
Remember that you can place whitespace _inside_ tags quite easily,
including linebreaks (not everywhere inside a tag, but enough).
Rather than:
<a href="foo" >Foo</a>
<a href="bar" >Bar</a>
<a href="bat" >Bat</a>
You can use this, which doesn't have renderable whitespace yet is
still broken for source readability
<a
href="foo" >Foo</a><a
href="bar" >Bar</a><a
href="bat" >Bat</a>
Or even:
<a href="foo" >Foo</a
><a href="bar" >Bar</a
><a href="bat" >Bat</a
>
You _must_ keep a clear distinction in your mind between ASP, the HTML
that your ASP generates, and the rendered effects of your HTML + CSS,
if you're to get anywhere with server-side web development.
Find out what you _must_ have in your HTML (and what you must avoid),
to get the rendered behaviour you want.
Write ASP that generates exactly this HTML.
Don't try to fiddle with the ASP until the rendered effect happens to
look right. You'll go crazy. Slice the problem in two and get each
part right separately.
<div class="AspNet-GridView-Pagination AspNet-GridView-Bottom">
<span>1</span>
<a href="javascript:__doPostBack('gvAwarded','Page$2')">2</a>
<a href="javascript:__doPostBack('gvAwarded','Page$3')">3</a>
<a href="javascript:__doPostBack('gvAwarded','Page$11')">...</a>
<a
href="javascript:__doPostBack('gvAwarded','Page$Last')">>></a>
</div>
I'd also recommend avoiding the javascript: pseudo-protocol. Just use
the onclick event instead.
Here are my styles (these class names are automatically rendered by the
aforementioned asp.net GridView.)
font-size: 0.65em;
line-height: 19px;
font-size: 0.65em; is far too small, for anything except "flyspeck 3"
legalese in the most user-hostile of cases.
line-height: 19px; is also a bad idea in any conceivable context.
* Don't set it. It's very rare to ever need to do this.
* Set it in unitless dimensions, not pixels
* Certainly don't use it as a substitute for vertical spacing between
block elements. Use margin (or maybe padding).
.
- Follow-Ups:
- References:
- How can I prevent spaces between <a> tags being rendered?
- From: mark4asp
- How can I prevent spaces between <a> tags being rendered?
- Prev by Date: Re: Firefox not applying style...
- Next by Date: Re: How can I prevent spaces between <a> tags being rendered?
- Previous by thread: Re: How can I prevent spaces between <a> tags being rendered?
- Next by thread: Re: How can I prevent spaces between <a> tags being rendered?
- Index(es):
Relevant Pages
|
Loading