Hi
i want to know how to make space within hyperlinked text or images for example:
<a href="http://www.daniweb.com">daniweb</a>
<a href="http://www.daniweb.com">daniweb 2</a>
so the output will be

Daniweb daniweb 2

if add <BR> instead of </a> then it's now what i mean it's out put is that
daniweb
daniweb 2

is there any way to make space like that "Dani web Daniweb 2 "?

Thanks in advance
Svmer

Dani AI

Generated

Browsers collapse runs of ordinary spaces, so the visible gap between inline links will usually be a single space. As noted, that is the default; and suggested the inline-entity workaround and warned against using structural tags incorrectly. A more robust, maintainable approach is to control spacing with CSS rather than trying to force extra spaces in the HTML output.

Use one of these CSS options (wrap the links in a container and target them):

/* modern, simple: flex layout with a gap */
.nav { display: flex; gap: 1rem; align-items: center; }
/* target links as boxes and give them room */
.nav a { display: inline-block; margin-right: 16px; }
/* insert a fixed spacer before each following link */
.nav a + a::before { content: ""; display: inline-block; width: 20px; }

From PHP, emit the links inside a container and add a class (for example "nav" or per-link classes) so the CSS above applies. Prefer CSS so spacing adapts with responsive layouts and can be changed globally without altering PHP output. For compact navs, the gap approach is simplest; for older browser support, margin on inline-block items is safest.

For background on why raw spaces collapse and on the CSS properties used, see MDN: Whitespace and gap (Flexbox/Grid).

Recommended Answers

All 5 Replies

You can use &nbsp; in HTML code to give space.

can you be a little more specific I think you have to use a paragraph or somethin' but replacing the end tag of <a> with <br /> its a big NO .. I think you know why oif you'll try it :)

Matricol, typing slowly just for you,,
no mention of replacing end tags was made, you appear foolish

Svmr
browsers display differently some add a space where there is a carriage return in the source, some do not, better to ensure the space with a no-break space as written by vibhadevit above
the character string &nbsp; where you want a space to appear, after the first end anchor bla </a> &nbsp;

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.