HTML is a markup language used to create the structure of web pages. It consists of a series of elements, each represented by tags. For example, the <html>
tag is the root element of an HTML document, and the <body>
tag contains the visible content of the page.
<!DOCTYPE html>
<html>
<head>
<title>My First HTML Page</title>
</head>
<body>
<h1>Welcome to my website</h1>
<p>This is a paragraph of text.</p>
</body>
</html>
CSS is used to style HTML elements. It allows you to control the layout, colors, fonts, and other visual aspects of a web page. CSS rules are made up of a selector and a declaration block. The selector targets the HTML elements to be styled, and the declaration block contains one or more property - value pairs.
h1 {
color: blue;
font-size: 24px;
}
ASCII is a character - encoding standard that represents text in computers. It uses 7 - bit codes to represent 128 different characters, including letters (both uppercase and lowercase), numbers, and special symbols. For example, the ASCII code for the letter ‘A’ is 65, and for ‘a’ is 97.
To use HTML, you create an HTML file with a .html
extension. You can then open this file in a web browser to view the page. You can also use HTML to create links between pages using the <a>
tag.
<a href="https://www.example.com">Visit Example.com</a>
There are three main ways to use CSS: inline, internal, and external.
style
attribute.<p style="color: red;">This is a red paragraph.</p>
<style>
tag in the <head>
section of an HTML document.<!DOCTYPE html>
<html>
<head>
<style>
p {
color: green;
}
</style>
</head>
<body>
<p>This is a green paragraph.</p>
</body>
</html>
.css
file and linked to the HTML document using the <link>
tag.<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<p>This paragraph will be styled according to styles.css</p>
</body>
</html>
In styles.css
:
p {
color: purple;
}
In programming, you can use ASCII codes to represent characters. For example, in JavaScript, you can get the ASCII code of a character using the charCodeAt()
method.
let char = 'A';
let asciiCode = char.charCodeAt(0);
console.log(asciiCode); // Output: 65
<header>
, <nav>
, <main>
, <article>
, <section>
, and <footer>
to improve the structure and accessibility of the page.<header>
<h1>Website Header</h1>
</header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
</ul>
</nav>
<main>
<article>
<h2>Article Title</h2>
<p>Article content goes here.</p>
</article>
</main>
<footer>
<p>© 2024 My Website</p>
</footer>
<!DOCTYPE html>
<html>
<head>
<style>
.highlight {
background - color: yellow;
}
#unique-element {
border: 1px solid black;
}
</style>
</head>
<body>
<p class="highlight">This paragraph is highlighted.</p>
<div id="unique-element">This is a unique div.</div>
</body>
</html>
with open('file.txt', 'w', encoding='ascii') as f:
f.write('Hello, World!')
p {
width: 50%;
font - size: 1.2em;
}
CSS, HTML, and ASCII are fundamental technologies in web development. HTML provides the structure of web pages, CSS enhances their visual appeal, and ASCII serves as a basic character - encoding standard. By understanding their fundamental concepts, usage methods, common practices, and best practices, you can create more effective and well - structured web pages.