CSS – Set Width for Paragraph
To set a specific width for Paragraph element using CSS, set width property with required value for the selected paragraph elements in styles(inline/external).
Example
In the following HTML script, we have set width property for paragraphs with different values.
index.html
</>
Copy
<!DOCTYPE html>
<html lang="en">
<head>
<style>
p {
border: 1px solid;
}
#p1 {
width: 50px;
}
#p2 {
width: 150px;
}
#p3 {
width: 250px;
}
</style>
</head>
<body>
<p>Default paragraph.</p>
<p id="p1">Paragraph 1.</p>
<p id="p2">Paragraph 2.</p>
<p id="p3">Paragraph 3.</p>
</body>
</html>
Conclusion
In this CSS Tutorial, we learned how to set width for paragraph element(s) using CSS.