and All geek questions in one placeHTML attribute with / without quotesIs there a difference between<iframe src="www.example.com" width=100%></iframe> and <iframe src="www.example.com" width="100%"></iframe> I tried both, and both seem to work, but I ask, just in case, that I need to be careful (for example, units other than%, etc.).+12html quotesJohn Oct 24 '12 at 19:53source share7 answersIt's all about the true validity of HTML markup. This is what the W3C (WWW Consortium) is for. Many things can work in HTML, but they need to be checked to be more carefully recognized by the web browser. You can even omit the <html> and </html> tags at the beginning and at the end, but this is not recommended at all, no one does this and is considered "bad code."Therefore, it is more advisable to put them in quotation marks.0Davit Oct 24 '12 at 19:56source shareThere is no practical difference exceptif you are checking your page, quotation marks may or may not be necessary to avoid error messages, depending on the type of doctype usedif you serve a page with an XML content type for browsers (rarely and rarely useful), then you need quotes - otherwise the page does not appear at all, just an error messageIf the page is otherwise processed using XML tools, quotation marks are required.Otherwise, quotation marks are really needed only if the attribute value contains a space, line break, quotation mark Ascii ("), apostrophe Ascii ('), serious accent (`), equal sign (=), less sign (<) or more than a character (>). Thus, style = width:20em will work (although it can be considered somewhat obscure), while style = width: 20em will not - because of the space, you need to write style = "width: 20em" .Many people always write quotes around all attribute values, for simplicity. Others think that quotation marks make the code a little dirty, so they omit them whenever possible.Whatever it is, src="www.example.com" means a relative URL link, not what people expect. You probably meant src="http://www.example.com" .+13Jukka K. Korpela Oct 24 '12 at 21:49source shareAccording to the W3C, there are four types of attribute syntax:empty attribute syntaxSyntax of attribute value without quotessingle-quote attribute value syntaxdouble-quoted attribute value syntaxThis is true for HTML5, however when referenced to & lt; HTML5 W3C says quotation marks (single or double) are required depending on the type of document used (e.g. strict, transitional, etc.).+6j08691 Oct 24 '12 at 20:01source shareThis is from Google - best practices - "Minimize payload size" https://developers.google.com/speed/docs/best-practices/payload (my emphasis)To keep your content compressed well, follow these steps: ... Use consistent quotes for the attributes of HTML tags, i.e. always a single quote, always a double quote, or no quotation at all , if possible.+3tomo7 Mar 6 '14 at 13:08source shareNo, both are the same ..In HTML 5, quotation marks around attributes are simply optional. (if there are no spaces or special characters in the value)But I think it's better to quote them.+1Sushanth - Oct 24 '12 at 19:55source shareThe syntax of a value without quotesThe name of the attribute, followed by zero or more spaces, followed by one character U + 003D EQUALS SIGN, followed by zero or more spaces, followed by the value of the attribute, which, in addition to the requirements given above for attribute values, is not must contain letter spaces, any characters U + 0022 QUOTATION MARK ("), characters U + 0027 APOSTROPHE ('), characters U + 003D EQUALS SIGN (=), characters U + 003C LESS-THAN SIGN (& lt;), U + 003E BIG CHARGE characters (>) or U + 0060 GRAVE ACCENT characters ('), and should not be an empty string.- W3 HTML5 Specification - sec 8.1.2.3. Attributes+1georgeawg Aug 08 '18 at 17:22source shareThere is a big difference. Most browsers will see the absence of quotes and automatically insert them. If you looked at the element, you would see it. Always put quotes around values ββfor non-smart browsers-1Zak Oct 24 '12 at 19:56source shareSource: https://habr.com/ru/post/1441897/More articles:Parsing YYYY-MM-DD dates strictly on Linux - linuxDelphi - Hide console window - delphiCreating a new table from two existing tables with the possibility of each combination - sqlHow to hide the console window? - delphiC # .net winforms DataGridView footer - c #Rapid device testing << in C ++ - c ++How to WebBrowser.Navigate () from BackgroundWorker? - c #Building a custom expression tree in Spirit: Qi (without Utree or Boost :: Variant) - c ++is there any advantage to using int instead of float without decimal numbers? - floating-pointHow to add qi :: characters in the grammar? - c ++All Articles
Is there a difference between
<iframe src="www.example.com" width=100%></iframe>
and
<iframe src="www.example.com" width="100%"></iframe>
I tried both, and both seem to work, but I ask, just in case, that I need to be careful (for example, units other than%, etc.).
It's all about the true validity of HTML markup. This is what the W3C (WWW Consortium) is for. Many things can work in HTML, but they need to be checked to be more carefully recognized by the web browser. You can even omit the <html> and </html> tags at the beginning and at the end, but this is not recommended at all, no one does this and is considered "bad code."
<html>
</html>
Therefore, it is more advisable to put them in quotation marks.
There is no practical difference except
Otherwise, quotation marks are really needed only if the attribute value contains a space, line break, quotation mark Ascii ("), apostrophe Ascii ('), serious accent (`), equal sign (=), less sign (<) or more than a character (>). Thus, style = width:20em will work (although it can be considered somewhat obscure), while style = width: 20em will not - because of the space, you need to write style = "width: 20em" .
style = width:20em
style = width: 20em
style = "width: 20em"
Many people always write quotes around all attribute values, for simplicity. Others think that quotation marks make the code a little dirty, so they omit them whenever possible.
Whatever it is, src="www.example.com" means a relative URL link, not what people expect. You probably meant src="http://www.example.com" .
src="www.example.com"
src="http://www.example.com"
According to the W3C, there are four types of attribute syntax:
This is true for HTML5, however when referenced to & lt; HTML5 W3C says quotation marks (single or double) are required depending on the type of document used (e.g. strict, transitional, etc.).
This is from Google - best practices - "Minimize payload size" https://developers.google.com/speed/docs/best-practices/payload (my emphasis)
To keep your content compressed well, follow these steps: ... Use consistent quotes for the attributes of HTML tags, i.e. always a single quote, always a double quote, or no quotation at all , if possible.
No, both are the same ..
In HTML 5, quotation marks around attributes are simply optional. (if there are no spaces or special characters in the value)
But I think it's better to quote them.
The syntax of a value without quotesThe name of the attribute, followed by zero or more spaces, followed by one character U + 003D EQUALS SIGN, followed by zero or more spaces, followed by the value of the attribute, which, in addition to the requirements given above for attribute values, is not must contain letter spaces, any characters U + 0022 QUOTATION MARK ("), characters U + 0027 APOSTROPHE ('), characters U + 003D EQUALS SIGN (=), characters U + 003C LESS-THAN SIGN (& lt;), U + 003E BIG CHARGE characters (>) or U + 0060 GRAVE ACCENT characters ('), and should not be an empty string.- W3 HTML5 Specification - sec 8.1.2.3. Attributes
The name of the attribute, followed by zero or more spaces, followed by one character U + 003D EQUALS SIGN, followed by zero or more spaces, followed by the value of the attribute, which, in addition to the requirements given above for attribute values, is not must contain letter spaces, any characters U + 0022 QUOTATION MARK ("), characters U + 0027 APOSTROPHE ('), characters U + 003D EQUALS SIGN (=), characters U + 003C LESS-THAN SIGN (& lt;), U + 003E BIG CHARGE characters (>) or U + 0060 GRAVE ACCENT characters ('), and should not be an empty string.
- W3 HTML5 Specification - sec 8.1.2.3. Attributes
There is a big difference. Most browsers will see the absence of quotes and automatically insert them. If you looked at the element, you would see it. Always put quotes around values ββfor non-smart browsers
Source: https://habr.com/ru/post/1441897/More articles:Parsing YYYY-MM-DD dates strictly on Linux - linuxDelphi - Hide console window - delphiCreating a new table from two existing tables with the possibility of each combination - sqlHow to hide the console window? - delphiC # .net winforms DataGridView footer - c #Rapid device testing << in C ++ - c ++How to WebBrowser.Navigate () from BackgroundWorker? - c #Building a custom expression tree in Spirit: Qi (without Utree or Boost :: Variant) - c ++is there any advantage to using int instead of float without decimal numbers? - floating-pointHow to add qi :: characters in the grammar? - c ++All Articles