The background-color and text color properties in CSS are failing to apply

Struggling with my HTML homework, following the book instructions but still getting errors. Can anyone here help me figure out what's wrong?

questions: 1: Add a blank line after the CSS reset style rule, add a comment with the text, Style rule for body and image, and then create new style rules for the body and img selectors.

Create a style rule for the body selector that sets a background color value of #e3eaf8. Create a style rule for an img selector that sets a max-width to 100% and displays the images as a block.

2: Add a blank line after the img style rule, add a comment with the text Style rule for header content, and then create a new style rule for the header h1 descendant selector that aligns text center; sets a font size value of 3em; sets a font family value of Georgia, Times, serif; sets a padding value of 3%; and sets a color value of #101a2d.

3: Add a blank line after the header h1 style rule, add a comment with the text Style rules for navigation area, and then create the following style rules for the nav, nav ul, nav li, and nav li a selectors.

Create a style rule for the nav selector that sets the background color to #1d396d. Create a style rule for nav ul that sets the list style type to none, sets the margin to 0, and aligns text center. Create a style rule for nav li that sets the display to an inline-block, sets a font size of 1.5em, sets a font family value of Verdana, Arial, sans-serif, and a font weight value of bold. Create a style rule for nav li a that sets the display to a block, sets a font color value of #e3eaf8, sets top and bottom padding values of 0.5em and left and right padding values of 2em, and removes the text decoration.

Those are the questions and I have tried to change my code in various ways but can't seem to get it right

Code:

<DOCTYPE html>
<!--    
    Student Name: Nicholas Prawl
    File Name: styles.css
    Date: 02/13/2021
-->

<!-- 
    CSS Reset
    margin: 0;
    padding: 0;
    border: 0;
-->

<!--
    Style rule for body and image

    body {
      background-color: #e3eaf8;
    }
    img {
      max-width: 100%;
      display: block;
    }
-->

<!--

    Style rule for header content
     header h1 {
      text-align: center;
      font-size: 3em; 
      font-family: Georgia, Times, serif; 
      padding: 3%;
     color: #101a2d;
    }

-->

<!--
    Style rules for navigation area
    nav{
      background-color: #1d396d;
    }
    nav ul{
      list-style-type: none;
      margin: 0;
      text-align: center;
    }
    nav li{
      display: inline-block;
      font-size: 1.5em;
      font-family: Verdana, Arial, sans-serif;
      font-weight: bold;
    }
    nav li a{
      display: block;
      color: #e3eaf8;
      padding-top: 0.5em;
      padding-bottom: 0.5em;
      padding-left: 2em;
      padding-right: 2em;
      text-decoration: none;
  
    }
-->

Answer №1

Your code could use some improvements.

First and foremost, it seems like you're mixing CSS within your HTML code without utilizing the appropriate style tags. For guidance on how to properly integrate CSS into HTML, check out this helpful article:

https://www.w3schools.com/css/css_howto.asp

Moreover, your comments are not being added correctly. To understand the correct way of adding comments in CSS code, take a look at this resource: https://developer.mozilla.org/en-US/docs/Web/CSS/Comments

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

Issues persist with redirection when using AJAX and PHP in a login form, resulting in the user staying on the index page

After filling out both the email and password form fields and clicking the sign-in button, my script is functioning correctly. However, upon clicking the sign-in button, I want the user to be redirected to the home page. Currently, the user remains on the ...

The 'Required' attribute in HTML is malfunctioning

The 'required' attribute is not functioning properly when I try to submit the form. I've searched online for a solution, but none of them have resolved my problem. Take a look at the code snippet below - I've used the required attribute ...

Setting the height attribute of an image tag in HTML to match a JavaScript variable

I am currently developing a SharePoint app that heavily relies on JavaScript. I have implemented a feature where the user can set a variable of their choosing, which I want to utilize as the width of an image displayed on the screen. This designated value ...

Tips for sending every individual string object within an array as post data via ajax

I have a scenario where I am dealing with dynamically generated text boxes. Each value from these text boxes needs to be stored in a JSON array when submitted. The approach I took was to push all the values into an array and upon submission, these values a ...

