1. Eric Meyerโ€™s CSS reset ๐Ÿ‘ฉโ€๐Ÿ’ป

๋ธŒ๋ผ์šฐ์ €๋งˆ๋‹ค ๊ธฐ๋ณธ ์Šคํƒ€์ผ์ด ๋‹ค๋ฅด๊ณ , ๋ถˆํ•„์š”ํ•œ ์Šคํƒ€์ผ๋„ ๋งŽ์•„์„œ ๊ฐ€๊ธ‰์ ์ด๋ฉด ๋ฆฌ์…‹ ์‹œ์ผœ์ฃผ๋Š” ๊ฒƒ์ด ์Šคํƒ€์ผ์„ ์ž‘์„ฑํ•˜๊ธฐ ์‰ฝ๊ณ , ํฌ๋กœ์Šค ๋ธŒ๋ผ์šฐ์ง•์— ๋„์›€์„ ์ค€๋‹ค. ์ด๊ฒƒ์„ Reset CSS ๋ผ ํ•˜๋Š”๋ฐ ๋Œ€๋ถ€๋ถ„์˜ Reset CSS ๋Š” Eric Meyer๊ฐ€ ์ œ์‹œํ•œ ๊ฒƒ์„ ๊ธฐ์ค€์œผ๋กœ ํ•˜๊ณ  ์žˆ๋‹ค.


2. Create CSS File ๐Ÿ‘ฉโ€๐Ÿ’ป

์ฒซ ๋ฒˆ์งธ ๋ฐฉ๋ฒ•์€ ์ง์ ‘ CSS ํŒŒ์ผ์„ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด๋‹ค.

meyerweb ์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ CSS ๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  line-height: 1;
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

๋ฌผ๋ก , ๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ ์ด๊ฒƒ๋งŒ์œผ๋ก  ์ถฉ๋ถ„ํ•˜์ง€ ์•Š์•„์„œ ๊ฐœ์ธ์ ์œผ๋กœ ๊ณตํ†ต์œผ๋กœ ์ ์šฉํ•˜๊ณ  ์‹ถ์€ ์Šคํƒ€์ผ์„ ํ•จ๊ป˜ reset ์— ์ถ”๊ฐ€ํ•˜๋Š” ํŽธ์ด๋‹ค.

a {
  text-decoration: none;
  color: inherit;
}
* {
  box-sizing: border-box;
}
input, textarea {
  -moz-user-select: auto;
  -webkit-user-select: auto;
  -ms-user-select: auto;
  user-select: auto;
}
input:focus {
  outline: none;
}
button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

์ด ๋‘˜์„ ํ•ฉ์ณ ์ง์ ‘ reset.css ํŒŒ์ผ์— ์ž‘์„ฑํ•ด ๋„ฃ์–ด ์ œ๊ณตํ•ด ์Šคํƒ€์ผ์„ ์ดˆ๊ธฐํ™” ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

  • Customized reset.css
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  line-height: 1;
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
a {
  text-decoration: none;
  color: inherit;
}
* {
  box-sizing: border-box;
}
input, textarea {
  -moz-user-select: auto;
  -webkit-user-select: auto;
  -ms-user-select: auto;
  user-select: auto;
}
input:focus {
  outline: none;
}
button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

3. JSDelivery ๐Ÿ‘ฉโ€๐Ÿ’ป

JSDelivery CDN ์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์„ CDN ์—์„œ ์ง์ ‘ ๊ฐ€์ ธ๋‹ค ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜ npm ์œผ๋กœ ์„ค์น˜ํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. ๋ฌผ๋ก , ์ด ๋ฐฉ๋ฒ• ์—ญ์‹œ Eric Meyer์˜ Reset CSS ๋ฅผ ์‚ฌ์šฉํ•ด ๋งŒ๋“ค์–ด์กŒ๋‹ค.

CDN ์„ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ JSDelivr ๋ฅผ ๋ฐฉ๋ฌธํ•ด ์ตœ์‹  ๋ฒ„์ „์„ ํ™•์ธ ํ›„ ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค.

<!-- static version -->
<link href="https://cdn.jsdelivr.net/npm/reset-css@5.0.2/reset.min.css" rel="stylesheet">
<!-- latest minor -->
<link href="https://cdn.jsdelivr.net/npm/reset-css@5/reset.min.css" rel="stylesheet">
<!-- latest major -->
<link href="https://cdn.jsdelivr.net/npm/reset-css/reset.min.css" rel="stylesheet">

