Is CSS giving error?

后端 未结 19 1378
傲寒
傲寒 2020-12-29 21:35

At a recent interview I was asked the question \"Is CSS giving error?\" by the interviewer.

Is there an interpreter working behind CSS which blocks

19条回答
  •  春和景丽
    2020-12-29 22:14

    CSS is not a real programming language but a domain-specific language (https://en.wikipedia.org/wiki/Domain-specific_language).

    In contrast to scripting languages like JavaScript or PHP (which are Turing-complete programming languages) as well as real programming languages like Java or C CSS will not "give errors" as CSS-code is not real program source code.

    However as any domain specific language CSS has a syntax and is read by an interpreter (very similar to a declarative Turing-complete programming language).

    If the syntax is not correct (test here: https://jigsaw.w3.org/css-validator/#validate_by_input) the CSS is invalid. It depends on the interpreter used how to deal with invalid CSS parts, interpreters in common Web browsers will not halt on CSS syntax errors.

    This question therefore can not be explicitly answered:

    • CSS can be invalid (syntax)
    • CSS can have "syntax errors"
    • CSS will not "give" errors and errors are usually just ignored by common interpreters

提交回复
热议问题