Skip to main content

Command Palette

Search for a command to run...

CSS- Separating style

Published
1 min readView as Markdown

When <style> code is too long, it's quite hard to see the whole code. Style code can be separated by using

  • Make a new stylesheet image.png

image.png

  • Copy all tags under <style>and paste it in mystyle.css. Delete <style> from the original code.

-Import stylesheet by using <link rel="stylesheet" type="text/css" href = "mystyle.css">

<!-- create a style.css file in the same folder and, use it in head tag -->
<link rel="stylesheet" type="text/css" href = "(the name of CSS file).css">
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <link href="https://fonts.googleapis.com/css2?family=Song+Myung&display=swap" rel="stylesheet">
</head>
<body>
    <div class="wrap">
        <div class="mytitle">
            <h1>Login Page</h1>
            <h5>Enter your ID and password</h5>
        </div>
        <p>ID: <input type="text" /></p>
        <p>PW: <input type="text" /></p>
        <button> Login</button>
    </div>
</body>
</html>

image.png

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login Page</title>
    <link href="https://fonts.googleapis.com/css2?family=Song+Myung&display=swap" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href = "mystyle.css">
</head>
<body>
    <div class="wrap">
        <div class="mytitle">
            <h1>Login Page</h1>
            <h5>Enter your ID and password</h5>
        </div>
        <p>ID: <input type="text" /></p>
        <p>PW: <input type="text" /></p>
        <button> Login</button>
    </div>
</body>
</html>

image.png

More from this blog

Ollie Seongyong Kim

85 posts