How to find error in css code. Checking CSS for validity using the CSS Validation Service. Making buttons interactive

Checking a web code for validity is checking it against W3C standards and certificates.
The W3C (World Wide Web Consortium) are the Web's technical legislators who develop standards and guidelines for coding. W3C certificates and standards are mandatory for everyone who works on the web. Uniform standards in code spelling are needed so that all Web applications communicate in a single language space, in standard languages, and understand each other while working with Web documents.
The W3C not only creates Networking Standards, but also actively promotes their implementation.
The W3C has online services for checking HTML / XHTML and CSS code for validity.
Checking your code against W3C standards using W3C validators is the best way out.

Free online services from W3C to check code for validity.
W3C validators have an intuitive interface. It's easy and simple to work with them.
The services make it possible to check in three modes and have, accordingly, only three buttons:
Check URL
(for verification, you need to specify the address of any page of the site available on the Web)
Check uploaded file
(for verification, you need to specify the path to the scanned file)
Check typed text
(for verification, you need to copy and paste the verified code into the validator window)

The last two methods are especially useful when checking web documents or texts located on local computers. These can be web pages, either already downloaded from the Web to a local computer, or generated by engines located on local servers, such as "Denver". In the case of Denver, you need to save the page through the browser as a file with the .html extension and then check it as a separate file, or copy the source code of the web page directly from the browser and check it as typed text.