์ด ์™ธ์—๋„ npm, yarn, bower๋ฅผ ์‚ฌ์šฉํ•  ์„ค์น˜๋ฅผ ์ œ๊ณตํ•˜๋ฉฐ, ์—ฌ๋Ÿฌ ์Šคํƒ€์ผ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ํ†ตํ•ฉ์„ ์ œ๊ณตํ•œ๋‹ค.

npm i reset-css
yarn add reset-css
bower install reset-css


  • CSS
@import '/path/to/reset-css/reset.css';
  • PostCSS and postcss-import
@import 'reset-css';
  • webpack and css-loader
import 'reset-css';
  • Less
@import '/path/to/reset-css/less/reset';
  • Sass
@import '/path/to/reset-css/sass/reset';

์ดํ›„ ์ถ”๊ฐ€๋กœ ์ฒ˜๋ฆฌํ•˜๊ณ ์ž ํ•˜๋Š” ๋ฆฌ์…‹ ์Šคํƒ€์ผ์„ ์ž‘์„ฑํ•˜๋ฉด ๋œ๋‹ค.

a {
  text-decoration: none;
  color: inherit;
}
* {
  box-sizing: border-box;
}
input, textarea {
  -moz-user-select: auto;
  -webkit-user-select: auto;
  -ms-user-select: auto;
  user-select: auto;
}
input:focus {
  outline: none;
}
button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

4. Styled Reset ๐Ÿ‘ฉโ€๐Ÿ’ป

Styled Components ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ์ปดํฌ๋„ŒํŠธ ๋ฐฉ์‹์œผ๋กœ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋ฉฐ, ์—ญ์‹œ Eric Meyer์˜ Reset CSS ๋ฅผ ์‚ฌ์šฉํ•ด ๋งŒ๋“ค์–ด์กŒ๋‹ค.

Styled Components ๋ฒ„์ „์— ๋”ฐ๋ผ ์‚ฌ์šฉ ๋ฐฉ์‹์ด ์กฐ๊ธˆ์”ฉ ๋ณ€๊ฒฝ๋˜๋‹ˆ NPM JS ๋ฅผ ๋ฐฉ๋ฌธํ•ด ํ˜„์žฌ ๋ฒ„์ „๊ณผ ์ผ์น˜ํ•˜๋Š” ์‚ฌ์šฉ ๋ฐฉ๋ฒ•์ธ์ง€ ํ™•์ธํ•˜๋„๋ก ํ•œ๋‹ค. ๋‹ค์Œ์€ Styled Components 4+ ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์„ค๋ช…ํ•œ๋‹ค.

npm i styled-reset

์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” reset-css ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ๋‹ฌ๋ฆฌ Styled Components ๋กœ ์ž‘์„ฑํ•œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์•ฑ์— ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์‚ฌ์šฉ๋˜๋ฉฐ, ์‚ฌ์šฉ ๋ฐฉ๋ฒ•์€ ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค.

1. Reset component

๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณต๋˜๋Š” Eric Meyer ์˜ Reset CSS ๋งŒ ์ ์šฉํ•˜๊ณ ์ž ํ•  ๊ฒฝ์šฐ ๊ธฐ๋ณธ ์ œ๊ณต๋˜๋Š” ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import { Reset } from "styled-reset";
import { BrowserRouter } from "react-router-dom";

const root = ReactDOM.createRoot(document.getElementById("app-root") as HTMLElement);
root.render(
  <React.StrictMode>
    <Reset />
    <BrowserRouter>
      <App />
    </BrowserRouter>
  </React.StrictMode>,
);

2. createGlobalStyle

๋ณ„๋„์˜ CSS ํŒŒ์ผ์„ ์ž‘์„ฑํ•˜์ง€ ์•Š๊ณ  Styled Components ๋งŒ์„ ์‚ฌ์šฉํ•ด ์ˆ˜์ •๋œ Reset CSS ๋ฅผ ์ œ๊ณตํ•˜๊ณ ์ž ํ•  ๊ฒฝ์šฐ ์ œ๊ณต๋˜๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด ํ™•์žฅ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

import { createGlobalStyle } from "styled-components";
import reset from "styled-reset";

const GlobalStyle = createGlobalStyle`
  ${reset}
  a {
    text-decoration: none;
    color: inherit;
  }
  * {
    box-sizing: border-box;
  }
  input, textarea {
    -moz-user-select: auto;
    -webkit-user-select: auto;
    -ms-user-select: auto;
    user-select: auto;
  }
  input:focus {
    outline: none;
  }
  button {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
  }
`;

export default GlobalStyle;
import React from "react";
import GlobalStyle from "./GlobalStyle";

function App() {
  return (
    <>
      <GlobalStyle />
      <div>Hi, I'm an app!</div>
    </>
  );
}

export default App;