HTML and CSS Basics

MTN NIGERIA LTE

HTML and CSS Combination

  • Purpose: Understand how to combine HTML and CSS to create a simple web page.

Example Code

  • The following is a complete HTML document demonstrating the use of HTML and CSS:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Simple Web Page</title>
    <style>
    body{
    background-color: yellow;
    }
    h1 {
    color: red;
    }
    </style>
    </head>
    <body>
    <h1>My School Website</h1>
    <p>Welcome to our ICT class.</p>
    </body>
    </html>
    
  • Explanation of Code:

    • <!DOCTYPE html>: Declares the document type and version of HTML.
    • <html>: The root element of an HTML page.
    • <head>: Contains meta-information about the document, such as its title and linked styles.
    • <title>: Sets the title of the web page, shown in the browser's title bar or tab.
    • <style>: Contains CSS rules for styling HTML elements.
    • body: Represents the main content of the HTML document; here, it is styled with a yellow background.
    • h1: Header element that, when styled, changes the text color to red.
    • <body>: Contains the actual content of the web page visible to users.
    • <h1>: A heading designed to be the title of the web page.
    • <p>: A paragraph element that provides a brief greeting in the context of the web page.

Advantages of Using HTML and CSS

  1. Easy to learn and use: HTML and CSS have straightforward syntax, making them accessible for beginners.
  2. Helps create attractive websites: The combination allows for visually appealing designs and layouts.
  3. Separates content from design: HTML outlines the structure and content, while CSS handles the appearance and styling, promoting cleaner code.
  4. Makes websites responsive and organized: CSS facilitates responsive design that adapts to various screen sizes, hence improving user experience.