How to use the W3C online validators.
we turn to the validator, at:
(http://validator.w3.org/ - for HTML or XHTML validation
http://jigsaw.w3.org/css-validator/ - for CSS validation)
in the opened validator window, select one of three verification methods
(site page url, local file or typed text)
go to the corresponding tab
specify the object of verification
(enter the url of the checked web page,
or the path to the file on the local computer,
or insert the tested code, respectively)
press the button "Check" and look at the result of the check

Services from the W3C check the code for validity and immediately indicate errors if there are any. Each error will be commented on. The comments are, unfortunately, in English. So Google Translate is there to help you, all you have to do is fix the code and check it again for consistency if necessary.
W3C validators are completely free and automated. Therefore, you can hammer them with your work on mistakes for a long time and with impunity. For this, these services are created.

A normal alternative to W3C validators.
In addition to the W3C web code validation online servers, the HTML Validator extension for the Mozilla Firefox browser gives very good results. The presence of such an add-on in the browser facilitates the work of the webmaster and proves once again that Mozilla Firefox is the "steering" browser.
You can download the dauber extension here: http://users.skynet.be/mgueury/mozilla/

You can install the extension like this:
- Launch Firefox.
Next: Menu - Tools - Add-ons - Extensions.
And, just drag the downloaded file (xpi extension) into the opened window with the mouse.
After that, the extension will be installed automatically.

or (second way):
- Launch Firefox.
Next: Menu - File - Open File - specify the path to the downloaded file.
After that, the extension, again, will be installed automatically.

After the installation is complete, you will need to restart the browser.
On restart, a window will appear with a choice of the method for scanning web pages:
"HTML Tidy" or "SGML Parser" or "Serial"
We choose the "SGML Parser" method as the most convenient and acceptable option. Click the corresponding button. Now, in the browser window, the add-on icon will be displayed, and next to it is the add-on settings menu button.
I have - above and on the right:

HTML Validator for Mozilla Firefox browser works completely automatically. He doesn't need to be shown what to check. It checks all documents that will be opened in Mozilla Firefox. It is very convenient. It is enough to look at the color of the program label to understand whether or not there is a problem in the open document.
Depending on the test results, the color of the icon can be green, yellow or red, which means the following:
green - "no errors", everything is "OK"
yellow - "no errors, but warnings"
red - "there are mistakes"

When you click on the shortcut, a window will open containing the source code of the viewed page with explanations and comments to errors and warnings, if any.
Something like this.

Welcome! So we came to an end. There is a whole year of fruitful work ahead, many interesting ideas have been outlined, and now the only thing left is to bring them to life 🙂 You can follow the course of events and see how freedom of thought is expressed in action - just subscribe to the blog, I assure you - it will not take much time ...

Today my task is to find out if the correct source code that has passed the test affects anything and, if so, how much. And as always, I am waiting for your opinions on this in the comments.

Last year, I paid a lot of attention in my publications to such a term as validity, it's time to figure out which ones are. advantages of valid HTML... Earlier, together with you, we discussed how to check for validity, as well as channels and a few other interesting points.

Four main factors in favor of a valid website

First, we can say with a hundred percent certainty that pages that have passed the validator test will display correctly in absolutely all modern browsers - and this is no less important than. Agree, it's not very pleasant to see the layout with distorted elements in front of you. And the visitor is unlikely to return to such a blog, where its author is disdainful of the appearance and.

Secondly, even if you think logically, removing unnecessary tags and other "garbage", we reduce the page weight and thereby reduce the page load time, and browsers spend less time processing such pages. You know, there is such a saying: "Less words, more action", if you rephrase it and apply it to site building, you get something like "Fewer tags - more words."

And these are not empty words, everyone who has ever encountered problems with Yandex received a response from technical support: improve the site and work on it. For example, in the Yandex Webmaster toolbar, you can find help for the section, which contains recommendations for creating sites.

If you carefully study this document, then paragraph 3 "Layout" sets out the following:

Try to keep your page layout up to standard

Thirdly, if you are engaged in the creation of websites to order or promote them, then you probably must know the languages \u200b\u200bHTML and CSS, and if so, then why deliberately create errors? In addition, customers sometimes set a task for the contractor: to use a valid code, respectively, and the prices will be much higher for the work performed.

And, finally, fourthly, the psychological factor plays an important role. It's nice to know that the work done meets certain criteria and standards, in our case, the standards of the World Wide Web Consortium. And as you know, psychology is a great thing! So don't ignore her.

Eh, it's so nice to see such an inscription 😉

Hello everyone!

Checking the validity of HTML code is necessary for, because search robots see only HTML code. For this reason, it is advisable to put the site code in full order. In this we will be helped by special online services that perform code verification and point specifically to errors.

One such service is the validator.w3.org validator, which is probably the best. It is completely in English, so some people may have problems when working, but don't be alarmed: the validator will show you both the line number and the error itself.

A valid code is a code that meets all standards.

For the lesson, you will need the following material:

The aforementioned online service checks the HTML code online on the entire site. You just need to specify the domain of your site and click the "Check" button, so you start checking the HTML-code of the site.

Also, the validator provides one very interesting feature - checking site files from the local computer. In my opinion, this tool is useful for those who make websites to order. Before placing the order, you need to double-check everything, because you want to be always satisfied with your work. You can check the files by going to the “Validate by File Upload” tab:

How do I fix errors in HTML code?

The Validator W3c service pointed out two errors to me and issued 8 warnings. I will try to fix them and show you how to do it in one piece.

We fix the error “Element style not allowed as child of element div in this context. (Suppressing further errors from this subtree.) ”. This error tells me that in the HTML code, namely the tag

there is no need to write styles. Therefore, the styles that are written in this block
you need to transfer it to the style.css file and that's it.

The validator also indicates where the error is located:


This way you can find and fix HTML errors. But sites consist not only of markup code, but also CSS, so we also check the cascading style sheets of the web resource.

Checking CSS code for validity

The W3c validator can also check the CSS code for validity. You can do this at this link. The principle of operation is the same: specify the URL of the site, or select a file on your computer and click on the "Check" button.

Unlike the same HTML validator, the CSS validator is in Russian.

CSS errors and warnings

When checking CSS code for validity, the service issues a large number of errors and warnings. I got 23 errors and 281 warnings. At first glance, it may seem that this is a lot and may even be scary, however, most of the indicated errors and warnings are shown only because the service does not know certain properties that apply to different browsers.

In my case, most of the 281 warnings are CSS properties to display normally in different browsers:

The service positions such tags as “unknown vendor extension”. Therefore, if, when checking your CSS files, you see a large number of such errors, then do not be alarmed. It's okay.

I will not list the most common errors and ways to eliminate them, since everyone's solutions may be different and you need to look at the HTML code itself to understand what is wrong.

If you cannot eliminate some error, then share the problem in the comments to the lesson, maybe we will find a solution together.

I hope that the lessons that came out during this week were useful for you and helped in solving certain problems.

Well, now, goodbye!

Previous article
Next article

2016-12-29


We animate the buttons and check the site for the validity of the HTML and CSS code

Hello dear visitor!

Today we will consider, using the example of a created web page, how you can check the site for validity, namely, for compliance with the established specifications of the HTML and CSS languages.

In addition, before checking, we will make some revision of the CSS stylesheet in the part related to "animating" the sidebar buttons, where we will make static buttons interactive, changing their appearance depending on their state - passive, active and pressed.

  • Making buttons volumetric
  • Making buttons interactive
  • Do you need validation
  • How to validate HTML code
  • How to validate CSS code
  • Site source files

Making buttons volumetric

In the previous article, we styled the main content area to match the layout of the home page. At the same time, at the moment there are buttons in the sidebar that are static and look like a regular flat brown rectangle with rounded corners.

Below is a fragment of a sidebar with such buttons.

In order to "animate" the buttons, we first give them some volume with the help of CSS styles. And we will do this using the linear gradient property, which was previously used in the design of the rotator, search and subscription blocks.

We define the linear gradient values \u200b\u200bas follows:

1. Color shades will be set from bottom to top, starting with a darker color than the main color of the button. To determine which color to use at the beginning of the gradient, we use the tool of a graphics editor, in this case photoshop.

To do this, with an open design layout document, select the "Color Picker", move the cursor over the required area of \u200b\u200bthe button, define the main color and then use the "Color Picker" tools to select a darker color of the same brown shade. In our case, let's take a color with the value "653939". How this can be done is clearly shown in the screenshot below.


2. Next, define the stop position of the gradient where the initial, darker color will transition to the main one. Place the stop position approximately in the middle. At the same time, in order to make a more saturated color, we will move the stop position up a little, and define its value, say, 70% of the height.

3. The last thing to do to assign properties to the gradient is to define a lighter color than the base color that will color the buttons at the top. This is done in the same way as when defining the initial gradient color. In this case, we will take the value of this color as "b88686".

3. Based on the received data, add a linear gradient to the previously generated CSS properties of the buttons.

    input: {

    height : 30px;

    margin-bottom : 10px;

    border-radius : 5px;

    background : # a76d6d;

    text-align : center;

    font-weight : bold;

    color : #fff;

    float : right;

    background-image

It can be noted that when determining the extreme colors, stop positions are not indicated here, since at values \u200b\u200bof 0% and 100% this is not necessary.

Now, let's refresh the browser and see the result.

As you can see, the buttons have acquired a slight bulge. Now you can start "revitalizing" them.

Making buttons interactive

In order to fully work with the buttons, we will make them interactive, which will visually reflect their three main states, passive (the button is in its initial state), active (the cursor is hovering over the button) and pressed (when the cursor is hovering, the mouse button is pressed and held).

And this will be done using a combination of shadow and border properties. The essence of this technique is that by changing the color of the shadow and borders from different sides, you can achieve an imitation of the change in the state of the buttons.

First, let's do this for the passive state and try to portray it so that the buttons rise above the surface.

We'll choose the colors of the borders and shadows in the same way as in the previous cases.

The CSS code after the appropriate additions will take the form.

    input: {

    height : 30px;

    margin-bottom : 10px;

    border-radius : 5px;

    background : # a76d6d;

    text-align : center;

    font-weight : bold;

    color : #fff;

    float : right;

    background-image : linear-gradient (to top, # 653939, # a76d6d 50%, # b88686);

    box-shadow : 2px 2px 4px 0px # 422a2a;

    border-width : 2px;

    border-style : solid;

    border-color : #ddbebe # 241616 # 241616 #ddbebe;

It can be noted here that borders are represented by a combination of properties that determine the thickness (border-width with the value 2px ), a style (border-style) with a value that specifies a solid border and colors (border-color) on each of the four sides.

Let's update the browser and see how the buttons will now look.

As you can see, the buttons seem to be raised in this state.

Now let's try to make the buttons look like a pressed state. To do this, we will remove the shadow, and change the color of the borders. In this case, we will use a special pseudo-class selector: hover corresponding to the active state.

The CSS for the active state of the buttons will look like this.

    input: hover {

    box-shadow : none;

    border-color : # a76d6d # a76d6d # a76d6d # a76d6d;

In this case, we will change the color of the borders again and add a shadow, only in this case it will be internal and without displacement. The pseudo-class selector will also change to: active, corresponding to the pressed state.

The CSS code for the pressed state will be as follows.

    input: active {

    box-shadow : 0px 0px 7px 2px # 422a2a inset;

    border-color : # 777 #fff #fff # 777;

The "Search" button is shown below for comparison, where you can clearly see how it changes its appearance depending on the state.


Fig. 8 Passive state

This is where we finished the layout of the main page and brought it to a form that matches the design layout. And now we must, as before at each stage, check it for cross-compatibility in different browsers. But before that, let's check the page for validation, since the state of the code can, to some extent, affect cross-consistency. Therefore, now we will perform this very necessary operation.

Do you need validation

Validation is the verification of code against established standards. Distinguish between validation for correctness of HTML and CSS code. It is clear that in one case the HTML code is checked, in the other the CSS code.

Probably, many will find it strange the question of whether validation is needed. But if you look on the Internet, you can see that there are many who believe that valid code is optional, that this is a waste of time, since browsers work well even with all kinds of errors.

Of course, in many cases, sites can work well on invalid code, but cross-consistency in such cases will definitely not be guaranteed. After all, there are standards for the programming languages \u200b\u200bthemselves, but for the fact that browsers correct errors in the same way, such a standard, of course, does not exist and cannot be. And therefore, different browsers can handle errors in different ways, which can lead to different display of pages.

And in general, it is not clear why some people have such a figurative attitude towards their work, according to the principle "it will do just that." Therefore, if someone thinks that he does not need to check the code for validity, then this is his right, and he can hardly be convinced of the opposite, and there is no need.

Now let's move on to directly checking the validity of the codes, first HTML, then CSS.

How to validate HTML code

In fact, the code validation check itself is quite simple, as can now be seen. But, the elimination of errors usually takes a certain amount of time. Of course, if the code consists of several lines, then difficulties can arise here. But, if there are hundreds and thousands of them, then you may have to work hard, it all depends on how well the code was compiled. Therefore, it is better to do this more often with a joint cross-matching check.

Here we will consider the simplest and most common option for checking for validity - this is the use of the "W3C Consortium" site, which, with the support of browser developers, develops specifications for web page codes.

To check the HTML code, just follow the link https://validator.w3.org/, where a page with a field for entering the address of the page being checked will open.

screenshot 51


After pressing the "Check" button, we will receive the check result.


In this case, the HTML code is valid, but there is a recommendation to use the lang attribute with the value "ru" , since the page uses Russian.

The lang attribute is intended for browsers to display certain characters, such as quotation marks, correctly, depending on the language being used. Therefore, it will not be superfluous for us to include it in the HTML code. And we will do this in the html tag so that this attribute can affect the entire document.

How to make this addition is shown in the following table.

    "ru" >

    . . .

And now, if we do a second check, we can see that the code has become fully valid without any comments.


In this way, we checked the file posted on the Internet. But when the page has not yet been posted on the web, you can check its validity in other ways, this is either upload the file using the browse button, or use the form to directly copy the HTML code.

The screenshot shows the last option, when the web page code is copied directly into the form for validation.


After performing the check, we get a similar result, and the checked code will also be shown here. In the event that errors are found, they will be highlighted to simplify the search, which greatly simplifies the work to eliminate them.


How to validate CSS code

We've covered HTML validation checking. The CSS code is checked in exactly the same order. Only in this case, you need to use another validator page, which for this case is located at http://jigsaw.w3.org/css-validator/.

Let's open it and, just like the previous time, enter the address of the page to be checked, and then press the "Check" button.

The result of this check is shown in the screenshot.


As you can see, our CSS code is fully compliant with the specification without any errors, which is a good result.

The order of the other verification methods for this case completely coincides with similar checks for HTML-code. Therefore, we will not repeat ourselves here, and this is where we will end the consideration of validation checks.

After that, we will check our page for cross-matching and making sure that it is displayed the same on all browsers, this will complete the layout of the site's main page.

And, we will deal with this immediately after the New Year holidays.

And in conclusion, you can wish everyone a Happy New Year! And wish you health, love, joy, prosperity and, of course, great success in creating your own website for the possibility of successful work on the Internet in the New Year!

Site source files

The source files of the site with the updates that were made in this article can be downloaded from the attached additional materials.