I am very new to web design and I would like help aligning p
elements on a web page, just like Tab aligns things in a word processor. I have the following code:
.tiny-ps {
display: block;
}
.big-ps {
display: none;
}
div.summary-container {
border: 2px ridge;
width: 100%;
font-weight: normal;
background-color: #eaeaea;
}
p {
font-family: Tahoma, Arial, Helvetica;
}
p.highlight {
display: block;
color: #ffffff;
font-weight: bold;
text-align: center;
}
p.highlight:nth-of-type(odd) {
background-color: #800000;
}
p.highlight:nth-of-type(even) {
background-color: #800020;
}
@media screen and (min-width: 500px) {
div.summary-container {
margin: 10px 0px;
}
p {
font-size: 12pt;
margin-bottom: 5px;
margin-top: 5px;
}
p.normal {
display: inline;
margin-right: 2%;
font-size: 12pt;
}
p.highlight {
display: block;
margin: 2px 0px 2px 0px;
font-size: 12pt;
}
.billName {
display: block;
}
.Norm9 {
font-size: 8pt;
}
.tiny-ps {
display: none;
}
.big-ps {
display: inline-block;
}
}
<div class="summary-container">
<p class="highlight">Address Correction: 3</p>
<p class="highlight"><span class="tiny-ps">Exped/Cour NOT Sent-Shipping: 5</span><span class="big-ps">Expedited/Courier Orders NOT Sent to Shipping: 5</span></p>
<p class="highlight"><span class="big-ps">Pickup Orders Not Sent to Shipping: 1</span><span class="tiny-ps">Pickups Not Sent-Shipping: 1</span></p>
<p class="highlight"><span class="big-ps">Liner Orders Not Sent to Shipping: 1</span><span class="tiny-ps">Liners Not Sent-Shipping: 1</span></p>
<p class="normal">Orders Shipped Today: 0</p>
<p class="normal">Order Received: 14</p>
<p class="normal">Payment Declined: 6</p>
<p class="normal">Payment Authorized: 3</p>
<p class="normal">Mgt Hold: 6</p>
<p class="normal">Order Sent to Shipping: 3</p>
<p class="normal">Pending Mgt Approval for PMT: 4</p>
<p class="normal">HELP ME: 1</p>
<p class="normal"><span class="big-ps">Expedited/Courier Orders Sent to Shipping: 2</span><span class="tiny-ps">Exped/Courier Sent to Shipping: 2</span></p>
</div>
What I cannot seem to figure out is how to get the text in the paragraphs to line up with the text in the other paragraphs and how to get the numbers to line up with each other. I want to do this without having to use a table
. I can change the markup a little and add class names, but I do not want to use a table. It would look something like this:
Can anybody help me with this? Thank you!
To align things in the inline direction, use the properties which begin with justify- . Use justify-content to distribute space between grid tracks, and justify-items or justify-self to align items inside their grid area in the inline direction.
I used Flexbox's justify-content and align-items properties, which respectively allow you to center elements horizontally and vertically. By setting both to center on the parent, the child element (or even multiple elements!) will be perfectly in the middle.
The purpose of this article is to display paragraph elements as inline elements using CSS. The display property in CSS is used for placing the components (“div”, “hyperlink”, “heading”, etc) on the web page. The display property is set to inline. It has the default property of “anchor” tags. It is used to place the “div” inline i. e.
To set the alignment of last paragraph to right, we use CSS text-align-last property. The text-align-last is used to set the last line of the paragraph just before the line break. The line break may be due to the natural ending of a paragraph, or it may be due to the use of <br> tag.
Vertical Alignment The vertical-align property sets the vertical alignment (like top, bottom, or middle) of the content in <th> or <td>. By default, the vertical alignment of the content in a table is middle (for both <th> and <td> elements). The following example sets the vertical text alignment to bottom for <td> elements:
To left-align the content, force the alignment of <th> elements to be left-aligned, with the text-align: left property: The vertical-align property sets the vertical alignment (like top, bottom, or middle) of the content in <th> or <td>. By default, the vertical alignment of the content in a table is middle (for both <th> and <td> elements).
You can use css 'display:inline-block' or 'display:inline-grid' and mention width.
.tiny-ps {
display: block;
}
.big-ps {
display: none;
}
div.summary-container {
border: 2px ridge;
width: 100%;
font-weight: normal;
background-color: #eaeaea;
}
p {
font-family: Tahoma, Arial, Helvetica;
}
p.highlight {
display: block;
color: #ffffff;
font-weight: bold;
text-align: center;
}
p.highlight:nth-of-type(odd) {
background-color: #800000;
}
p.highlight:nth-of-type(even) {
background-color: #800020;
}
p.normal {
display: inline-grid;
width: 30%;
float: left;
font-size: 11px;
}
<div class="summary-container">
<p class="highlight">Address Correction: 3</p>
<p class="highlight"><span class="tiny-ps">Exped/Cour NOT Sent-Shipping: 5</span><span class="big-ps">Expedited/Courier Orders NOT Sent to Shipping: 5</span></p>
<p class="highlight"><span class="big-ps">Pickup Orders Not Sent to Shipping: 1</span><span class="tiny-ps">Pickups Not Sent-Shipping: 1</span></p>
<p class="highlight"><span class="big-ps">Liner Orders Not Sent to Shipping: 1</span><span class="tiny-ps">Liners Not Sent-Shipping: 1</span></p>
<p class="normal">Orders Shipped Today: 0</p>
<p class="normal">Order Received: 14</p>
<p class="normal">Payment Declined: 6</p>
<p class="normal">Payment Authorized: 3</p>
<p class="normal">Mgt Hold: 6</p>
<p class="normal">Order Sent to Shipping: 3</p>
<p class="normal">Pending Mgt Approval for PMT: 4</p>
<p class="normal">HELP ME: 1</p>
<p class="normal"><span class="big-ps">Expedited/Courier Orders Sent to Shipping: 2</span><span class="tiny-ps">Exped/Courier Sent to Shipping: 2</span></p>
</div>
.tiny-ps {
display: block;
}
.big-ps {
display: none;
}
div.summary-container {
border: 2px ridge;
width: 100%;
font-weight: normal;
background-color: #eaeaea;
}
p {
font-family: Tahoma, Arial, Helvetica;
}
p.highlight {
display: block;
color: #ffffff;
font-weight: bold;
text-align: center;
}
p.highlight:nth-of-type(odd) {
background-color: #800000;
}
p.highlight:nth-of-type(even) {
background-color: #800020;
}
@media screen and (min-width: 500px) {
div.summary-container {
margin: 10px 0px;
}
p {
font-size: 12pt;
margin-bottom: 5px;
margin-top: 5px;
}
p.normal {
display: inline;
margin-right: 2%;
font-size: 12pt;
}
p.highlight {
display: block;
margin: 2px 0px 2px 0px;
font-size: 12pt;
}
.billName {
display: block;
}
.Norm9 {
font-size: 8pt;
}
.tiny-ps {
display: none;
}
.big-ps {
display: inline-block;
}
}
#num{
width: 5%;
text-align:left;
padding-block:initial;
}
#std{
text-align:left;
}
.cent{
margin-left: auto;
margin-right: auto;
}
<div class="summary-container">
<p class="highlight">Address Correction: 3</p>
<p class="highlight"><span class="tiny-ps">Exped/Cour NOT Sent-Shipping: 5</span><span class="big-ps">Expedited/Courier Orders NOT Sent to Shipping: 5</span></p>
<p class="highlight"><span class="big-ps">Pickup Orders Not Sent to Shipping: 1</span><span class="tiny-ps">Pickups Not Sent-Shipping: 1</span></p>
<p class="highlight"><span class="big-ps">Liner Orders Not Sent to Shipping: 1</span><span class="tiny-ps">Liners Not Sent-Shipping: 1</span></p>
<table class="cent">
<tr>
<td id="std"><p class="normal">Orders Shipped Today:</td><td id="num">0</p></td>
<td id="std"><p class="normal">Order Received: </td><td id="num">14</p></td>
<td id="std"><p class="normal">Payment Declined: </td><td id="num">6</p></td></tr>
<tr>
<td id="std"><p class="normal">Payment Authorized: </td><td id="num">3</p></td>
<td id="std"><p class="normal">Mgt Hold: </td><td id="num">6</p></td>
<td id="std"><p class="normal">Order Sent to Shipping: </td><td id="num">3</p></td></tr>
<tr>
<td id="std"><p class="normal">Pending Mgt Approval for PMT: </td><td id="num">4</p></td>
<td id="std"><p class="normal">HELP ME: </td><td id="num">1</p></td>
<td id="std"><p class="normal"><span class="big-ps">Expedited/Courier Orders Sent to Shipping: </td><td id="num">2</span><span class="tiny-ps">Exped/Courier Sent to Shipping: 2</span></p></td></tr>
</table>
</div>
Use CSS's text-indent
property.
p {
text-indent: 45px
}
Adjust the pixel value to whatever fits. You can also use a percentage value for responsive sites.
try this
Expedited/Courier Orders Sent to Shipping
you can also put in table
.tiny-ps {
display: block;
}
.big-ps {
display: none;
}
div.summary-container {
border: 2px ridge;
width: 100%;
font-weight: normal;
background-color: #eaeaea;
}
p {
font-family: Tahoma, Arial, Helvetica;
}
p.highlight {
display: block;
color: #ffffff;
font-weight: bold;
text-align: center;
}
p.highlight:nth-of-type(odd) {
background-color: #800000;
}
p.highlight:nth-of-type(even) {
background-color: #800020;
}
@media screen and (min-width: 500px) {
div.summary-container {
margin: 10px 0px;
}
p {
font-size: 12pt;
margin-bottom: 5px;
margin-top: 5px;
}
p.normal {
display: inline;
margin-right: 2%;
font-size: 12pt;
}
p.highlight {
display: block;
margin: 2px 0px 2px 0px;
font-size: 12pt;
}
.billName {
display: block;
}
.Norm9 {
font-size: 8pt;
}
.tiny-ps {
display: none;
}
.big-ps {
display: inline-block;
}
}
<div class="summary-container">
<p class="highlight">Address Correction: 3</p>
<p class="highlight"><span class="tiny-ps">Exped/Cour NOT Sent-Shipping: 5</span><span class="big-ps">Expedited/Courier Orders NOT Sent to Shipping: 5</span></p>
<p class="highlight"><span class="big-ps">Pickup Orders Not Sent to Shipping: 1</span><span class="tiny-ps">Pickups Not Sent-Shipping: 1</span></p>
<p class="highlight"><span class="big-ps">Liner Orders Not Sent to Shipping: 1</span><span class="tiny-ps">Liners Not Sent-Shipping: 1</span></p>
<table style="width:100%">
<tr>
<td>Orders Shipped Today:</td>
<td>0</td>
<td>Order Received:</td>
<td>14</td>
<td>Payment Declined:</td>
<td>6</td>
</tr>
<tr>
<td>Payment Authorized:</td>
<td>3</td>
<td>Mgt Hold:</td>
<td>6</td>
<td>Order Sent to Shipping:</td>
<td>3</td>
</tr>
<tr>
<td>Pending Mgt Approval for PMT:</td>
<td>4</td>
<td>HELP ME: 1</td>
<td>1</td>
<td>Payment Declined:</td>
<td>6</td>
</tr>
</table>
<p class="normal"><span class="big-ps">Expedited/Courier Orders Sent to Shipping: 2</span><span class="tiny-ps">Exped/Courier Sent to Shipping: 2</span></p>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With