What sets apart sending an HTML string versus an HTML file from an express server?

I am developing a Cloud Function that functions as an express server and has the following requirements: Retrieve an external index.html file Parse the file, make changes to certain tags Send the modified file back to the user's browser as a respon ...

Strategies for optimizing PPI and DPI in responsive design

Imagine having two monitors: one 15.5 inches with a resolution of 1920 x 1080 and the other 24 inches with the same resolution. The first monitor has a pixel density of around 72 PPI, while the second has around 90 PPI. If I apply a media query in CSS for ...

Creating a Website Optimized for Mobile Devices

As a beginner web developer, I am in the process of creating a mobile-friendly website system. Currently, I am utilizing Bootstrap for responsiveness, PHP5, MySQL, and occasionally Ajax/JQuery. Recently, I came across JQuery Mobile. While I have been usin ...

How can we display the Recent Updates from our LinkedIn profile on our website using iframe or javascript?

Currently, I am in the process of developing a .NET web application for our company's website. We already maintain an active LinkedIn profile where we regularly post updates. https://i.stack.imgur.com/T2ziX.png My main query at this point is whether ...

Adapt your design to different screen sizes with Bootstrap 4

There will be a significant amount of typing required for this task. I have a page that needs some design adjustments when the screen size is reduced. This includes elements of menus switching positions and additional design features on certain fields. C ...

DIV size issue resolved

Content within a div is surpassing the set fixed size determined by CSS. <style> #fixeddiv { position: fixed; margin: auto; max-height: 300px; max-width: 700px; } </style> <div id="fixeddiv"> <div id="M77 ...

beginning the process of aligning the select element with the label in a form

.surveyform-class { background: yellow; margin: 0 25%; width: 50%; border-right: 40px solid yellow; } .main-div{ background: lightgrey; width: 50%; height:100%; margin: 0 25%; border-right: 20px solid yellow; border- ...

Having trouble with my WordPress theme not recognizing my CSS file

My file path is displayed below: D:\web server\blog.dev.cc\wp-content\themes\ablog\css for java script file path D:\web server\blog.dev.cc\wp-content\themes\ablog\assets\js Despite checking ...

How come defining the state using setTimeout does not display the accurate properties of a child component?

Presented here is a component designed to render a list of items and include an input for filtering. If no items are present or if the items are still loading, a message should be displayed. import { useState } from "react"; export const List = ...

Can one select a radio button without corrupting the data in VUE?

How can I preselect a value for radio buttons created using Vue's List Rendering without having a dataset in the script? Below is the code snippet for a better understanding of my goal: SCRIPT: data() { return { formData: {} //formData st ...

How to preserve alternating row styles when exporting Angular Data Table to Excel with .withButtons?

Utilizing Angular DataTable to display a list of data, with alternate row background color and border styles defined. An issue arises when exporting the Data table to excel as the alternate row style and border styles are lost. Only the raw data is includ ...

The background image will expand to fill any available space

I'm currently working on rendering divs with a background image CSS property. The images have fixed sizes, and I want to display them in a grid layout. However, the divs with background images stretch when there is extra space available, which is not ...

How to keep a window/tab active without physically staying on that specific tab

Whenever I'm watching a video on a website and switch to another tab, the video stops playing. But when I switch back to the original tab, the video resumes. Is there a trick to prevent the video from stopping? I've already tried using scrollInto ...

What methods can be used to prevent words from breaking inside a label?

I'm having trouble styling a label with CSS properties because every word inside the label is breaking to a new line. For example, "Withdraw money" is displaying like this: Withdraw money I've tried various properties like white-space:nowrap,f ...

Generate a Calendar Table using JavaScript in the Document Object Model (DOM

I have set up a table with 6 rows and 5 columns. The purpose of the table is to represent each month, which may have varying numbers of days. I want each column to display dates ranging from 1-30 or 1-31, depending on the specific month. Here's what ...

Achieving the perfect scale for your background image using only CSS

I am currently working on a website, and the client has requested that the background scales up or down depending on the browser size. I have managed to achieve this partially using some jQuery hacks to adjust element sizes as the browser is resized, but I ...