Avinash Chandra
Avinash Chandra

Reputation: 183

Aligning the block of text with left and right margin

I have a block of text. I want to put a margin of 20% on the left side and margin of 30% on the right side. How can I acheive this using CSS?

Below is my code:

.style4 {
    float: left;
    margin-left: 20%;
    background-color: #e5e0dd;
    width: 68.1%;
    margin-right: 30%;
    border-left:30%;

    text-align: center;
    font-family: Calibri;
    font-size: small;
}

<div class="style4">
    This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.
</div>

Upvotes: 0

Views: 136

Answers (1)

nyxthulhu
nyxthulhu

Reputation: 9762

I think you may be looking to do padding rather than margin here.

padding-left: 20%; padding-right: 30%; 

Upvotes: 1

Related Questions