Setting input control focus without javascript [duplicate] - html

This question already has answers here:
Default html form focus without JavaScript
(5 answers)
Closed 8 years ago.
Is there a way to set the focus in a specific HTML input (a textarea control, actually), without using Javascript?
EDIT: Is possible in HTML5 but the question is about HTML < 5

You can use autofocus in HTML5 documents, but it has little support at present (see chart).

Nope. Sadly JavaScript is required, because it's dynamically modifying the browser on the client-side (what JavaScript was made for).

I don't know of any, other than tabbing to the field or clicking within it.

It depends on how and when you want to set the focus on this textarea. "tabindex" might help you.

Related

Can a textarea belong to multiple forms? [duplicate]

This question already has an answer here:
Multiple form ID's in HTML5's input form attribute
(1 answer)
Closed 8 years ago.
I have a textarea similar to
<textarea name="mytextarea" form="form1 form2"></textarea>
When inspecting the element and viewing node attributes, it shows the form as null. This is in chrome.
Inputs can have multiple form attributes, but can textareas?
It's different from the other question because it pertains to text areas, not other inputs. Though, the result may ultimately be the same.
I received my initial apparently incorrect information from this:
http://www.w3schools.com/tags/tag_textarea.asp
See form on that page. Either way. This can stay closed. It is obviously not implemented in the browsers or ever specified in the spec.
Thanks all.
As this answer states, nowhere on the W3C Spec is stated that the form owner of an element can be a list of IDs. If for some reason, that is working for you, you're still not conforming to standards.
I suggest using jQuery if you want to submit multiple forms at the same time, or duplicate the value of input elements across different forms on submission.

Disable <a> click without the help of jQuery/Javascript [duplicate]

This question already has answers here:
How to disable a link using only CSS
(25 answers)
Closed 8 years ago.
Is there anyway to inhibit the click handler on a tags in HTML without the help of jQuery/Javascript?
disabled only works on button and input, but I've chosen to use a tags in my code. I suppose I can use span and simulate the exact a styles I currently have, but it would be nice if there's a simple way around this.
Thanks in advance.
Use # as href or omit the href. The link won't work anymore. As cocco noted, setting href to # has the disadvantage, that the history gets messed up and the browser jumps back to the top of the page. Nevertheless, the value # has been used on numerous pages.
Disabling the onClick is not possible, but you can use onclick="return false". This way nothing happens on click.
There is also a partial solution using css (described in this already answered question).
there are many ways to do that..
1.simplest:
a.onclick=function(){
return false
}
2.standard/modern:
a.addEventListener('click',function(e){
e.preventDefault()
},false)
example with class=active to activate the link.
http://jsfiddle.net/y7vVq/
onclick="return false"
This is the simple way to disable click in a tag

Make new HTML tag which acts like an exist tag with extras [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Custom html tags — Is there a better way?
I using finding myself very frequently writing: <pre class="cpp">, when using highlight.js. Just out of interest, is there any way I could make a new tag, say <pcpp>, which would act exactly like <pre class="cpp">, just using CSS?
I can imagine this would be possible with JavaScript, but I would not want to start changing all my tags every time the page is loaded.
No, but if you are using JavaScript anyways then you can apply the cpp class to all <pre> elements if you're finding that you're applying that class to every <pre> element on the page:
// Using jQuery
$('pre').addClass('cpp');
Making a new element would probably cause major issues with the page, much more trouble than it's worth, and it wouldn't validate as HTML anymore.
No you are not supposed to create new tag in HTML

Is there a way to prevent browser autofill an input box? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
How do you disable browser Autocomplete on web form field / input tag?
Is there a W3C valid way to disable autocomplete in a HTML form?
My browser automatically fills the register form in my website, which is supposed to be anonymous so it's not a very good sign to users to see their names already on the form.
Is there a way to prevent this from happening?
I could take the input box and simply erase it with javascript but I wanted to know if there was another way round. Thanks
<input type="text" autocomplete="off" />
That should work.

Adding custom attributes in html tags [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Custom attributes - Yea or nay?
Can any side effect occur in browsers if I add custom attributes to html tags for instance:
No side effects that I know if, they just won't validate and it's possible that in the future whatever attribute name you choose may conflict if browsers decide to implement one with the same name (Unlikely if you name it something unique enough)
Read more here: Custom attributes - Yea or nay?
This is fine, except that if you try to validate your markup, this will cause it to fail.
Otherwise, from a browser perspective there shouldn't be a problem.
Everyone will be kind to you (JavaScript, CSS, HTML) but your page will not validate.
If you decide to use custom attributes, prefix them with data- to make them forward compatible with HTML5 (and to not use a possible reserved attribute in the future).
click?