No, auto margin will not resize a paragraph element. It just tries to automatically determine the appropriate field size in areas with an automatic element size. Basically, if you want a paragraph to be smaller than the div containing it, you can set the static width of the paragraph (s) as a specific width or percentage of the inner width of the parent element. Another option, if you do not want to make the static size of the paragraph (s), should be to install an addition to the parent element or set static fields in the paragraphs.
div.paragraph-container { padding: 20px; /* or padding: 20px 20px 20px 20px; sets all the padding individually (top, right, bottom, left) */ }
This will make all paragraphs centered inside the div and will be 40 pixels smaller if paragraphs have no margins.
div.paragraph-container p { margin: 10px 20px; /* sets the margin on the paragraph(s) to 10px on top and bottom and 20px on left and right which does the same as the first example assuming that the div does not have padding. */ }
If you want the border to be exactly the width of the text, follow these steps:
div.paragraph-container p { border-bottom: 1px dotted black; padding: 0px 0px 5px 0px; margin: 10px 20px; } div.paragraph-container { padding: 0px; }
Assuming the text fills the paragraph element, this will work. If there are 2 words in a paragraph, it will not be as wide as the text. The only way to pull this out is with an inline element, such as a span or an element that has been set to display: inline; , but inline elements will be mixed side by side unless you place a block element between them.
txpeaceofficer09
source share