0

I have a footer, which has a horizontal menu.

CSS

footer {
    height:99px;
}
ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    font-size: 20px;
    padding-top:26px;
}
li {
    float:right;
    width:8%;
}

I want to make it so that when I make other menus, the css for the footer menu won't affect it. What would be an effective method for this? The html is just a basic <footer> tag.

1 Answer 1

4

In this case, you can use descendant relationship, where you say apply the style to ul elements which comes inside a footer element.

footer {
    height:99px;
}
footer ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    font-size: 20px;
    padding-top:26px;
}
footer ul li {
    float:right;
    width:8%;
}

If you want to be more specific(if you might have multiple footer elements in the page) you can assign a class to the footer like myfooter then use the class selector also like

footer.myfooter {
}
footer.myfooter ul {
}
footer.myfooter ul li {
}

Have a look st the different CSS selctors

Sign up to request clarification or add additional context in comments.

1 Comment

An id, e.g., #myFooter, might be more appropriate than a class, since it applies to only one footer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.