I have this
sentence 1 <br />
sentence 2

I need to control their vertical spacing using XHTML or PHP
How do I do that??
Thanks
Steve

Dani AI

Generated

Nice question, — and good pointer from . The right tool here is CSS: use line-height to change spacing inside a block of text, and use margin or padding to control space between block-level elements. Avoid using line-break tags purely to add vertical space; they force a break but are not intended for layout (see MDN: line-height and MDN: br element).

Here are simple, practical rules and examples you can drop into your stylesheet:

/* control spacing inside paragraphs and between them */
p {
  line-height: 1.6;    /* unitless preferred so it scales with font-size */
  margin: 0 0 1em 0;   /* space after each paragraph */
}

/* if you must insert a visual spacer (use sparingly) */
.spacer {
  display: block;
  height: 1rem;
}

If you need PHP to output spacing, have PHP emit semantic HTML with classes and keep styling in CSS (better than inline styles). Example:

echo '<p class="lead">Sentence one</p>';
echo '<p>Sentence two</p>';

Quick tips: prefer unitless line-height so spacing scales with font-size, and use margins between blocks instead of repeated breaks.

Recommended Answers

All 2 Replies

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.