1

The CSS content attribute allows me to modify the content of an element. Is it possible to modify an element such that its contents would be posted as part of a form, using pure CSS?

Example of what I want to do:

<style type="text/css">
    #sneaky:before {
        content: "Testing, testing!";
    }
</style>
...
<form action="foo.php" action="POST">
    <textarea name="data" id="sneaky"></textarea>
    <input type="submit" value="Send" />
</form>

According to several questions on this site, there's no way to use :before and :after on input elements, but one comment did mention that textarea seems to behave specially.

Is there any way to modify form variables (via any element vector) using only CSS?

Note: This doesn't have to be particularly cross-browser compatible, or reliable. I'm researching how different browsers behave and the tricks that each can be subjected to.

Community
  • 1
  • 1
Polynomial
  • 27,674
  • 12
  • 80
  • 107

1 Answers1

1

No, it's not possible since :after and :before create pseudo elements that don't alter input and textarea values in any way (and they're neither seen in the DOM tree)

Fabrizio Calderan
  • 120,726
  • 26
  • 164
  • 177
  • I understand that it's not possible for `textarea` using `:after` or `:before`, but are there any ways at all to modify form fields directly from CSS, using any element, selector, attribute, etc? – Polynomial Feb 21 '12 at 12:06
  • no. you cannot alter the dom via css. you cannot change attributes or values via css – Fabrizio Calderan Feb 21 '12 at 12:08
  • 1
    no. it doesn't. CSS is meant to style elements. HTML is meant to give strucuture and meaning and JS is meant to add behaviour. Every layer has its own specific purpose. – Fabrizio Calderan Feb 21 '12 at 12:11
  • I understand that, it happens to suck for this particular purpose. – Polynomial Feb 21 '12 at 12:21