Chat Gpt20623
Chat Gpt20623
DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8”>
<title>Blog Website</title>
</head>
<body>
<header>
<h1>My Blog</h1>
</header>
<main>
<section id=”blog-posts”>
</section>
<section id=”create-post”>
<button id=”submit-post”>Submit</button>
</section>
</main>
<script src=”script.js”></script>
</body>
</html>
Css
Body {
Margin: 0;
Padding: 0;
Header {
Background-color: #333;
Color: #fff;
Padding: 20px;
Text-align: center;
H1 {
Margin: 0;
Main {
Margin: 20px;
#create-post input,
#create-post textarea {
Display: block;
Margin-bottom: 10px;
Width: 100%;
#create-post button {
Background-color: #333;
Border: none;
Color: #fff;
Cursor: pointer;
#create-post button:hover {
Background-color: #555;
.post {
Background-color: #f9f9f9;
Border-radius: 5px;
Margin-bottom: 20px;
Padding: 20px;
.post h3 {
Margin-top: 0;
.post p {
Margin-bottom: 0;
Javascript
Const posts = [
Function displayPosts() {
blogPosts.innerHTML = ‘’;
Posts.forEach((post) => {
postElement.classList.add(‘post’);
titleElement.innerText = post.title;
contentElement.innerText = post.content;
postElement.appendChild(titleElement);
postElement.appendChild(contentElement);
blogPosts.appendChild(postElement);
});
Function addPost() {
Content: contentInput.value,
};
Posts.push(newPost);
titleInput.value = ‘’;
contentInput.value = ‘’;
displayPosts();
displayPosts();
Const submit