how to write a proper selector for what is inside input box?
I have a form of inputbox and i need to write a good selector. I need to assign attributes only to what is inside inputbox. form looks like this:
<label></lab开发者_高级运维el>
<input type="text" disabled="disabled" name="xxx" size="100" value="abcd" class="yyy" />
however, i have more elements of this class on my page.
what is the best way to go?
As you've added a class "yyy", you can just go ahead and do the following:
<style type="text/css">
.yyy {
font-size: 14px;
font-family: Arial;
color: #FF0000;
}
</style>
You can of course paste that HTML code above and plant it in your HTML document, but it's best practice to keep HTML and CSS away from each other.
So add this code in your head tag:
<link href="some/style.css" type="text/css" rel="stylesheet" />
And inside of style.css:
.yyy {
font-size: 14px;
font-family: Arial;
color: #FF0000;
}
You could use either input.yyy {}
, which will work on all browsers but if you have more than one input element on the page with a class of yyy, it will select all of them.
An alternative is input[name=xxx], using a new CSS3 selector, but this won't work in older browsers, so it depends how important it is that the style works everywhere.
精彩评论