Why isn't my CSS wrapper reflecting in my HTML code?

Hey there, I'm working on a funny website dedicated to my friends in my computing class and I’ve run into an issue. The wrapper in my CSS isn't being applied to the webpage. It works fine on other pages of the site, but for some reason, it's not working here. Here’s the HTML code snippet:

<html>    
    <head>
        <link href="main.css" rel="stylesheet" type="text/css>

        <title>Comparing George and Adam's Physiques</title>

    </head>

    <body>

    <div class="wrapper">
    <h1> Exploring the physical differences between George and Adam </h1>

    <div class="article ">
    <ul>
        <li>George is less chubby than Adam.</li>
        <li>George has superior hair compared to Adam.</li>
        <li>George sports a manly stubble collection.</li>
        <li>Simply put, George wins in the looks department over Adam.</li>
    </ul>

    <div class="littlearticle">

    <p> <a href="george_vs_adam.html"> Click here to go back to the homepage </a> </p>
    </div>
    </div>
    </div>
</html>

Here's the relevant section of my CSS code:

body {
   text-align: left;
}
.wrapper {
    width: 40em;
    text-align: left;
    margin-left: 150px;
    margin-right: 150px;
    padding: 8px;
}
h1 {
    color: red;
    background-color: white;
    font-family: tahoma;
    border-top: 2px double red;
    border-bottom: 2px dashed red;
    padding: 8px;
}
.article {
    color: blue;
    font-family: consolas;
    font-size: medium;
    background-color: yellow;
    padding: 8px;
}
.littlearticle {
    color: black;
    font-family: consolas;
    font-size: medium;
    background-color: red;
    padding: 8px;
}

Answer №1

There are four small errors that need correction:

1

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

Correction:

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

2

The closing body tag is missing: </body>

3

Within the .article section, there is padding;8px;, which should be corrected to padding: 8px;

4

Within the .wrapper section, text-align;left; should be changed to text-align: left;

Answer №2

Many of the CSS rules in your code are invalid:

The correct syntax for CSS is :

rule: property;

It should never be:

rule; property;

Therefore, you need to correct:

text-align; left; to text-align: left;

background-color; white; to background-color: white;

padding; 8px; to padding: 8px;

In addition, your CSS link is incorrect and make sure to close the double quotation marks:

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

You also missed the closing tag </body>

Another thing to note is that CSS properties should be lowercase, for example:

text-align: Left; should be text-align: left;

While this won't affect your CSS styling directly, it's considered good practice to follow.

Answer №3

Make sure to include the closing double-quote for "text/css"

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

Answer №4

Your code contains a few syntax errors, as mentioned by others previously.

body {text-align: left;}

.wrapper{
width:40em; text-align:left;
margin-left: 150px; margin-right: 150px;
padding: 8px;

}

h1 {
color:red;
background-color:white;
font-family:tahoma;
border-top:red 2px double;
border-bottom: red 2px dashed;
padding: 8px;

}

.article {
color:blue;
font-family:consolas;
font-size:medium;
background-color:yellow;
padding:8px;

}

.littlearticle {
color:black;
font-family:consolas;
font-size:medium;
background-color:red;
padding: 8px;

}

Make sure to correct the reference in your HTML page as shown below:

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

You can view the working example on JSFiddle.

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 can heights be shared among rows in HTML?

<div class="container-fluid"> <div calss="row" style="height:20%; display: block;"> <h1>20% height</h1> </div> <div calss="row"> <h1>height should be 80%</h1> </div> < ...

The value entered is displaying as not defined

As a newcomer to the world of javascript, I am diving into creating a simple To Do list. The basic functionality is there, but I'm scratching my head trying to figure out why the input value in my code keeps returning undefined. The remove button is ...

Establish a predetermined selection for a drop-down menu

