CSS can be used to custimize links and navigation menus. A navigation menu is basically a list of links.
At the bottom of this page there is a code editor pre-loaded with the lesson's code.
<ul>
<li><a href = "index.php">Home</a>
<li><a href = "blog.php">Blog</a>
<li><a href = "photos.php">Photo Gallery</a>
<li><a href = "https://www.facebook.com/codingcommanders/">Facebook</a>
</ul>;
If you are not familar with lists visit HTML Lists and CSS Lists. If you are not familar with <a> elements visit HTML Navigation.
When the user hovers over a link, changes often occur. Look at the menu below. What happens when you hoover over the links?
Notice the background turns white and the text turns black? That is done with the hover selector. Let's look at the code.
/* Text & background color on hover*/
a:hover {
color: black;
background-color: white
}
a:hover
<a> hover selector - For <a> elements, when hover is true:text color
- will be blackbackground-color
- will be yellow.<a href = "blog.php">Blog</a>
In the example menu, you may also have noticed the link text was white before you visited the associated page. Unvisited links are styled by the link selector.
a:link {
color: white;
}
➼ a:link
- <a> link selector -
The CSS code applies to unvisited links.
➼ color
Links that have Not been visited will have white text.
<a href = "blog.php">Blog</a>
The visited selector is used to style link that have already been visited. In the example menu, visited links have pink text.
a:visited {
color: pink;
}
➼ a:visited
- <a> visited selector -
The CSS code applies to unvisited links.
➼ color
The text color will be pink, for links that HAVE been visited.
<a href = "blog.php">Blog</a>
Once you click on a link, it becomes active
a:active {
background-color: hotpink;
}
➼ a:active
- <a> active selector -
The CSS code applies to active links.
➼ color
-
The text color will be pink, for links that HAVE been visited.
<a href = "blog.php">Blog</a>
a {
text-decoration: underline;
}
/* a selectors for myMenu class*/
/* Hover selector*/
.myMenu a:hover {
background-color: white;
color: black;
}
/* Unvisited Selector*/
.myMenu a:link {
color: white;
}
/* Visited selector*/
.myMenu a:visited {
color:pink;
}
/* Visited Hover*/
.myMenu a:visited:hover {
background-color: white;
color: black;
}
/* Active Selector*/
.myMenu a:active {
background-color: hotpink;
Note: The hoover selector can be applied to other elements, not just a links. It is common to use hover with buttons, links and list items.
Project - Part I: Is explained on the bottom of CSS Color Lesson.
Continue working on the ad you started in Part I.
Project -Part II Assignment: Create a Navigation Menu for your ad.
The menu should have links to:
1) www.codingcommanders.com
2) The ad you are making (from Project: Part I)
3) A new page you create (you choose the content!)
Happy Coding!