Changing the background color and text color on hover using CSS

Is there a way for the menu to change both the background and text color when I hover over it? Currently, my CSS only changes the background color but not the text color. Any help would be appreciated.

a:hover
{
    color: #231f20;     //for new text color (not working)
    background-color: #ffffff;     //for new background color (working)
}

Answer №1

It seems like I grasp your point now. The reason it didn't work before was due to the way you were attempting to comment out the code using // instead of /*.

Below is the updated version:

a:hover
{
    color: #231f20;     /*for text new colour (not worked)*/
    background-color: #088a68;     /*for background new colour (it worked)*/
}
<a href="...">Small Example</a>
<br>
<a href="..." style="font-size: 50px">Big Example</a>

Check out the live example here: https://jsfiddle.net/yn16bxsv/

I hope this clears things up for you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a Rails application that dynamically fills a table with data from a

Encountering an issue with Ruby on Rails. I have a "Host Model" that contains a method which has a longer runtime. class Host < ActiveRecord::Base def take-a-while # implement logic here end Attempting to access a page where this method ru ...

Aurelia TypeScript app experiencing compatibility issues with Safari version 7.1, runs smoothly on versions 8 onwards

Our team developed an application using the Aurelia framework that utilizes ES6 decorators. While the app works smoothly on Chrome, Firefox, and Safari versions 8 and above, it encounters difficulties on Safari 7.1. What steps should we take to resolve th ...

Utilize Jsoup to retrieve a specific value from a designated HTML source

I am currently working on a project that involves extracting all currency values and their corresponding names from a specific website. These extracted values need to be stored in two separate arrays. While researching online, I came across some code snip ...

Javascript function fails to trigger when clicked

<body ng-app="starter"> <ion-pane> <ion-header-bar class="bar-dark"> <h1 class="title">AppifyLife</h1> </ion-header-bar> <ion-content> <center><div class="card" id="life"><h3>20< ...

Issue with IE7 causing rollover navigation blocks to disappear when hovering over content

While conducting browser testing on the website The website's top navigation menu includes rollover effects for building services, exterior services, and commercial categories. The CSS-triggered navigation works seamlessly in all browsers except for ...

Adding a new row to an HTML table using JavaScript

In the code snippet below, I am facing an issue with adding a row to an HTML table and inserting it into a database. I have tried using JavaScript to add the row in order to avoid postback, but so far, I have been unsuccessful. Can someone assist me in t ...

nyroModal automatically adapts its dimensions according to the size of the webpage, not the size of

A situation has arisen with a link that opens an image using nyroModal. While everything is functioning correctly, the Modal window appears in the center of the page instead of aligning with the middle of the browser window. As a result, only the upper por ...

A guide on extracting a div element without a class using Html Agility Pack

Can you help me extract the text 'Galatasaray.' from the HTML code below? I'm not sure how to specify it properly. <div class="dRib1"> <h2>Information</h2> </div> <div>Galatasaray.</div> ...

The jQuery Show Hide feature is experiencing issues specifically on Internet Explorer

Everything looks good in Firefox and Chrome, but unfortunately it's malfunctioning in IE. Does anyone have a suggestion for hiding select Dropdown options? I attempted using CSS with display: none but it didn't work. $j("#id option[value=&apos ...

Styles applied in the child component will have a cascading effect on the entire webpage

My webpage is divided into two parts: child1 and child2. Page Hierarchy: Parent Child1 Child2 Here are the CSS styles included in the page: Child1 -> z-index: 1 Child2 -> z-index: 2 What I want to achieve is to add a backdrop to the entire ...

Adjusting elements in Material UI without distorting them

Struggling with resizing a select component from material UI led to some unexpected challenges. Despite attempting to adjust the size using the className property, the label ended up misaligned and the selection shade appeared larger than the select box it ...

Enable a button or class to dynamically alter its color

Hi there! I'm new to coding and just started learning HTML and CSS. My question is: How can I change the color of buttons once they are clicked? <div class="icon-bar"> <a href="#"><i class="fa fa-search" ...

Tips for customizing the WooCommerce product page

If you want to customize the layout of a WooCommerce product page, you can override the template by copying the WooCommerce template folder into your theme. You can find step-by-step instructions here. I am looking to change the layout of a WooCommerce pr ...

How can I improve the smoothness of my CSS transition when resizing background images?

I'm currently working on creating an intro movie for a game and I thought it would be interesting to use CSS animations. However, I've noticed that some parts of the animation appear bumpy and inconsistent. It seems that depending on the transiti ...

Creating tables with equal column width in Bootstrap 5

Is there a method to ensure equal width for all columns in a bootstrap table? By default, it appears to allocate more space to columns with larger content, but I want them all to have the same width. Below is my code: <table class="table table-hove ...

Google Extension PHP Plugin

Is it feasible to integrate a PHP file into a Google Extension for Chrome? I've been exploring the idea of creating an extension and most resources only mention HTML, CSS, and JavaScript. Any guidance on using PHP in the extension would be highly valu ...

List without order - item position in the list

I currently have a website featuring 5 pages, with the main navigation displayed using an unordered list. My goal is to have the "active" page displayed first in the list. For example, if my pages are "Home | About | Contact | Blog" and the user is on the ...

Step-by-step instructions on including an href and img tag using JavaScript

My issue arises when I include a href link and an img tag in javascript, as the image fails to display. html='<div id="iw-container">'+'<a ><div class="iw-title">Hot Pot Restaurant </div> </a>'+ name+"< ...

Styling columns with full height using CSS Flexbox

I'm currently experimenting with Flexbox to design a basic two-column webpage that stretches across the entire width and height. The left column has a fixed width of 200px, while the right column uses up the rest of the space. Here's what I have ...

Tips for aligning text to the right and button to the left while ensuring responsive design with CSS

Trying to align text on the left and the button on the right with space between them in a responsive card design. The button has a background image added to it. Here is my attempted CSS, but the design is not yet fully responsive: .component { disp ...