Is CSS giving error?

后端 未结 19 1303
傲寒
傲寒 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:21

    Is CSS giving error? Does CSS work on its own with it's own separated "compiler"?

    Sure, NOT, as for CSS the browser is the component of the execution process that gives errors while CSS on its own cant.

    Example

    #foo{
        Bar: 50%;
        Nonsense: 100%;
        color: red
        }
    

    In this case the browser will ignore the Bar ans Nonsense proprieties and jump to color propriety. And you will have no Exception or error thrown, unlike JS (just for comparison). So the obvious answer is No!

    0 讨论(0)
  • 2020-12-29 22:22

    css can block program in such a way, if you have button and some css properties are not allowing it to display well on your page, in that case we can say it is blocking, otherwise it is not blocker for execution. even errors don't block the execution, it just misplace or display the things improperly.

    0 讨论(0)
  • 2020-12-29 22:24

    In the CSS there is no errors but you can face some errors in the browser's console, That could be the browser giving error but not CSS throwing error.

    0 讨论(0)
  • 2020-12-29 22:25

    "Is CSS giving error ?" - No

    CSS itself don't gives error. It will just ignore that attribute if it is incorrect. If there is syntax error then it will also ignore the same and if any other selector get effected due to syntax error (like missing of '}') that also will be ignored.

    There are various IDE (like visual studio) highlight your errors. As gabe3886 told you can also validate your syntax using W3C CSS Validator

    0 讨论(0)
  • 2020-12-29 22:30

    Generally errors in the CSS doesn't cause any error messages in the browser. Any incorrect code is simply ignored (or in some cases accepted by assuming a missing part, e.g. a length unit).

    The CSS parser tries to recover after each incorrect code, so usually it will only affect the style or the rule where the error is, the parser won't just stop parsing the rest of the CSS code.

    Some browsers will add warnings to the error console for errors in the CSS, so developers can open the console to see if there is any errors.

    0 讨论(0)
  • 2020-12-29 22:30

    CSS rendering is a process of the browser (or similar) and is intended to not "throw an error" (exception, etc). ...In theory.

    (bugs in libs/dependencies could cause true errors such as a certain combination of characters freaking out the greater OS. These bugs are well documented on all operating systems and beyond but operate on the fringe of this inquiry)

    I have read many times, from many sources, that each browser desires a compliant CSS feature and does their best to "absorb" bad or mistake riddled syntax recovering as promptly as possible. Having a CSS interpreter hang (error) is totally possible, but I always think of the final implementation of CSS parsing as a flavor of a major anti-pattern in Python:

    # bad code, just some theory, my Python code "always works"
    try:
        # code
    except:
        pass
    

    where any and all errors are swallowed.

    As others have stated, "Is CSS giving error?" is a bad or possibly trick question. CSS is syntax or language.

    So here's the real deal: Language gives no errors and has no capacity for error. Only the interpretation of the language may errors be provided (as a product of evaluation). Only the evaluation has the capacity to find error.

    If the term "parser" was added to the question then YES, the CSS parser is giving error. But as the phrase stands in your (un-edited) post, I would answer with some linguistic whoop-a$$ and a little CS-101: No, here's why...

    Just my $0.02 from a Programmer + Linguist.

    0 讨论(0)
提交回复
热议问题