HTML and Css
HTML and Css
HTML Structure
• <!DOCTYPE html>
• <html lang="en">
• <head>
• <meta charset="UTF-8">
• <meta name="viewport" content="width=device-width, initial-scale=1.0">
• <title>My Simple Page</title>
• <link rel="stylesheet" href="styles.css">
• </head>
• <body>
• <h1>Welcome to My Page</h1>
• <p>This is a simple paragraph of text.</p>
• <button id="myButton">Click Me!</button>
• <ul>
• <li>Item 1</li>
• <li>Item 2</li>
• <li>Item 3</li>
• </ul>
• <div id="result"></div>
• <script src="script.js"></script>
• </body>
• </html>
HTML TAGS
• <div>: A block-level container for grouping content.
• <p>: Represents a paragraph of text.
• <h1>, <h2>, <h3>... <h6>: Header tags for titles and
headings.
• <a>: An anchor tag for hyperlinks.
• <ul>, <ol>, <li>: For unordered (bulleted) and ordered
(numbered) lists.
• <img>: For images.
• <button>: For clickable buttons.
image tag
• The <img> tag is used to embed an image in an HTML
page.
attributes:
src,width,height,alt,style
HTML Styles
<em>-emphazied text f
i
n
<sub>-subscripted text e
t
e
<sup>-superscripted text d
Example
<style>
• body {background-color: powderblue;}
• h1 {color: blue;}
• p {color: red;}
• </style>
External css
style.css
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p{
color: red;
}
border
• surrounded by border
syntax:
border:2px yellow;
properties
border-width: Specifies the width of the border (e.g., 1px,
2px).
• border-style: Defines the style (e.g., solid, dotted,
dashed).
• border-color: Sets the color of the border (e.g., red, #000,
rgba(255, 255, 255, 0.5)).
margin
• space between one element and another element
Syntax:
margin:2px;
padding
• space between element and border
syntax:
padding:2px
tables
• <table>
• <tr>
• <th>Company</th>
• <th>Contact</th>
• <th>Country</th>
• </tr>
• <tr>
• <td>Alfreds Futterkiste</td>
• <td>Maria Anders</td>
• <td>Germany</td>
• </tr>
• <tr>
• <td>Centro comercial Moctezuma</td>
• <td>Francisco Chang</td>
• <td>Mexico</td>
• </tr>
• </table>
Lists in html
• unordered lists:
<ul>
• <li>Coffee</li>
• <li>Tea</li>
• <li>Milk</li>
• </ul>
ordered list
• <ol>
• <li>Coffee</li>
• <li>Tea</li>
• <li>Milk</li>
• </ol>
description list
• <dl>
• <dt>Coffee</dt>
• <dd>- black hot drink</dd>
• <dt>Milk</dt>
• <dd>- white cold drink</dd>
• </dl>
Input methods in html
<div class="city">
• <h2>London</h2>
• <p>London is the capital of England.</p>
• </div>
defining style using id
• <style>
• #city {
• background-color: tomato;
• color: white;
• border: 2px solid black;
• margin: 20px;
• padding: 20px;
• }
• </style>
<div id="city">
• <h2>London</h2>
• <p>London is the capital of England.</p>
• </div>