Welcome to WebmasterWorld Guest from 54.226.241.8

Forum Moderators: incrediBILL

Message Too Old, No Replies

Should There Be a Space Before </li>

     

gouri

6:00 pm on May 25, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I am using XHTML 1.0 Transitional and saw coding for lists in two ways.

One way has a space before the </li> tag begins and one does not. Which is the proper way to write this?

<ul>
<li>I went to the park. </li>
<li> I went to the mall. </li>
</ul>

or

<ul>
<li>I went to the park.</li>
<li> I went to the mall.</li>
</ul>

Should I leave a space before the < in </li> and the . at the end of the sentence? Is either way okay?

I would appreciate your thoughts.

birdbrain

6:06 pm on May 25, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there gouri,

I would not leave any spaces, either after the opening
tag or before the closing tag.

If spacing is required, then use precise CSS padding to
achieve it.

birdbrain

gouri

6:31 pm on May 25, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



@birdbrain,

Thanks for the response.

So you would go with the second one. That one is coded the way that it should be?

birdbrain

6:46 pm on May 25, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there gouri,

It is not really a case of right or wrong. :)

A space before the closing tag makes no difference to the outcome,
whereas a space after the opening tag will indent the text.

By habit, I don't leave space on either side. ;)

birdbrain

drhowarddrfine

7:53 pm on May 25, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is your reasoning for putting a space in? At one time, in certain situations, IE would mess up formatting and a space would fix that but I don't recall if that's still true. At least, I've not run into it lately.

Why are you using XHTML or transitional?

lucy24

8:13 pm on May 25, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



a space after the opening tag will indent the text

This depends on the browser. A "conforming user-agent" may choose to ignore any whitespace after any opening tag, along with any whitespace before any closing tag. Useful to know if you habitually use inverse markup, like <i>switching italics </i>off<i> and on again</i>. (You shouldn't be doing this anyway, but it can occur. Yes, I intentionally used html markup rather than Forums markup.)

gouri

12:22 am on May 26, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Thanks for the responses, everyone.

@drhowarddrfine,

What is your reasoning for putting a space in?

Do you mean the space before </li> ? I saw both ways (with a space and without) on the Internet, and I was trying to figure out what is the proper way to code the bullet points.

Why are you using XHTML or transitional?

That's what the template uses. What would you recommend using?

g1smd

1:11 am on May 26, 2013 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Many would recommend HTML 4.01 Strict or HTML 5.

gouri

2:27 am on May 26, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Thanks for the recommendations, gs1md.

Can you tell me why these would be better?

drhowarddrfine

3:17 am on May 26, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



@gouri Transitional doctypes were created for those transitioning from older, obsoleted HTML back in 1999 to HTML4. New web pages should never be using obsolete markup. You should always be in strict mode.

While HTML4.01 strict doctype is fine, the idea is to keep the browser in strict mode and the newer, so-called "HTML5 doctype" does just that. Plus it's a lot shorter and easier to remember. Also note, there is no "5" in this doctype as it really has nothing to do with the version number:
<!DOCTYPE html>

While I capitalized doctype, it's not necessary with HTML5 though that breaks from every other standard that requires it to be capitalized.

gouri

2:19 am on May 31, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Thanks for the explanation and telling me how to write the DOCTYPE.

kishor insight

5:16 am on Jun 4, 2013 (gmt 0)



I would not leave any spaces, either after the opening
tag or before the closing tag.

If spacing is required, then use precise CSS padding to
achieve it.

[edited by: incrediBILL at 6:02 am (utc) on Jun 4, 2013]
[edit reason] Removed SIG see TOS [/edit]

Mike Spancer

12:12 pm on Jun 14, 2013 (gmt 0)



Spaces are not used in HTML tags either opening tag or closing.

-Mike

gouri

3:37 pm on Jun 14, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I appreciate the responses.

Dether

12:19 pm on Jan 13, 2014 (gmt 0)



More than one space doesn't matter. And you should code in that way to have readable code. To do some spacing and view modifications use css.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month