How to style a button on disabled state using inline CSS only - html

I have a button and I want to style it when disabled using inline style only.
I know how to style using internal/external style.
Code below:
<input type="submit" value="Submit" disabled="disabled" />

Other than by explicitly changing the style with JavaScript (which violates your "inline CSS only" constraint): you can't.
The style attribute only contains the body of a rule-set. It can't do anything that you need a selector for.

Related

How do I target any CSS property using multiple radio buttons? To assign diff- values to the CSS property when different Radio btn are checked

I want to assign different values to a CSS property for some other element when different radio buttons are checked.
`<input type="radio" name="for-image" id="img-1">
<input type="radio" name="for-image" id="img-2">
<input type="radio" name="for-image" id="img-3">`
You need to use CSS selectors for that. With CSS selectors you can target elements like so: div:first-of-type or div:nth-of-type(3).
You may also need to use the :checked selector to trigger styles for when a checkbox is selected. CSS selectors can be combined too!
To see how they work and which CSS selectors are there for you to use, please read this link: W3Schools CSS Selectors

What is the difference between <button type="submit"> and <input type="submit"> in HTML [duplicate]

This question already has answers here:
Difference between <input type='button' /> and <input type='submit' />
(4 answers)
Closed 1 year ago.
input type="submit" and button tag are they interchangeable? or if there is any difference then When to use input type="submit" and when button ?
And if there is no difference then why we have 2 tags for same purpose?
http://www.w3.org/TR/html4/interact/forms.html#h-17.5
Buttons created with the BUTTON element function just like buttons created with the INPUT element, but they offer richer rendering possibilities: the BUTTON element may have content. For example, a BUTTON element that contains an image functions like and may resemble an INPUT element whose type is set to "image", but the BUTTON element type allows content.
So for functionality only they're interchangeable!
(Don't forget, type="submit" is the default with button, so leave it off!)
The <input type="button" /> is just a button and won't do anything by itself.
The <input type="submit" />, when inside a form element, will submit the form when clicked.
Another useful 'special' button is the <input type="reset" /> that will clear the form.
Although both elements deliver functionally the same result *, I strongly recommend you use <button>:
Far more explicit and readable. input suggests that the control is editable, or can be edited by the user; button is far more explicit in terms of the purpose it serves
Easier to style in CSS; as mentioned above, FIrefox and IE have quirks in which input[type="submit"] do not display correctly in some cases
Predictable requests: IE has verying behaviours when values are submitted in the POST/GET request to the server
Markup-friendly; you can nest items, for example, icons, inside the button.
HTML5, forward-thinking; as developers, it is our responsibility to adopt to the new spec once it is officialized. HTML5, as of right now, has been official for over one year now, and has been shown in many cases to boost SEO.
* With the exception of <button type="button"> which by default has no specified behaviour.
In summary, I highly discourage use of <input type="submit"/>.
Use <button> tag instead of <input type="button"..>. It is the advised practice in bootstrap 3.
http://getbootstrap.com/css/#buttons-tags
"Cross-browser rendering
As a best practice, we highly recommend using the <button> element
whenever possible to ensure matching cross-browser rendering.
Among other things, there's a Firefox bug that prevents us from
setting the line-height of <input>-based buttons, causing them to not
exactly match the height of other buttons on Firefox."
<input type='submit' /> doesn't support HTML inside of it, since it's a single self-closing tag. <button>, on the other hand, supports HTML, images, etc. inside because it's a tag pair: <button><img src='myimage.gif' /></button>. <button> is also more flexible when it comes to CSS styling.
The disadvantage of <button> is that it's not fully supported by older browsers. IE6/7, for example, don't display it correctly.
Unless you have some specific reason, it's probably best to stick to <input type='submit' />.
I realize this is an old question but I found this on mozilla.org and think it applies.
A button can be of three types: submit, reset, or button. A click on a
submit button sends the form's data to the web page defined by the
action attribute of the element. A click on a reset button
resets all the form widgets to their default value immediately. From a
UX point of view, this is considered bad practice. A click on a button
button does... nothing! That sounds silly, but it's amazingly useful
to build custom buttons with JavaScript.
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/My_first_HTML_form#And_a_<button>_to_finish
<button> is newer than <input type="submit">, is more semantic, easy to stylize and support HTML inside of it.
While the other answers are great and answer the question there is one thing to consider when using input type="submit" and button. With an input type="submit" you cannot use a CSS pseudo element on the input but you can for a button!
This is one reason to use a button element over an input when it comes to styling.
I don't know if this is a bug or a feature, but there is very important (for some cases at least) difference I found: <input type="submit"> creates key value pair in your request and <button type="submit"> doesn't. Tested in Chrome and Safari.
So when you have multiple submit buttons in your form and want to know which one was clicked - do not use button, use input type="submit" instead.
If you are talking about <input type=button>, it won't automatically submit the form
if you are talking about the <button> tag, that's newer and doesn't automatically submit in all browsers.
Bottom line, if you want the form to submit on click in all browsers, use <input type="submit">

Can a checkbox be checked by default in the stylesheet, rather than in an HTML attribute?

Like the title says: can a checkbox be checked by default in the stylesheet, rather than in an inline HTML attribute?
Example from w3schools.com, the "car" box is checked:
<form action="demo_form.asp">
<input type="checkbox" name="vehicle" value="Bike"> I have a bike<br>
<input type="checkbox" name="vehicle" value="Car" checked> I have a car<br>
<input type="submit" value="Submit">
</form>
I'm making an "I agree to the Terms and Conditions" checkbox, and due to the clunky website I'm making this on, I can't create inline CSS. Instead, I can assign this field a css class, and edit the class in the larger stylesheet.
If it makes it easier, this will be the only checkbox on the page.
A checkbox cannot be checked in CSS, unfortunately. It relies on the checked attribute of the input element, and attributes cannot be modified via CSS.
Alternatively, you could look into a JavaScript solution, but of course the best way would be to edit the HTML directly.
First of all, this is not a css but a html element's attribute.
Another way to check it is with javascript, and with css you can only select it like this:
input[type=checkbox]:checked /* select checked checkbox */
input[type=checkbox] /* select any checkbox */

css for html attribute

In my site I have this code (Wordpress / Woocommerce Cart page):
<input type="submit" class="button" name="update_cart" value="Update Cart">
I want to add an update icon after the text "Update Cart" On other pages was it fairly simple using a :after pseudo element.
I don't know what I'm missing but I can't get it to work with the mark-up above.
For instance I have tried
input[name="update_cart"]::after {
etc.
}
and
.button[name="update_cart"]::after {
etc.
}
This did not work.
Please advice.
There is the following note in CSS 2.1: “Note. This specification does not fully define the interaction of :before and :after with replaced elements (such as IMG in HTML). This will be defined in more detail in a future specification.” This has not happened so far, and browsers simply don’t implement those pseudo-elements at all for elements like input. But they do implement them for button.
So if you can change the markup, you can append generated content to the button text:
<style>
.button[name="update_cart"]:after {
content: " ⤾";
}
</style>
<input type="submit" class="button" name="update_cart" value="Update Cart">
<p>
<button type="submit" class="button" name="update_cart" value="Update Cart">Update Cart</button>
The example includes an input type=button element too, to illustrate how the button rendering is the same, except that for button, generated content works.
You can't use :after or :before on input or button element.
You can use a span element with a button inside and an :after in the span with icon (probably with a character as content using Font Awsome or Icon Moon).
Don't forget the content inside :after css, the pseudo element will not be visible if this css property isn't properly set.

highlighting the textbox without using javascript or jquery

can we highlight our textbox without using javasript/jquery or css ?if yes then how? i am on jsp page, can jsp help?
You can do it with CSS inline, without using an external stylesheet. If you really must:
<input type="text" style="background-color:#FFFFCC;" />
To change the default style (including color) of an HTML element from the default style that the browser uses, you must apply the style via CSS or JavaScript.
No, that is not possible without CSS (if you want to use things like colors). You can do it without JavaScript, though. This would be the CSS for doing it:
.textbox {
background-color: #FF0000;
}
And the markup:
<textarea class="textbox" rows="10" cols="30"></textarea>