Are there rules governing spacing before or after '</ >'?


Hello all
I’m not too sure how to phrase my question , but hopefully someone can help with an answer :
Are there rules governing spacing before or after ‘</ >’ ?
For instance , why is there a ‘space’ in line 5 after the word ‘currently’ , but no space before ‘Least’ in the same line?
I presume that at line 3 [ <div id= ] ‘<div’ has a space after ‘v’ , because there’s no closing ‘>’ ?
and finally , at line 11 for instance ,

'

Species

’ there are no spaces at all ?

So are there special rules/conventions/ to learn concerning these ‘spacings’ ?
Hope that makes some sense at least !

Cheers all

Hi, there.

So, let’s say we have these three examples:

<p>I am putting emphasis on a <strong>word</strong> in this sentence</p>
<p>I am putting emphasis on a<strong> word </strong>in this sentence</p>
<p>I am putting emphasis on a<strong>word</strong>in this sentence</p>

The output for those three lines of code would look like:

I am putting emphasis on a word in this sentence

I am putting emphasis on a word in this sentence

I am putting emphasis on awordin this sentence

In the first two examples, the strong tag is placed directly next to other words or white space, and the browser displays them the same. But for the third example, no spaces are given and so you get three words condensed into one.

But what about this example?

<p>I am putting emphasis on a <strong> word </strong> in this sentence</p>

How would this appear on screen?

I am putting emphasis on a word in this sentence

It looks exactly the same as the first two examples, even though there is additional space. Why is that? In this case, the browser detects that there are consecutive spaces and collapses them.

Simply put, the browser will typically ignore any extra spaces.

2 Likes

Thanks very much for this example , much appreciated info !

2 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.