Re: How can I prevent spaces between <a> tags being rendered?



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')">&gt;&gt;</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).


.



Relevant Pages

  • Re: Poll: Line continuation
    ... That's how HTML does it, using the <tags>. ... > Too bad VB doesn't treat whitespace as whitespace like HTML ...
    (microsoft.public.vb.general.discussion)
  • Keeping whitespace in responseText, etc.
    ... I'm trying to access the source of an HTML page with as few alterations ... returns and tabs) within tags and between tags. ... all non-line-feed whitespace within tags and all whitespace in general ... a better version of the XMLHttpRequest object's responseText method? ...
    (comp.lang.javascript)
  • Re: Kirks group is a clone of RMCR with an important exception
    ... currently reading in context) the HTML used (<PRE tags) results in ... loads of whitespace and big gaps between lines of text. ...
    (rec.music.classical.recordings)
  • Re: Kirks group is a clone of RMCR with an important exception
    ... currently reading in context) the HTML used (<PRE tags) results in ... loads of whitespace and big gaps between lines of text. ...
    (rec.music.classical.recordings)
  • Re: Remove HTML from String?
    ... If you're concerned about prevent browsers from rendering the HTML in ... affective than trying to remove the tags. ...
    (comp.lang.ruby)

Loading