Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML entitites - alternative to &nbsp?

I am a beginner with HTML (coming from a C background) and I came across the concept of HTML entities. I have some very basic questions regarding &nbsp.

  1. How does &nbsp entity introduce a non-breaking space within an element ?

  2. Is there any alternative to using the &nbsp entity in HTML ?

My internet searches have not given the answer I was looking for and some direction on these would be most appreciated.

like image 725
Siva Avatar asked Jul 16 '14 12:07

Siva


Video Answer


2 Answers

  is an alias for   or &xa0;. This character is defined as "non-breaking space" in the HTML standard. So someone said "browser must treat this is a space but not break a line" in a standard and all people who created Web browsers adhered to this standard.

If your editor supports it, you can also type this character. The browser doesn't care how it was created, only that it sees the byte 0xa0 in the input stream.

As an alternative, you can use various CSS styles and tricks to create lengths of text that won't break (for example with the style white-space: nowrap (see here) or by using padding / margins.

Related:

  • http://en.wikipedia.org/wiki/Non-breaking_space
like image 68
Aaron Digulla Avatar answered Sep 23 '22 08:09

Aaron Digulla


  1. &nbsp is simply a reference to a [particular] space character [see comments]. It renders in the font specified for its location.

  2. Sure. The space character. Or you can split the element and apply padding or margin via CSS.

like image 25
isherwood Avatar answered Sep 23 '22 08:09

isherwood