Development

웹 개발의 기본 사항 : HTML, CSS 및 JavaScript

sonpro 2023. 4. 23. 12:23
반응형

web development

The Basics of Web Development: HTML, CSS, and JavaScript

Web development is an exciting field that has grown rapidly over the years. It involves the creation and maintenance of websites and web applications. In this article, we will discuss the basics of web development, which include HTML, CSS, and JavaScript.

HTML

HTML stands for Hypertext Markup Language. It is the standard markup language used to create web pages. HTML provides the structure and content of a web page. It consists of a series of elements that define the different parts of a web page, such as headings, paragraphs, images, and links.

Here is an example of an HTML code that creates a basic web page:

<!DOCTYPE html>
<html>
<head>
    <title>My Web Page</title>
</head>
<body>
    <h1>Welcome to my web page</h1>
    <p>This is a paragraph.</p>
    <img src="image.jpg" alt="My Image">
    <a href="https://www.example.com">Visit Example</a>
</body>
</html>

In the example above, we have an HTML document that starts with a <!DOCTYPE html> declaration. This tells the browser that the document is an HTML5 document. The <html> element contains the entire web page, and the <head> element contains the metadata of the web page, such as the title. The <body> element contains the content of the web page, such as headings, paragraphs, images, and links.

CSS

CSS stands for Cascading Style Sheets. It is a style sheet language used to describe the presentation of a web page. CSS provides the visual style of a web page, such as the layout, colors, fonts, and animations.

Here is an example of a CSS code that styles the HTML code above:

body {
    font-family: Arial, sans-serif;
    background-color: #f2f2f2;
}

h1 {
    color: #333;
    text-align: center;
}

p {
    color: #666;
    font-size: 16px;
    line-height: 1.5;
}

img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

a {
    color: #007bff;
    text-decoration: none;
}

In the example above, we have a CSS code that styles the HTML code above. The body element sets the font family and background color of the web page. The h1 element sets the color and text alignment of the heading. The p element sets the color, font size, and line height of the paragraph. The img element sets the display, margin, and maximum width of the image. The a element sets the color and text decoration of the link.

JavaScript

JavaScript is a programming language used to create interactive web pages. It provides the behavior of a web page, such as user input validation, animations, and dynamic content.

Here is an example of a JavaScript code that adds interactivity to the HTML code above:

const button = document.querySelector('button');
const input = document.querySelector('input');
const message = document.querySelector('#message');

button.addEventListener('click', () => {
    if (input.value === '') {
        message.textContent = 'Please enter your name.';
    } else {
        message.textContent = `Hello, ${input.value}!`;
    }
});

In the example above, we have a JavaScript code that adds interactivity to the HTML code above. The const keyword declares variables that store references to the HTML elements. The addEventListener method adds an event listener to the button element that listens for a click event. The if statement checks if the input value is empty and displays a message if it is. Otherwise, it displays a personalized greeting message.

Conclusion

In conclusion, HTML, CSS, and JavaScript are the basics of web development. HTML provides the structure and content of a web page, CSS provides the visual style of a web page, and JavaScript provides the behavior of a web page. By mastering these three technologies, you can create amazing websites and web applications that are both functional and beautiful.

반응형