CSS 대한 질문입니다

절차탁마의 이미지

요즘 web을 공부하면서
궁금한점이 하나 생겨서 질문 올립니다.

CSS에서 왜 cascading이라는 수식을 할까요?
네이버에는 연속형/종속형이라 나옵니다

위키피다아에는 다음과 같이 나옵니다만,
사전적인 뜻하고 도저히 연결이 않되는군요.

CSS specifies a priority scheme to determine which style rules apply if more than one rule matches against a particular element. In this so-called cascade, priorities or weights are calculated and assigned to rules, so that the results are predictable.

답변해주시면 고맙겠습니다

절차탁마의 이미지

음..로긴했을때와 않했을때 보이는 목록이 차이가 있군요.
왜그렇죠?

sephiron의 이미지

새로고침을 해 보세요.

Prentice의 이미지

콕 집어 언급하는 것일 수록 우선순위가 높게 지정되기 때문에 그렇습니다.

body { color: red; background-color: white;}
p { color : green; }

body보다 p가 하위요소이므로 p는 녹색이 됩니다. (자식 이기는 부모는 없습니다.)

p { color: green; }
p.emphasis { color: yellow; background-color: blue; }

<p class="emphasis">가 그냥 <p>보다 구체적이므로 class="emphasis"가 붙은 문단은 파란 바탕에 노랑색이 됩니다.

----

보통 p는 배경색을 body한테서 상속 받았지만 class="emphasis"인 녀석은 상속 받지 않았습니다. CSS 선언문을 어떻게 주느냐에 따라 상속이 되는 경우가 있고 안되는 경우가 있습니다. (id가 class에 우선하는 것 등등.) 기본 원칙은 구체적인 것일 수록 적용이 잘 된다, 입니다.

이렇게 선별적 중첩방식으로 포개지기 때문에 cascading이라고 부릅니다.

bootmeta의 이미지

말 그대로 작은 폭포들이 계속해서 이어져 있는 상황을 연상하시면 될 듯합니다.
단계적으로 첫 단계에서 같은 항목에 대해 적용되는 룰을 이어지는 다음 단계에서 다시 같은 항목에서 다른 룰로 변경된다면 이전 적용 룰을 무시하고 변경된 룰이 적용됩니다. 폭포가 이어지는 한 계속해서 반복되겠죠. 물론 룰이 변경되지 않으면 기존 룰이 적용됩니다.

안타깝지만 이런 번역의 문제때문에 어쩔 수 없이 원서를 보는 것이 속 편할 때가 많습니다. -_-

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.