Link: Iprogramiz.
com
IWEB 141 TUTORIALS
What is HTML?
HTML (HyperText Markup Language) is the standard markup language used to create
web pages. It structures the content on the page and is often combined with CSS
(Cascading Style Sheets) and JavaScript for styling and functionality.
2. Basic HTML Structure
A basic HTML document has a specific structure. Here’s a simple template:
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Page Title</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is my first HTML page.</p>
</body>
</html>
Explanation:
<!DOCTYPE html>: Declares the document type and version of HTML.
<html>: The root element of the HTML page.
<head>: Contains meta-information about the document, like the title and
character set.
<body>: Contains the content of the webpage that is displayed in the browser.
3. Common HTML Tags
Here are some basic HTML tags you should know:
Headings: Define headings with <h1> to <h6>. <h1> is the largest, and <h6> is the
smallest.
html
<h1>This is a Heading</h1>
<h2>This is a Subheading</h2>
Paragraphs: Use <p> to create a paragraph.
html
<p>This is a paragraph.</p>
Links: Create hyperlinks with the <a> tag.
html
<a href="https://www.example.com">Visit Example</a>
Images: Embed images using the <img> tag.
html
<img src="image.jpg" alt="Description of image">
Lists: Create ordered lists with <ol> and unordered lists with <ul>.
html
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<ol> <li>First Item</li> <li>Second Item</li> </ol> ```
4. Adding More Content
You can add various other elements like:
Tables: Use <table>, <tr>, <td> to create tables.
html
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Forms: To create forms, use the <form> tag.
html
<form action="/submit" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<input type="submit" value="Submit">
</form>
5. Practice
To practice your HTML skills:
1. Open a text editor (like Notepad on Windows, or TextEdit on Mac).
2. Write your HTML code.
3. Save it with a .html extension (e.g., index.html).
4. Open that file in any web browser to see your work!
Basic CSS Tutorial
1. What is CSS?
CSS is a stylesheet language used to describe the presentation of an HTML document. It defines
how elements should be displayed on the screen, in print, or in other media.
2. How to Add CSS to HTML
You can include CSS in your HTML in three ways:
a. Inline CSS
Add styles directly to an HTML element using the style attribute.
html
<h1 style="color: blue;">This is an inline-styled heading</h1>
b. Internal CSS
Place styles within a <style> tag in the <head> section of your HTML document.
html
<head>
<style>
body {
background-color: lightgray;
h2 {
color: green;
</style>
</head>
c. External CSS
Link to a separate CSS file using the <link> tag in the <head> section.
html
<head>
<link rel="stylesheet" href="styles.css">
</head>
3. CSS Syntax
The basic syntax of a CSS rule consists of a selector and declarations:
css
selector {
property: value;
Selector: Targets the HTML element.
Property: The style attribute you want to change (like color, font-size, etc.).
Value: The value you want to assign to the property.
4. Common Selectors
Element Selector: Targets all instances of an element.
css
p{
color: red; /* Selects all <p> elements */
Class Selector: Selects elements with a specific class (use a dot .).
css
.my-class {
font-size: 18px; /* Applies to all elements with class="my-class" */
ID Selector: Targets a unique element (use a hash #).
css
#my-id {
margin: 20px; /* Applies to the element with id="my-id" */
}
5. Basic Styling Properties
Here are some basic CSS properties you can use:
Color and Background
css
body {
background-color: #f0f0f0; /* Light gray background */
h1 {
color: blue; /* Makes the heading blue */
Font Properties
css
p{
font-family: Arial, sans-serif; /* Sets the font */
font-size: 16px; /* Sets the font size */
font-weight: bold; /* Makes the text bold */
Text Alignment
css
h2 {
text-align: center; /* Center aligns the text */
Margins and Padding
css
div {
margin: 10px; /* Space outside the div */
padding: 15px; /* Space inside the div */
6. Example of HTML and CSS
Here’s a complete example combining HTML and CSS.
HTML (index.html):
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First CSS Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Welcome to My Web Page</h1>
<h2 class="subtitle">A simple subtitle example</h2>
<p>This is a paragraph with some text.</p>
<div id="content">
<p>Content inside a styled div.</p>
</div>
</body>
</html>
CSS (styles.css):
css
body {
background-color: #e0e0e0; /* Light gray background */
font-family: Arial, sans-serif; /* Default font for the body */
h1 {
color: darkblue; /* Dark blue heading */
text-align: center; /* Center text */
.subtitle {
color: darkgreen; /* Dark green subtitle */
text-align: center; /* Center subtitle */
#content {
background-color: white; /* White background for content */
border: 1px solid #ccc; /* Light gray border */
padding: 15px; /* Inner space of the content area */
margin: 20px; /* Outer space from other elements */
7. Practice
Create an HTML file and a CSS file using the examples provided above.
Modify the styles in your CSS file to see how they affect the HTML elements.
Experiment with different properties and values to understand how CSS works.
8. Resources for Further Learning
Online Tutorials: Websites like W3Schools and MDN Web Docs offer great resources.
Interactive Learning: Platforms like Codecademy or FreeCodeCamp provide interactive
CSS courses.
Feel free to ask if you have specific topics or questions about CSS that you’d like to explore!