This question already has answers here:
Difference between id and name attributes in HTML
(22 answers)
Closed 5 years ago.
Could anybody kindly explain me the difference or logic behind HTML5 id & name attributes of input & other elements.
Should I define both or one is enough?
Which one is required? id or name
Sometimes, both can be used for the same purpose. But,
Normally id attribute is used to call that element. and name attribute is used when you send a data to some other page from a form through post or get method, then we can access to the data of that element through that name.
Related
This question already has answers here:
How to style text of submit button
(3 answers)
Closed 2 years ago.
We can use the tag(superscript tag) to represent something like a^b and e^x in html5. But while using the tag to make a button, we normally use the 'value' attribute to represent what's gonna be on the button something like this:
<input type="button"class="cutedog" value ="x cube">
But we can't really use the sup tag inside the " " because it just prints out the exact thing out something like this: "e(sup)x(/sup)" (I have deliberately put () instead of < and > because stackoverflow does't support this :( )
Anyway can you tell me that how can we put e^x inside "" or is there any way to do this?? Plz help me :))
<button>x<sup>3</sup></button>
This question already has answers here:
Checking multiple contains on one string
(8 answers)
Closed 2 years ago.
I need to write a regex pattern in AWS WAF to find whether my web request's body contains any HTML elements. Can someone please help me to write a regex for this. below are the HTML elements which I need to find and match
<
<
>
&
"
const string = "<p>your html belongs here</p>"
string.match(/(<|<|>| |&|")/g) // this one will return boolean
Note: you should sanitize your string. I mean, you put < to your string instead of <
This question already has answers here:
Regular expression for floating point numbers
(20 answers)
Closed 3 years ago.
I need to have a text input that accepts only numbers and the dot sign for float numbers.
I don't want a number type input.
You can't do this with html only - you'd need to use JavaScript.
e.g. Javascript key board input filtering
There is an <input pattern=""> attribute which can be used for validation, but it does not prevent the input from accepting invalid characters, only prevents them being submitted when the form is validated.
This question already has answers here:
Is it guaranteed that non-numeric attribute values on every web-page HTML are always quoted?
(1 answer)
what are data-* HTML attributes?
(1 answer)
Closed 4 years ago.
In the code I am working on I found this:
<div class="icon icon2 screen-icon" data-screen-idx=1>
What puzzles me is the last "attribute" (or whatever it is )
Is this data-screen-idx-1 legal in html tag?
Please note that 1 is not quoted.
If yes, where can I find info about this.
If not, why would someone write such thing?
Yes, this is valid HTML. They are called "data-attributes" and can be whatever you want, as long as they begin with data-.
See this article for more information. MDN - Using data attributes
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What are valid values for the id attribute in HTML?
valid value for name attribute in html
It is valid to name a HTML5 input with a string containing a period?
<input type="text" name="article.title" value="The title"/>
Yes, it's valid.
But you will make things difficult for yourself if you need to access them via JS or CSS in particular. Again, it can be done, but it will make things difficult.
My advice is to use a hyphen instead.
It is valid according to this part of the HTML5 spec.
The name content attribute gives the name of the form control, as used in form submission and in the form element's elements object. If the attribute is specified, its value must not be the empty string.
Any non-empty value for name is allowed, but the names "charset" and "isindex" are special:
emphasis mine
"Attribute values can contain text and character references, with additional restrictions depending on whether they are unquoted attribute values, single-quoted attribute values, or double-quoted attribute values. Also, the HTML elements section of this reference describes further restrictions on the allowed values of particular attributes, and attributes must have values that conform to those restrictions."
from w3.org (W3C Working Draft):
HTML Syntax - HTML5