0

I am wondering how to go from html formatted tags to CSS. The Html is

Ball: <input type=text name=BL size=5 value=5>

The CSS I have so far is:

#info input[type=text]{}

My goal would be as little html as possible. Thanks :)

2
  • Ok, what you have is fine. Was there something you actually wanted to do? Because your question certainly doesn't convey any intent. Commented Nov 3, 2011 at 3:10
  • I thought that the input, name, size and value could be set using CSS, and was wondering how, but I realize now they can not. Commented Nov 3, 2011 at 3:25

2 Answers 2

1

Not entirely sure what your goal is, but you can set it up like:

<input type="text" class="inputfield" name="BL" size="5" value="5" />

And control it with CSS:

.inputfield {
    border: 1px solid #000;
    font-family: Tahoma, Verdana, sans-serif;
    color: #ff0000;
    background: #c3c3c3;
    }
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I thought that CSS could be used to to set the type, name, size, and value fields, but this clears it up.
1

The only current attribute on the input you could replace with CSS would be size. You would use the CSS width property instead.

#info input[type=text]{
    width: 30px;
}

<input type="text" name="BL" value="5">

Though size and width are not exactly the same. size="5" will size the input for 5 characters. Width is (usually) measured by pixels, but you can also use other units of measurement (em, %, pt, pc, mm, cm, in).

4 Comments

I thought I'd mention, just in case (Because what you suggested may be misleading), that you can apply far more than size attributes to input elements using css. In this case it's true that only size can be replaced with a style, but inputs are still able to be styled like most html elements as well. Sorry if this was obvious to everyone else, haha. At first I read it as though only size could be used in all cases.
size is number of character slots shown not width in the case of input[type=text]
wait, so width could not replace size?
size can be used in terms of width of characters of the font selected. The benefit (or drawback, depending on how you look at it) is that users who might have overridden the browser's default font size, will be shown a field with a width of XX characters in that size. When width is specified in CSS, this is not always the case. It's a more definitive property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.