[제나플러스] Inputs vs Buttons > 팁앤테크

본문 바로가기
사이트 내 전체검색

팁앤테크

[제나플러스] Inputs vs Buttons

페이지 정보

본문

Inputs vs Buttons

So, here’s your standard submit button markup:

<input type="submit" value="Submit" />

And it looks like this across the three brothers:

Input Submits

Meh. Here’s the markup used when creating a button element that submits:

<button type="submit">Submit</button>

And it looks like this :

Buttons

These buttons work and behave in exactly the same way as our counterparts above. In addition to submitting the form, you can make them disabled, add an accesskey or even specify a tabindex. Aside from the visual indifference Safari seems to have for them (it doesn’t put that forced aqua interface on it, which we’ll be able to use to our advantage), the coolest thing about the <button> tag is that you can put useful HTML elements inside them, like images:

<button type="submit"><img src="" alt="" /> Submit</button>

Which looks like this :

Buttons with Images

Nice. (Okay, they’re a little fugly, but I said they’re in need of a little love.) In fact, according to the W3C these special visual differences is exactly why the <button> elements were created.

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.

The Button Element - W3C

And so here we were looking for a design solution and here our friends writing the giant handbook of the Internet had a piece of markup meant to help us with just such a problem. Convenient, yet unfortunate that most designers and developers don’t even know the element exists. Now, before I made the jump to replace all the image inputs in Wufoo with button elements, I decided that the markup and CSS would have to fulfill a couple of requirements.

The Requirements

  1. They had to look like buttons.

  2. They had to look the same across browsers.

  3. The styles I used for button needed to also be used with ones I might use with links (since interaction in Wufoo is always initiated with either a Form Submission or an Ajax Call from a link, these things probably sit next to each other and I needed them to have the same visual weight).

  4. The markup needed to be flexible and easy to change for uses in lots of different situations.

  5. I should be able to use icons and colors effectively to pass information about the kind of interaction that would be taking place.

With those challenges in place, I dove into the CSS and after solving some cross browser challenges, came up with the following (which you can also see all over Wufoo):

The Results


Nothing crazy. Simple, but effective. Now, what I love about this way of handling buttons is that I can use the 1000 icon arsenal from FAMFAMFAM to illustrate a ridiculous number of ideas and actions without having to generate something from Photoshop every single time I need something new. If we take a quick look at the markup, you’ll notice that the last two buttons up there are actually links:

<div class="buttons">
<button type="submit" class="positive">
<img src="/images/icons/tick.png" alt=""/>
Save
</button>

<a href="/password/reset/">
<img src="/images/icons/textfield_key.png" alt=""/>
Change Password
</a>

<a href="#" class="negative">
<img src="/images/icons/cross.png" alt=""/>
Cancel
</a>
</div>

The reason this is useful is because lots of actions in web applications are REST driven and so simply sending a user via a link to a specific URL will initiate something they need to do. Using styles that can work for both types of elements (links and buttons), gives us the flexibility to keep our means of interaction looking consistent and appropriate whether it’s being done with Ajax or a standard submission.

Just a quick aside, you may wonder why I’ve left the alt tags blank in those icon images. It may come as a surprise to some that while alt attributes are required on every image, actually describing them is not. Empty alt attributes are completely valid and help screenreaders know which information to effectively ignore, saving your users precious time when they’re trying to find the next appropriate actionable item. Because the icons are actually superfluous, I’d rather not waste the user’s time hearing about the image I used to visualize what’s going on. They’ll just hear “Submit” rather than “Checkmark Submit”, which would actually make things a little confusing.

추천0

댓글목록

등록된 댓글이 없습니다.

Total 285건 2 페이지
  • RSS
팁앤테크 목록
번호 제목 글쓴이 조회 추천 날짜
260 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 25331 0 04-20
259 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 25013 0 05-29
258 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 24580 0 09-18
257 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 24578 0 09-18
256 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 24461 0 10-19
255 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 24459 0 02-08
254 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 24133 0 09-02
열람중 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 23979 0 04-22
252 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 23915 0 05-02
251 포인트쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 23733 0 04-13
250 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 23606 1 05-10
249 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 23456 0 09-29
248 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 23371 0 12-10
247 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 23280 0 02-22
246 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 23173 0 03-25
245 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 22743 0 04-30
244 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 22617 0 05-26
243 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 22611 0 12-06
242 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 22349 0 11-28
241 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 22264 0 04-25
240 월드컵쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 21994 0 03-31
239 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 21931 0 04-10
238 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 21903 0 11-28
237 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 21838 0 04-24
236 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 21835 0 05-19

검색

회원로그인

회원가입

사이트 정보

株式会社YHPLUS / 대표 : ZERO
〒140-0011 東京都品川区東大井2-5-9-203
050-5539-7787
오픈카카오톡 (YHPLUS) :
https://open.kakao.com/o/slfDj15d

접속자집계

오늘
3,139
어제
5,045
최대
9,679
전체
2,617,517
Copyright (c) 株式会社YHPLUS. All rights reserved.