The background color is not displaying

As a programming novice, I received an assignment from my teacher but despite following the instructions, the colors do not appear on the page when opened.

My goal is to create a gradient background color within the main element, but unfortunately, it does not display. Here is the code I am using:

main
/*background-image:url(pics/bg.jpg);    background-repeat:repeat-y; background-color:#FFAA00;*/

#grad {
  background: -webkit-linear-gradient(left, #FFF, #F80);   /*   For Safari  5.1 to  6.0 */
  background: -o-linear-gradient(right, #FFF, #F80);   /*   For Opera   11.1    to  12.0    */
  background: -moz-linear-gradient(right, #FFF, #F80);   /* For Firefox 3.6 to  15  */
  background: linear-gradient(to right, #FFF, #F80);   /*   Standard    syntax  */
}

Even simplifying it to main {background-color: blue;}, the background remains white. Any assistance would be greatly appreciated!

Answer №1

It's effective for me, just be sure to accurately name the tags you're styling (and ensure they have a height like the other elements mentioned):

body {
  background-image:url(pics/bg.jpg); 
  background-repeat:repeat-y; 
  background-color:#FFAA00;
}
  
#grad {
  height: 100%;
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  background:-webkit-linear-gradient(left, #FFF,#F80); 
  /* For Safari 5.1 to 6.0 */
 }
  
<div id="grad"></div>

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

How to use JQuery to parse an external JSON file with array elements in Javascript

My goal is to extract information from an external JSON file using JavaScript, specifically an array and other elements. The JSON file I am working with is called 'TotalUsers.json' {"@version":"1.0", "@generatedDate":"12/20/10 5:24 PM", "day":[{ ...

Retrieve the identifier of the parent li element

We have an HTML structure shown below. A jQuery function is triggered when the click me link is clicked. Is it possible to retrieve the id of the enclosing li element from this function? If yes, how can this be achieved? <ul> <li id="20"> &l ...

Utilizing PHP to create a form via email

I have created this form and I would like to know if it is secure enough. I attempted multiple times to implement a captcha system, but unfortunately, it did not work for me. As I am still a student, please refrain from sending overly complex solutions. Q ...

When the Bootstrap navbar is collapsed, clicking on it does not result in it opening

I'm attempting to create a collapsible navbar for smaller screens that expands when a button is clicked. However, upon clicking the button, nothing happens and I'm unsure why. <nav class="navbar navbar-expand-lg navbar-light" style="backgro ...

Create a media query that targets both print and screen devices, specifying a minimum width condition

I am in need of a stylesheet that works well for both print and screens with decent width. When I write the following code, I expect it to be clear: @media print or (screen and (min-width: 801px)) { Rules here } Unfortunately, this code does not ach ...

"Creating dynamic webpage designs with CSS for responsive layouts

Currently, I am in the process of building a website utilizing a CSS fluid layout approach which is rooted in adaptive and responsive web design principles. For this project, I am avoiding using fixed values such as pixels (px) and instead opting for perc ...

Update the dropdown menu using jQuery when resizing

I am seeking a solution to adjust the behavior of my dropdown menu based on the screen resolution, utilizing jQuery. Currently, I have set it up so that above 1024px, the ul.level-2 menu is triggered by hovering over the button, and below 1024px, it respo ...

Display a div when collapsing in Bootstrap for screen widths of 991px or smaller

I am currently working on optimizing the mobile version of my website using Bootstrap. There is a div element that is taking up too much space on the page, and I would like to hide it on page load for screen widths of 991px or less. I want users to have th ...

Can Puppeteer be utilized for converting PDFs to HTML format?

Is it possible to convert PDF to HTML in addition to HTML to PDF? I haven't come across any resources that address this specific conversion process. ...

Is there a way to switch between showing and hiding without my navigation menu expanding?

I am currently working on creating an index for a large list. However, I have encountered an issue where clicking on a letter to display its contents also pushes the other letters on the index bar (left nav) down. I want the other letters to stay collapsed ...

Obtaining a list of child span elements using xpath in Selenium

I am looking to retrieve all child span elements based on the following xpath //label[@for='someText']/span Expected result: <span class="someClass">"Find this text"</span> <span id="someId">" ...

The Twitter Bootstrap 3 navbar on the right side, positioned outside the collapsible navbar

When using Twitter bootstrap 2.3.2, I could implement the following code snippet: http://jsfiddle.net/aQwUZ/3/ <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> ...

Guide for saving and loading text data on an HTML file with JavaScript

I have a textarea and two buttons to save or open files. Here is the basic HTML structure: <form name="form1"> <textarea name="text1"> HTML Codes goes here </textarea> <input type="button"> Open File <input type="button"> Sa ...

What causes an iframe to scroll horizontally when scaled?

I'm in the process of resizing an iframe element on my webpage using a CSS media query to adjust its dimensions. However, when I scale it down and interact with the iframe, my webpage starts scrolling horizontally. The issue is evident when using Chro ...

I'm puzzled by the inconsistency of my scrolltop function on mobile, as it seems to be scrolling to various parts of the page depending on my

I am encountering an issue with a function that scrolls to a specific element when a button is clicked. Strangely, this functionality works fine on desktop but fails on mobile devices. It successfully scrolls to the correct position only when at the top of ...

Specify the upper limit for a numeric input using Vuejs

My Vue.js script looks like the following: <template> <div> <div v-if='cart.length > 0'> <h1>Your Cart</h1> <template> <fieldset v-for='produc ...

Echoing data from an input form is not possible with an associative array

I'm having trouble printing the associative array after inserting data from an input box. Currently, I can only display the latest data entered in the input box. What I really want is to continuously add data to the array and display it every time new ...

Is the HTML5 capture attribute compatible with wkwebview?

Is it supported as stated in the title? For more information, you can check out the MDN documentation (Incomplete) and the Caniuse list of supported browsers. Surprisingly, none of them mention wkwebview. Does this attribute have support in wkwebview? Kno ...

Secure your URL with password protection

I have a website that requires restricted access upon entry. Prior to loading the page, users must enter three fields: username, password (belonging to the client), and a specific password unique to that particular page. These credentials are stored in a d ...

I seem to be having trouble properly sizing the width of my forms in Mui React

Having trouble with the sizing of my tabs in a project I'm working on. The first tab displays ingredients, while the second tab allows for adding new ingredients with various forms. However, when selecting different forms, the width of the form contai ...