-1

When I do this

<li class="language">
   <a href="felt.php?lang=en">en</a>
   <a href="felt.php?lang=jp">jp</a>
   <a href="felt.php?lang=ru">ru</a>
</li>

it gives me space between the a tags, with space

with space

but when I do

  echo '<li class="language">';
  echo '<a href="felt.php?lang=en">en</a>';
  echo '<a href="felt.php?lang=jp">jp</a>';
  echo '<a href="felt.php?lang=ru">ru</a>';
  echo '</li>';

It takes away the spaces. why is this? I have not applied any css...

MaxiGui
  • 6,190
  • 4
  • 16
  • 33
KAZ
  • 11
  • 1
  • 2

2 Answers2

0

It is because you are writing it wrong, you should write it like:

echo '<li class="language">
    <a href="felt.php?lang=en">en</a>
    <a href="felt.php?lang=jp">jp</a>
    <a href="felt.php?lang=ru">ru</a>
    </li>';

In your case, the echo will consider it as inline so it will delete the space, if you want to keep your structure you can always add it like:

echo '<li class="language">';
echo '<a href="felt.php?lang=en">en</a>';
echo ' ';
echo '<a href="felt.php?lang=jp">jp</a>';
echo ' ';
echo '<a href="felt.php?lang=ru">ru</a>';
echo '</li>';
MaxiGui
  • 6,190
  • 4
  • 16
  • 33
0

In php echo doesn't add any space or new line in the end of output.
This code

  echo '<li class="language">';
  echo '<a href="felt.php?lang=en">en</a>';
  echo '<a href="felt.php?lang=jp">jp</a>';
  echo '<a href="felt.php?lang=ru">ru</a>';
  echo '</li>';

will be translated as if you write html in one line.

<li class="language"><a href="felt.php?lang=en">en</a><a href="felt.php?lang=jp">jp</a><a href="felt.php?lang=ru">ru</a></li>

And if you care how browsers treat whitespace Mozilla have a good article - How whitespace is handled by HTML, CSS, and in the DOM

Alex
  • 21
  • 4