css js연결 방법

    <style></style>   html 내부 스타일

    <script></script> 내부 스크립트

 

    외부에서 불러올 때

    <link rel="stylesheet" href="style.css">

    <script src="custom.js"></script>

 

    <h1 style="color:red;"></h1> 인라인 스타일

    <h1 onclick="window.close()"></h1> 인라인 자바스크립트

 

- onclick javascript event

- 현재 탭에서 열기 

section 클릭 시 html로 연결된다.

<section onclick="location.href='iphonex.html'"></section>

<div class="wrap">
        <header>
            <nav>
                <div class="navi">
                    <a href="">icon</a>
                    <a href="">Mac</a>
                    <a href="">iPad</a>
                    <a href="">Watch</a>
                    <a href="">Music</a>
                    <a href="">고객지원</a>
                    <a href="" class="btn-search">검색</a>
                    <a href="" class="btn-search">장바구니</a>
                </div>
            </nav>
        </header>

        <section 
            class="welcome" 
            onclick="location.href='iphonex.html'">
            <div class="heading">
                <h3>iPhone</h3>
                <a href="iphonex.html">Encounter with the future</a>
            </div>
        </section>
</div>

.html 말고 url도 가능하다. "" 안에 "" 로 쓰면 안되고 작은따옴표로 써야한다. 

 

 

- 새탭에서 열기 

<section onclick="window.open( '링크' )"></section>

        <!-- 새창으로 띄우기 -->
        <section class="welcome"
            onclick="window.open('iphonex.html')">
            <div class="heading">
                <h3>iPhone X</h3>
                <a href="iphonex.html">Encounter with the future</a>
            </div>
        </section>

 

 

<a>

   <section></section>

</a>

a태그로 감싸는 방법은 비추천이다.

 

 

+ Recent posts