What's the reason for text-alignment not functioning properly?

After some testing, I have come up with the following code:

.Greetings {
  width:100%;
  display:block;
  text-align:center;
  font-family: "Times New Roman", Times, serif;
  font-size:75px;
  color:#208CB7;
 }

The objective was to center the text on the screen, however, it stubbornly remains in the top left corner. The CSS works perfectly fine in changing the color and size of the text, but unfortunately, the positioning is not responding as expected.

In addition, the text is dynamically generated using this script:

function Greetings() {
  var currentTime = new Date();
  var hour = currentTime.getHours();

  if(hour >= 22 || hour < 7) {
    document.write('<span class="Greetings">Good Night</span>');
  } else if (hour > 7 && hour <= 14){
    document.write('<span class="Greetings">Good Morning</span>');
  } else {
    document.write('<span class="Greetings">Good Afternoon</span>');
  }
}

The HTML structure involves calling the above-mentioned script to create the span element:

<div id="Greetings">
    <script type="text/javascript" src="js/default.js"></script>
</div>

Answer №1

text-aling:center;

Incorrect spelling - it should be text-align. Also, remember not to use a <span> for block-level elements. Instead, opt for a <div> and eliminate display:block and width:100%.

Furthermore, the correct symbol for "greater than or equal to" is >=, not => (which represents a fat arrow function).

Everyone makes typos that can cause chaos in coding. I experienced this just yesterday.

Answer №2

There is a typo in the text: "text-aling:center;" should be corrected to "text-align"

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

What is the best way to ensure that a Flex div and its child images stay confined within the boundaries of its parent container?

I'm struggling to create a responsive grid of images. I can't get the images to be both responsive with max-height and max-width, while also making sure the parent div takes up their full width. On the other hand, if I make the parent div the cor ...

Incorporate PHP form and display multiple results simultaneously on a webpage with automatic refreshing

I am currently in the process of designing a call management system for a radio station. The layout I have in mind involves having a form displayed in a div on the left side, and the results shown in another div on the right side. There are 6 phone lines a ...

A JavaScript function utilizing lodash's forEach method that is returning an undefined value

I've encountered a problem while developing a ReactJS app. In one of my functions called filterSelected, I have a for loop that iterates through an array of region names (e.g. ["Thailand", "Malaysia"]) and is supposed to return an array of their corre ...

What is the best way to incorporate an "if" statement into my code?

I'm in the process of setting up a section on my website where users can get live price estimates based on a value they input. While I have most of the formula in place, there's one final element that I need to figure out: introducing a minimum f ...

Having trouble setting a background image for a specific DIV element in HTML

I am in the process of updating my webpage, and need some assistance implementing a small background image. Here is what I have done so far: https://i.sstatic.net/nTxtD.png Below is the marked section where I am trying to add the background image: https ...

Scrolling seamlessly on websites with a single page

I am developing a single-page website that uses different section IDs instead of multiple pages. It's functioning properly, but I want to implement smooth scrolling to the sections rather than just statically jumping to them on the page. Jsfiddle: ht ...

Exploring and Presenting Arrays using React JS

Recently, I have started working with react js and I am trying to add a search functionality to filter an array in React. My goal is to allow the user to enter a character in the textbox and only see the names that contain that specific character. So far, ...

Text using Bootstrap positioned to the right of the breadcrumb navigation bar

Currently, I am using the default theme with Bootstrap 3. I have implemented breadcrumbs as shown below: <ol class="breadcrumb"> <li><a href="#">Home</a></li> <li><a href="#">Library</a></li> < ...

What exactly does this jquery library aim to achieve?

Recently, I discovered a new library for CSS3 animations. As someone who is still learning JavaScript, I am unsure of the benefits it offers. It appears to replicate what jQuery can already achieve but by utilizing CSS3. So, what advantage does using a to ...

Can the default Bootstrap classes in the ExtLib application layout control be modified?

I am currently using the responsive Bootstrap theme in combination with the application layout control in extlib, but I have been unable to locate any documentation on whether it is possible to modify the predefined Bootstrap classes. In the example below ...

Is there a way to specifically execute a Mongoose validate function solely for the create user page and not the edit user page?

Exploring Different Tools In the process of developing a website using Node.js, Express, and MongoDB. Leveraging mongoose for interacting with the MongoDB server has been quite beneficial. However, I encountered an issue where a function within my Mongo ...

What is the best way to reference an ImageButton using jquery?

I created an HTML page with a special div in the body that contains a collection of buttons and images. <div id="div_one"> <button id="button_one"> <asp:Image id="image_button_one" ImageUrl=".." runat="server"> </button> </div& ...

Issue with manipulating currency conversion data

Currently, I am embarking on a project to develop a currency conversion application resembling the one found on Google's platform. The main hurdle I am facing lies in restructuring the data obtained from fixer.io to achieve a similar conversion method ...

What are some ways to keep the text within the boundaries of the input box?

How can I prevent the letters from extending beyond the bar when typing a lot of characters? Your assistance in resolving this issue is greatly appreciated. <div id="tasks-container"> <div id="tasks-header"> ...

Passing asynchronous data from method1 to method2 without impacting the functionality of the script responsible for fetching the asynchronous data in method1

When working with TypeScript, I encountered an issue while trying to invoke an external script called SPCalendarPro within a private method that asynchronously fetches data. The script is invoked in the following manner: private _getSPCalendarPro() { con ...

Is there a way to organize items in an array alphabetically according to a predetermined key value?

I have an array of objects containing countries with various values for each country. My goal is to list them alphabetically. // globalBrands { [ { id: 1, title: 'Argentina', content: [{url: 'w ...

Tips for aligning specific items to the right side of the navigation bar

I've been grappling with creating a navigation bar for a website, aiming to position 4 elements on the left side of the screen and 2 on the right. Despite knowing that there's likely a straightforward solution, I'm struggling to get the elem ...

Why does Javascript Tic-Tac-Toe delay notifying the user until the entire board is full?

There have been a lot of questions about Tic-Tac-Toe javascript, but my issue is unique. My code works fine, but it doesn't declare a winner or a tie game until the entire board is filled. I suspect that my if statements are causing problems and can&a ...

Sending a parameter to a different function (on a separate webpage)

At the start of my webpage, there are two radio buttons on the first page, each with its own value. Upon clicking a link to move to the second page, a for loop is activated to grab the value of the selected button. The script has been tested and works as e ...

When utilizing an object as state in React, the `setState` function will only set

Currently, I am working on developing a React form that utilizes a custom Input component which I have created multiple times. The objective is to gather all the names and values from the form in the parent component: {inputName: value, inputName2: valu ...