Hopstream
Hopstream

Reputation: 6451

Is it redundant to set same style and padding for UL and LI?

Is it necessary to do the following:

ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

ul li {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

Or is just having these styles on ul sufficient?

Is there a browser compatibility reason for having it on both?

Upvotes: 1

Views: 87

Answers (1)

Milche Patern
Milche Patern

Reputation: 20452

No, it is not unnecessary.

ul { /* this is an unordered list */
    list-style-type: none;
    padding: 0;
    margin: 0;
}

ul li { /* this is an unordered list item */
    list-style-type: none; /* perhaps only this is redundant. */
    padding: 0;
    margin: 0;
}

UL are basicaly displayed has block elements while LI are displayed has list-items.

You might have to style them separately, and redundance is because the 'list-style' is inherited.

Upvotes: 3

Related Questions