웹 기초 (HTML, CSS, JS) 간단정리

RXDRYD·2021년 8월 19일
0
<!DOCTYPE html>
<html>

<head>
    <title>Title 명</title>
    <link rel="stylesheet" href="test.css"/>
</head>

<body>
    <nav>
        <a href="index.html">Home</a>
        <a href="A.html">A페이지</a>
        <a href="B.html">B페이지</a>
    </nav>

    <h1>첫번째 크기 설명</h1>
    <p>문단 표시</p>

    <a href="index.html">링크클릭</a>
    <br/>
    <hr/>

    <img src="https://images.pexels.com/photos/9160944/pexels-photo-9160944.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"/>


</body>
</html>

head

title : 탭에 표시되는 글자

p : 문단을 쭉 나열할때, 줄 바꿈은 br 로 사용

nav : navigation 바 처럼 버튼여러개 라인

href : 하이퍼링크

hr : 수평선

CSS 작성 예시

HTML 파일 본문에 쓸 경우

<head>
    <title>Title 명</title>
    <style>
        p {color: blue;}
        h1 {color: green;}
        img { width: 400px;}
    </style>
</head>

CSS 파일을 별도로 분리할 경우

HTML 파일 내부에 아래처럼 작성(index.html)

<head>
    <title>Title 명</title>
    <link rel="stylesheet" href="basic_style.css"/>
</head>

별도로 분리한 파일 작성(test.css)

p {color: blue;}
h1 {color: green;}
img { width: 400px;}

자바스크립트 작성 예시

HTML 파일 본문에 쓸 경우

<script>
        function doSomething() {
            var name = document.getElementById("user_name").value;
            document.getElementById("hello_to_somebody").innerHTML =  "안녕하세요. " + name + " 님!!!"        
            // alert(name); // 창 띄울때 
        } 
</script>

자바스크립트 파일을 별도로 분리할 경우

HTML 파일 내부에 아래처럼 작성(index.html)

<script type="text/javascript" src="test.js"></script>

별도로 분리한 파일 작성(test.js)

function doSomething() {
    var name = document.getElementById("user_name").value;

    document.getElementById("hello_to_somebody").innerHTML = 
        "안녕하세요. " + name + " 님!!!"

    //alert(name);
    
} 
profile
정리데쓰

0개의 댓글