1

How do I enter the following code into CSS so that I don't have to copy and paste it in every HTML page?

ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
li
{
float:left;
}
a:link,a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
background-color:#7A991A;
}

My issue is especially with the "ul" and "li" -I am not sure what to do with this! Any help would be greatly appreciated- thanks!

4 Answers 4

2

Place your css in a separate file and use the following directive to make it accessible in each page:

<link href="url to stylesheet.css" rel="stylesheet" type="text/css">
Sign up to request clarification or add additional context in comments.

Comments

0

Place the html in a seperate .CSS stylesheet and reference it as:

<link href="url to stylesheet.css" rel="stylesheet" type="text/css">

To use the ul and li tags you would write something similar to this:

<ul>

<li>
            <a href="#">Item 2</a>
            <ul>
                <li><a href="">Sub Item 1</a></li>
                <li><a href="">Sub Item 2</a></li>
                <li><a href="">Sub Item 3</a></li>
            </ul>
        </li>
        <li>
            <a href="#">Item 3</a>
            <ul>
                <li><a href="">Sub Item 1</a></li>
                <li><a href="">Sub Item 2</a></li>
                <li><a href="">Sub Item 3</a></li>
            </ul>
        </li>
        <li>
            <a href="#">Item 4</a>
            <ul>
                <li><a href="">Sub Item 1</a></li>
                <li><a href="">Sub Item 2</a></li>
                <li><a href="">Sub Item 3</a></li>
            </ul>
        </li>   
    </ul>

2 Comments

I have already created a style sheet. My issue is with how I would input the code into it. For instance, would I need to create tags for <div id=" "> or <ul id=" "> and, if so, how would I go about doing this?
you would do <ul id ="">
0

Create a CSS file and link it to your HTML file.

Comments

0

Add your css in separate .css file and call it in html file

<!DOCTYPE html >
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css" /> 
</head>
<body>
</body>
</html>

Comments

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.