Domanda

mi sono chiesto se posso usare <p>&nbsp;</p> (solo spazio al punto), invece di <br />

Perché amo per mantenere il mio codice semantico e pensato che se questo è giusto è stato mi dà fastidio per un po 'di tempo. Ho visto i redattori WYSIWSG (TinyMCE) utilizzare questo, ma ho ancora piuttosto chiedo poi farlo male.

È stato utile?

Soluzione

Cosa c'è di sbagliato con l'utilizzo i margini dei paragrafi per verticale spaziatura invece?

<p>Hello World</p>
<p>This is much cleaner than using empty tags with non-breaking spaces.</p>

Altri suggerimenti

Non è "semantica", un paragrafo vuoto è qualcosa che più o meno non può esistere, semanticamente. Esso non contiene informazioni, vale a dire senza contenuto semantico. Tutto ciò che fa è cambiare il layout visivo, vale a dire la presentazione.

Sei molto meglio con lo stile di modificare i margini, bordi o imbottitura per ottenere l'effetto che stai cercando.

Il modo giusto per farlo è con i CSS: utilizzare il margin-top o margin-bottom

.

<p>&nbsp;</p> è abbastanza orribile ... preferirei vedere <br> di quello (anche se può essere meno "corretto").

<p>&nbsp;</p> is not semantic, so I don't know how that helps you.

You should set the space between the paragraphs with css.

I advocate wrapping items in block-level tags, such as divs and ps. This way I don't need either. If you want to space out elements, you should be using margins. You can be more accurate with margins anyway.

In a situation where you're forced to have a line break, use <br />: it, unlike empty paragraph tags, actually does mean 'line break'. There's almost always a better way to do things though.

It's HTML. You can use whatever it wants as long as you're sure it will render the way you wanted on all the browsers you're gonna use. I don't understand what you mean by "keep my code semantic" so I'm not sure what your issue with <br> is. But if you're talking about formatting and such, turn to CSS.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top