Good day. I can not understand why it does not work.
The style for h1 specifically added to just check whether the file is "connected" or not. On h1 style is applied.
At the same time, if you apply the style directly in html , the style works. Tried input or input[type="text"]

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Формы</title> <link rel="stylesheet" href="/form.css" type="text/css"> </head> <body> <form action="form1.php" method="post"> <input type="text" class="test" name="test" placeholder="Введите текст" autofocus> <input type="submit" value="Добавить"> </form> <h1>Hello</h1> </body> </html> <style> input{ width: 100%; } h1{ color: green; } </style> 

    2 answers 2

    1. Single tags should be closed <meta /> ;
    2. <style>...</style> should be in <head>...</head> ;
    3. Check the path to the form.css file, possibly extra / in the path form.css ;

    The code above works - the header is green and the form is stretched.

    • The first item is optional! - HamSter
    • It does not work for me. - ev.ta
    • <style> h1 {text-align: center; } input {width: 100%; } </ style> - ev.ta
    • What is above, input works, but h1 does not work. Accordingly, you can swap places in the css file, then we get the opposite. H1 works no input - ev.ta

    /form.css - check the path to the form style file.

     <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Формы</title> <link rel="stylesheet" href="/form.css" type="text/css"> <style> input{ width: 100%; } h1{ color: green; } </style> </head> <body> <form action="form1.php" method="post"> <input type="text" class="test" name="test" placeholder="Введите текст" autofocus> <input type="submit" value="Добавить"> </form> <h1>Hello</h1> </body> </html> 

    • I actually green and checked. That is the right way - ev.ta