Essential CSS: A Guided Tutorial Using Hangman Stage 1

This page introduces the essential CSS concepts and rules used in our Hangman Stage 1 project. You'll learn how CSS styles your web pages, how selectors and properties work, and how Bootstrap 5 and your own custom styles combine for a polished look.

1. What is CSS?

CSS (Cascading Style Sheets) is a language for describing how HTML elements should look on the screen. CSS lets you change colors, fonts, spacing, layout, and much more.

/* This is a CSS comment */
selector {
    property: value;
    another-property: another-value;
}

2. How CSS is Used in Hangman Stage 1

3. Selectors and Properties

CSS uses selectors to target HTML elements. You can select by tag name (div), class (.myClass), or id (#myId).

/* Select by id */
#wordDisplay {
    background-color: bisque;
    font-family: monospace;
}

/* Select by class */
.btn-primary {
    background-color: #0d6efd;
    color: #fff;
}

/* Select by tag */
button {
    border-radius: 0.25em;
}

4. Key CSS Used in Hangman Stage 1

Here are some of the most important custom styles from our project:

#wordDisplay {
    background-color: bisque;
    font-family: monospace;
    white-space: nowrap;                /* Keeps the word on one line */
    overflow-x: auto;                   /* Adds horizontal scroll if needed */
    font-size: clamp(1.2rem, 8vw, 2.5rem); /* Responsive font size */
    letter-spacing: 0.3em;              /* Space between letters */
    text-align: center;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 0.5em;
}

#letterButtons button {
    margin: 0.2em;
    width: 2.5em;
    height: 2.5em;
    font-size: 1.2em;
    background-color: lightgreen;
}

/* Used (disabled) letter buttons: higher contrast */
#letterButtons button:disabled {
    background-color: #888 !important;   /* Darker background */
    color: #fff !important;              /* White text */
    opacity: 1 !important;               /* Remove Bootstrap's default dimming */
    border-color: #444 !important;       /* Darker border */
}

5. Responsive Design

Responsive CSS makes your site look good on all devices. We use:

6. Bootstrap vs. Custom CSS

<button class="btn btn-primary">Restart Game</button>
<a class="btn btn-outline-secondary" href="hangmanChatlogStg1.html">View AI Chatlog</a>

7. Tips for Beginners

8. See It in Action

Explore the game, AI chatlog, and HTML guide to see how CSS and HTML work together in a real project!

Tip: You can view the CSS file directly or use your browser's "Inspect" tool to see and experiment with styles live.