How can I set a default value for a dynamically filled dropdown menu featuring all 12 months in KnockoutJS? I want the default value to be the current month. This is how I am populating the dropdown with information: self.setMonthData = (data ...

Loading necessary CSS when needed in React JS

I am currently in the process of converting a bootstrap template to react framework. My question is, is there a way for me to load stylesheets on demand? For instance, if I have 2 components and I import the same stylesheet separately in both components, ...

I'm attempting to showcase an HTML file by using res.sendFile within the Express framework

As part of my workflow implementation, I have set up a scenario where upon user login, the credentials are sent via Ajax to an Express route for verification. If the user exists, the route responds with a message "authorised" triggering a second Ajax call ...

Setting up Bootstrap in Visual Studio for a seamless integration

Currently, I am working with the most recent version of VisualStudio which includes an older version of Bootstrap 3 when selecting the application template. I attempted to manually transfer the library files from the updated Bootstrap 4 to the root folde ...

Using dots instead of lines for the carousel indicators in PrimeNG

I'm currently working on a carousel feature, but I want to change the indicators from lines to small dots. I know the solution lies within the CSS files, but I'm not sure how to implement it. I think I need to create a new CSS class, but I could ...

Title vanishes when gradient is added to a div

I have encountered an issue with a recent update on my webpage. Previously, I had multiple divs with the title attribute that displayed information when users hovered over them. However, after adding a gradient background, the titles stopped appearing. Th ...

Image with text overlay

In my content, the setup includes the following: <p class="All-Book-Text">Maecenas iaculis, ipsum at tempor placerat, orci ligula aliquam enim, sit amet sagittis turpis enim sit amet lorem. Praesent dapibus pretium felis, et tempus nibh posuere a.&l ...

Is there a way to enable scroll on v-col?

I'm working on a layout that has specific requirements: The grey container should cover the entire viewport without exceeding it The green v-row should occupy the grey container entirely v-col 1 should utilize all available space and add a scrollbar ...

The Challenge of CSS 3D Transformation Angles

Currently, I am utilizing CSS3 for a transformation on a div with the following properties: '-webkit-transform' : 'rotateX(45deg) rotateZ(-45deg)' The outcome appears like this: Alternatively, you can view it in action in this fiddle ...

Looking to enlarge a few CSS classes, but unsure of the best approach

My app has some CSS code that I found, but it's too small. Can anyone help me increase the size by 150%? I am using React-Bootstrap for styling, so I'm looking for a way to enlarge the element without adjusting every attribute in the CSS classes. ...

Using jQuery to insert a div class with PHP referenced

My variable stores a color name. Here is an example: <?php $myvar = blueColour; ?> I want to apply this value to the body of an html page using jQuery: <script type="text/javascript"> jQuery(body).addClass("<?php echo $myvar; ?>"); < ...

Real-time data feeds straight from JSON

Currently, I have a JSON file that is generated dynamically and it contains match information along with a unique id. This JSON data is categorized into live, upcoming, and recent arrays. Being new to Javascript, I am unsure about the best approach to crea ...

Control the transparency of the initial parent div that includes an *ngFor loop

I want to add opacity only to the first div which contains an icon and a heading in another nested div. The second div should remain fully visible (opacity: 1). Here is the HTML structure: <div class="row clearfix"> <div class="col-lg-3 col- ...

Substitute the website address using regular expressions

Looking to update the iframe URL by changing autoplay=1 to autoplay=0 using regular expressions. jQuery(document).ready(function($){ $('.playButton').click(function(){ $('.flex-active-slide iframe').contents().f ...

What is the best way to retrieve the name of a dynamic form in a Controller

How can I retrieve the dynamic form name in my controller? See below for the code snippet: HTML <form name="{{myForm}}" novalidate> <input type="text" ng-model="username" name="username" required/> <span ng-show="(submit & ...

Font size transition on pseudo elements is not functioning properly in Internet Explorer when using the "em" unit

When I hover over, the font awesome icon and text on this transition increase in size. All browsers work well with this effect except for IE 11. This example demonstrates the same transition using px (class test1) and em (class test2). While using px wor ...

What could be causing my browser to display twice the height value?

After running the code below on my browser, I noticed that the height value is rendered double. To start off, I tested the following code in about:blank. In the HTML: ... <canvas id="canvasArea" style=" width: 500px; height: ...

The Lifecycle of an HTML Page

Trying to grasp the life cycle of an HTML page has been a challenge for me. Unable to find comprehensive resources online, I took matters into my own hands by experimenting with the f12 tool in Internet Explorer. Through these experiments, I have formulate ...