Html and css by jon duckett pdf


Jon DuCkeTT permission should be addressed to the Permissions Department , John Wiley & Sons, Inc., River . Many books that teach HTML and CSS. Web Design with HTML and CSS Digital Classroom. Published by. Wiley Publishing How to create Web sites and applications with HTML, CSS Jon Duckett. Jon Duckett HTML and CSS Design and Build . Many books that teach HTML and CSS I've focussed on the code you need to use 90% of the time .

Language:English, Spanish, Portuguese
Genre:Children & Youth
Published (Last):17.02.2016
Distribution:Free* [*Register to download]
Uploaded by: MARANDA

71502 downloads 142192 Views 38.46MB PDF Size Report

Html And Css By Jon Duckett Pdf

I have finished reading Jon Duckett's book called "HTML and CSS". After this book, what are some good textbook choices to continue learning about HTML and. The simpler way to learn HTML and CSS, in a beautifully presented, full-color book. Download: JPG (kb) | PDF (mb) Jon Duckett is a digital creative director who has written over a dozen books on web design and programming. HTML and CSS: Design and Build Websites by Jon Duckett. Read online, or download in secure PDF format.

Skip to main content. Log In Sign Up. The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. Further, readers should be aware that Internet websites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at , outside the United States at or fax

Sie sind bereits eingeloggt. Klicken Sie auf 2. Alle Produkte. He has worked with small startups and global brands, and has written more than a dozen books on web design, programming, usability, and accessibility.

Introduction 2 Chapter 1: Structure 12 Chapter 2: Text 40 Chapter 3: Lists 62 Chapter 4: Links 74 Chapter 5: Images 94 Chapter 6: Tables Chapter 7: Forms Chapter 8: Extra Markup Chapter 9: Introducing CSS Chapter Color Chapter So, some people give validate forms.

HTML5 introduces new form controls to standardize the way that some information is gathered. This will create a date input in browsers that support the new HMTL5 input types. This example shows what the date input looks like in the Opera browser. The appearance of the date input changes across different browsers. Browsers that support HTML5 validation will check that the user has provided information in the correct format of an email address. Some smart phones also optimize their keyboard to display the keys you are most likely to need when entering a URL.

Older browsers will simply treat it like a single line text box. R E S U LT placeholder On any text input, you can also use an attribute called placeholder whose value is text that will be shown in the text box until the user clicks in that area. Older browsers simply ignore this attribute. It uses a variety of form controls.

Different types of form control are suited to collecting different types of data. X Each form control is given a name, and the text the user types in or the values of the options they select are sent to the server. X HTML5 introduces new form elements which make it easier for visitors to fill in forms.

In this chapter, we will focus on some helpful topics that are not easily grouped together.

Its purpose last with new elements and which have been highlighted , was to allow people to write attributes added and older code the elements you have seen in new markup languages. Since removed. This meant that web users, however, have the authors are not recommended to authors had to follow some new, latest browsers installed on use them any more.

XHTML was created because not need to close all tags, and it allowed authors to continue new elements and attributes will One of the key benefits of this to follow older practices with a be introduced. At the time of change was that XHTML works less strict syntax and use some writing, the HTML5 specification seamlessly with other programs of the elements and attributes had not been completed, but that are written to create and that were going to be removed the major browser makers had process XML documents.

Vector Graphics SVG — a 1. These days, frames are very long as you endeavour to ensure rarely used and are being phased that users with older browsers In order to help web page out. There must be nothing before it, not even a space.

R E S U LT Although comments are not visible to users in the main browser window, they can be viewed by anyone who looks at the source code behind the page. On a long page you will often see comments used to indicate where sections of the page start or end, and to pass on notes to help anyone who is looking at the code understand it.

Comments can also be used around blocks of code to stop that code from being displayed in the browser. In the example on the left, the email link has been commented out. So very commonplace are these from other elements on the substances, they hardly attract attention - and page. Its value should start with yet they vouchsafe our very existence. As you will see when you come to look at CSS in the next R E S U LT section, giving an element a unique identity allows you to style it differently than any other instance of the same element on the page.

For example, you might want to assign one paragraph within the page perhaps a paragraph containing a pull quote a different style than all of the other paragraphs. In the example on the right, the paragraph with the id attribute whose value is pullquote is made uppercase using CSS. If you go on to learn about JavaScript a language that allows you to add interactivity to your pages , id attributes can be used to allow the script to work with that particular element.

The id attribute is known as a global attribute because it can be used on any element. To do this you can use the class attribute. Its value should describe the class it belongs to. In the example on the left, key paragraphs have a class attribute whose value is important. The class attribute on any element can share the same value. So, in this example, the value of important could be used on headings and links, too. By default, using these attributes In this example, CSS has been If you would like to indicate that does not affect the presentation applied to make elements with an element belongs to several of an element.

It will only change a class attribute whose value classes, you can separate class their appearance if there is a CSS is important uppercase, and names with a space, as you can rule that indicates it should be elements with a class attribute see in the third paragraph in the displayed differently. It is used to either: Contain a section of text where there is no other suitable element to differentiate it from its surrounding text 2. The content of the iframe can be any html page either located on the same server or anywhere else on the web.

There are a few attributes that you will need to know to use it: It can take one of three values: A value of 0 indicates that no border should be shown. A value of 1 indicates that a border should be shown. The seamless attribute like some other new HTML5 attributes does not need a value, but you will often see authors give it a value of seamless.

Older browsers do not support the seamless attribute. Some defined values for this web page. It is not visible to users but fulfills a number of purposes such as telling search engines description This contains a description about your page, who created of the page. This description it, and whether or not it is time is commonly used by search sensitive. If the page is time engines to understand what the sensitive, it can be set to expire.

It uses attributes to carry the information. These attributes In practice, this no longer has specify properties of the entire any noticeable effect on how page. The value of the name search engines index your site. A value of noindex can be used if In the first line of the example on this page should not be added.

The content attribute is where this description is actually specified. Note that the date must be specified in the format shown. For example, the left and right angled brackets. Therefore, if you want these There are also special codes When using escape characters, characters to appear on your that can be used to show it is important to check the page you need to use what are symbols such as copyright and page in your browser to ensure termed "escape" characters trademark, currency symbols, that the correct symbol shows also known as escape codes or mathematical characters, and up.

This is because some fonts entity references. For example, some punctuation marks. In the to identify their purpose. X The id and class attributes allow you to identify particular elements. This chapter begins by looking at how to use it in your web pages. Whether you are creating an When you create a Flash file in To view Flash, browsers need animation or a media player in the Flash authoring environment, to use a plugin an extra piece Flash, the files you put on your it is saved with the.

In order to use this file browser called the Flash Player. It has the. Flash plugin installed. The download the Flash authoring percentage of mobiles and environment from Adobe. When you export the movie tablets with it is much less. However, now it is more this chapter will show you how downloading this tool. The Flash authoring environment The. When Flash was first released, There are several reasons why There have been laws introduced it was developed to create fewer websites are using Flash to ensure that websites are animations.

The technology these days, including: At the time of when they use it and now rarely writing, Flash is still a popular consider building an entire When Apple launched the way of playing video and audio website in Flash. Despite this, Flash does have a decision not to support Flash.

Here you can see some of the changes in how animation, video, and audio are created on the web. If it can, the achieve two further benefits: The text can be accessed by by the SWFObject script. Flash movie, you could show a interact with the Flash file. The text can be indexed by can place the alternative content a text description of the Flash search engines which are not as for users who are not able to file.

The src attribute tells the browser where to find the script. This element is actually telling the SWFObject script five pieces of information, which are in the brackets: The location of the. The width of the Flash movie: The height of the Flash movie: The minimum version of the Flash player needed to view the movie: Online, there For this reason, browsers built service such as YouTube or are even more video formats prior to generally required Vimeo. This a video into another format browser that supports this means you would need to upload is sometimes referred to as new HTML5 element and the any videos you want to show in "encoding" the video.

There are several apps available video to be encoded in different on the web that enable you to formats. You do not need to worry about you need to host the video on encoding your video since your own server and add your We will be looking at two these sites allow you to upload own player into the page.

Once uploaded, they Some services will limit what Flash Video and the HTML5 automatically convert your video your video is allowed to include.

Therefore, it can Some hosted services will play cost you extra to host the videos their own adverts before your on your own site. If your video video will begin, or even overlay is hosted on a site like YouTube them over the screen as your or Vimeo, however, you do not video is playing. The quality of need to pay for the bandwidth.

Its your page using a JavaScript format. Here are two sites this chapter. You will also need to tell the Some Flash video players www.

H and some video editing Some players have advanced programs export video in this You do not need the Flash features such as the ability format. This is included in the on pages It only supports the FLV format not H It is very similar to the one you saw in the earlier example that introduced SWFObject. Different video players usually require information such as the path to the video in slightly different formats, but they usually come with examples and documentation to help you understand how to use them.

Here are some of the key issues to be aware of: Therefore, controls for the player, and recent browsers, so you cannot you need to supply your video in these can vary from browser just use this one technique if you more than one format.

You can control the want everyone to be able to see appearance of these controls your video you need to combine To reach as many browsers as using JavaScript but that is this HTML5 with Flash Video. But a dedicated a format called WebM. Some scaled up or down. On page you will see how I have provided a sample video in If you look at this example in to combine this HTML5 video H and WebM format for you Firefox and Opera you will see technique with Flash Video to to try with the code downloads.

If the attribute is none should supply its own controls present, it turns that option on.

Html & Css by Jon Duckett - PDF Drive

The browser should not load for playback. If the attribute is omitted, the the video until the user presses option is turned off. The browser should just collect indicates that the video should information such as the size, start playing again once it has first frame, track list, and ended. Otherwise, it will download some of the video to see if it can play the file which will take time and bandwidth. Or you may work you would only need to provide the other way around.

You would not need of the video for browsers it in FLV format as well. You that have different sized will see this demonstrated in screens so you can provide lower resolution content for the example at the end of the handheld devices chapter.

As with video, there are three routes commonly taken: Browsers that provide a player which you can from simple buttons that play support this element provide embed in your page, such as one track to complex players their own controls — much as SoundCloud.

Some people ask how to get This is actually quite difficult This is why some sites offer music to play consistently even to achieve and would rely on audio players in new windows, when visitors move from one techniques like using AJAX to so that listeners are not page to another on a website. If you do not use this attribute, no controls will be shown by default. You can also specify your own controls using JavaScript. It is not set to autoplay. It can have Vorbis audio format Firefox, considered better practice to let the same values we saw on page Chrome, and Opera.

For it to visitors choose to play audio. Firefox 3. The video has been encoded in H and WebM formats to reach as many browsers as possible. If the browser does not support HTML5 video or Flash, then a plain text message will be shown to the user. X Flash is not supported on iPhone or iPad. CSS allows you to create rules that specify how the content of an element should appear. For example, you can specify that the background of the page is cream, all paragraphs should appear in gray using the Arial typeface, or that all level one headings should be in a blue, italic, Times typeface.

Once you have learned how to write a CSS rule, learning CSS mostly involves learning the different properties you can use. So this chapter will: On this page, you can see a basic HTML page.

On the right hand page, you can see the same HTML page, but I have added outlines to each of the elements so that you can see how CSS will treat each element as if it lives inside its own box. In this example, block level elements are shown with red borders, and inline elements have green borders. Using CSS, you could add a border around any of the boxes, specify its width and height, or add a background color. You could also control text inside a box — for example, its color, size, and the typeface used.

Italics, bold, uppercase, and forms. These rules govern how the content of specified elements should be displayed. A CSS rule contains two parts: The same rule can apply to the selector should be styled. You can specify several properties in one declaration, each separated by a semi-colon. Arial; color: For example, color, font, properties.

For example, if you typeface, in a yellow color. This example uses two documents: They are usually described as href early, second early and maincrop. For example, some authors use one CSS file to control the presentation such as fonts and colors and a second to control the layout. They are usually described as an external CSS style sheet. Here is an example a style attribute on most of to that one element. You should that changes the color of the text the elements that appear in the avoid using this attribute in any in a single paragraph red: Here you can see the second i selector takes CSS precedence over the first.

In this color: It early and maincrop potatoes. Arial, Verdana, sans-serif; border properties; they are not color: If padding: When building a website there are several advantages to placing your CSS rules in a separate style sheet.

HTML and CSS (eBook, PDF)

All of your web pages can share Therefore, once the user has the one CSS style sheet, rather the same style sheet. If you want to make a will be easier to read and edit your site to link to the same CSS change to how your site appears, because it does not have lots of document.

This means that the you only need to edit the one CSS rules in the same document. For example, practice to have the content of results in less code and smaller you can change the style of the site separated from the rules HTML pages. Again, than a separate document. This consider it better practice to most authors consider it better is simply to save you opening keep the CSS in a separate file.

Work on CSS3 has been ongoing but the major browsers have already started to implement it. In the same way that there have Browsers did not implement all This is mentioned when it is been several versions of HTML, CSS features at once, so some likely to affect you, along with there have also been different older browsers do not support notes where CSS properties versions of CSS.

But finding and squashing those bugs is easy when you know how Before launching any new site, Using these tools, it is a good Some common browser bugs are it is important to test it in more idea to check the site on discussed in this book, but there than one browser, because there different operating systems PC, are many smaller bugs that only can be slight differences in how Mac, and Linux and in older occur in rare situations, or on old browsers display the pages.

You do not need lots of If you come across a CSS bug, computers to test your site, as When you look at your site in you can use your favorite search there are online tools to show more than one browser, you engine to try and find a solution. X Rules are made up of selectors that specify the elements the rule applies to and declarations that indicate what these elements should look like.

X Different types of selectors allow you to target your rules at different elements. X Declarations are made up of two parts: For example, the font-family property sets the choice of font, and the value arial specifies Arial as the preferred typeface.

In this chapter we will look at: DarkCyan We look at these three different ways of specifying colors on the next double-page spread. Anything long document into sections. RGB values, hex codes, and color names covered on the next page. We have also used the padding property to separate the text from the edges of the boxes. This makes it easier to read and you will learn more about this property on page To find the color you want, you can use a color picker.

Computer monitors are made up of thousands of tiny squares called pixels if you look very closely at your monitor you should be able to see them. When the screen is not turned on, it's black because it's not emitting any light. When it's on, each pixel can be a different color, creating a picture.

The color of every pixel on the screen is expressed in terms of a mix of red, green, and blue — just like on a television screen.

The hex value is provided next to the pound or hash symbol. There is also a good color picking tool at: However, between 0 and The of the green is color is MediumAquaMarine.

Technically speaking of gray in a color. At maximum to how much black is in a color. At minimum would be no black in the color. A lack of contrast is particularly If you want people to read a lot You can reduce contrast by a problem for those with of text on your page, however, using dark gray text on a white visual impairments and color then too much contrast can background or an off-white text blindness.

It also affects those with poor monitors and sunlight on their If text is reversed out a light color on a dark background , you screens which is increasingly can increase the height between lines and the weight of the font common as people use handheld to make it easier to read. To check contrast there is a handy online tool at: This value is known as an alpha value and is a number between 0. The rgba value will only affect the element on which it is applied not child elements.

Because some browsers will not recognize RGBA colors, you can offer a fallback so that they display a solid color. To create the fallback, you can specify a color as a hex code, color name or RGB value, followed by the rule that specifies an RGBA value. If the browser understands RGBA colors it will use that rule. If it doesn't, it will use the RGB value. At the time of writing, the opacity and rgba properties are only supported by the most recent browsers.

In HSL colors, hue is often gray in a color. Saturation is white lightness or black represented as a color circle represented as a percentage. Lightness is sometimes referred to as luminosity. Please note that lightness is a different concept to brightness. Graphic design software such as Photoshop and GIMP have color pickers that use hue, saturation, and brightness — but brightness only adds black, whereas lightness offers both white and black. C8C8C8; The value of the property starts background-color: The hsla color property allows you to specify color properties using hue, saturation, and lightness as above, and adds a fourth value which represents Because older browsers do not This provides a fallback because transparency just like the rgba recognize HSL and HSLA values, if there are two rules that apply property.

The a stands for: This means that if the This is expressed as a color name. This should appear browser understands HSL and number between 0 and 1. Both use color names. The first provides a fallback color using a hex code and the second is an HSLA value for browsers that support this method. Each paragraph is then shown in a different color to represent the varying levels of acidity or alkalinity, and these are specified using RGB values.

The example also uses a property called margin to decrease the gap between the paragraph boxes, and a property called padding to create a gap between the edge of the boxes and the text within them. These properties are covered on pages X There are three ways to specify colors in CSS: RGB values, hex codes, and color names.

X Color pickers can help you find the color you want. X It is important to ensure that there is enough contrast between any text and the background color otherwise people will not be able to read your content. It is known as RGBA. It is known as HSLA. As we look through these properties I will also give you some design tips on how to display your type. These details are have a much cleaner design.

Non-monospace fonts known as serifs. So, if the text is small, used for code because they align passages of text because they sans-serif fonts can be clearer nicely, making the text easier to were considered easier to read. Oblique versions of the font, letters are the amount of white space and font styles take the normal style thinner and closer together.

In expanded versions they are thicker and further apart. Times Verdana Times New Roman Helvetica As a result, sites often use a small set of typefaces that are installed on most computers shown above. There are some techniques to get around this limitation which are covered on pages It is possible to specify more than one typeface and create an order of preference in case the user does not have your first choice of typeface installed.

This is sometimes referred to as a font stack. They're not different widths. For this reason, it is common to add the generic font name after your preferred choice of typefaces. For example, if you wanted serif type, you could write the following: However, typefaces are subject to copyright, so the techniques you can choose from are limited by their respective licenses.

CSS is used to be downloaded from if it is not access to a wider range of fonts specify the typeface. LICenSInG You are not distributing the The license to use the font must The service takes care of the typeface, so there is no licensing permit its distribution using licensing issues with the people issue. But if you design on a PC, then it should look fine on a Mac. It uses JavaScript to to appear in a different typeface. Also, users cannot what is said.

LICenSInG You can use any typeface that Many commercial makers of As with sIFR, some typeface you have a license to use on your typefaces allow this technique, makers allow use of their fonts computer because you are not although you may need to pay with CUFON, but you need to distributing the typeface. Designers suggest pages usually look better if they use no more than three typefaces on a page.

We will be using an extended version of the HTML shown on this page for all of the examples in this chapter. There are several ways to font-family: Arial, Verdana, sans-serif; specify the size of a font. The font-size: We will look at these measurements in greater detail on the next page. So if you 9pt was developed by European use percentages or ems, you 10pt typographers in the sixteenth calculate the size of text you 11pt century.

When you first see body text at Print designers often refer to the 16 pixels, it might seem quite size of text in terms of points large. Once you get used to 72pt rather than pixels hence the the larger type, however, most use of pt in the scale on the people find it far easier to read; right.

Using of text relative to the size of the appears at the size you intended percentages of this amount, you text in the parent element. Since because percentages and ems can create a scale where the the default size of text in web are more likely to vary if a user default text size is 12 pixels, and browsers is 16 pixels, you can has changed the default size of headings are sized in relation use similar rules to those shown text in their browser.

Pixels are relative to the It is possible for users to change Because users can change resolution of the screen, so the the default size of text in their the default size of text in their same type size will look larger web browsers. If they have browser, the fonts could all when a screen has a resolution done this, the fonts will be appear larger or smaller than of x than it would when displayed at the same scale that the designer intended.

The extra p rule above is to help You can also use pt for point Internet Explorer 6 and 7 display sizes instead of px for pixels, but the fonts at the right size. You add the font to your style sheet using the font-face rule, as shown on the right. This specifies the path to the font. In order for this technique www. When looking at fonts on these Google also provides open sites, it is still important to check source fonts.

Rather than adding format the font's license agreement the font-face rule to your own This specifies the format that the because some fonts are only free style sheet, you link to a CSS file font is supplied in.

It's discussed for personal use that is, not for and font files on their servers: This is very Firefox 3. Because the browser needs to minimize this behavior are to download the font file in order delete any unneccesary glyphs 1: There are two values that this. In this example, you can see that the element whose class attribute has a value of credits has been bolded.

You might wonder why there is a normal weight. So it is essentially used as an "off switch. There are three values font-style: In this example, you can see that the credits have been italicized. Italic fonts were traditionally stylized versions of the font based on calligraphy, whereas an oblique version would take the normal version and put it on an angle. It is not unusual for the browser to fail to find an italic version of a typeface, in which case it will use an algorithm to place the normal version of the type on a slant, which means that a lot of italic text online is actually oblique.

In the HTML, the word by in the credits had a lowercase b. If you do utilize the uppercase option, it is worth looking at the letter-spacing property to increase the gap between each letter as shown on page This will help improve readability. In this example, the credits have been underlined. Also, the name of the breed which is a link is not underlined, which it would be by default because it is a link.

This property is commonly used by designers to remove the underlines that browsers place under links. Pages show how to add or remove an underline when a user hovers over a link. In a typeface, the part of line-height: Leading is measured from the bottom of the descender on one line to the top of the ascender on the next.

Increasing the line-height makes the vertical gap between lines of text larger. Increasing the default amount of helps the eye move along the line browser, the value of the line- leading can make text easier to instead of down them.

A good height property is best given in read. The vertical space between starter setting is around 1. Because users can adjust between lines is relative to the space between each word as this the default size of text in their size of text the user has selected. You can text-transform: If your text is R E S U LT in sentence or normal case, increasing or decreasing the kerning can make it harder to read. You can also control the gap between words using the word-spacing property. When you specify a value for these properties, it should be given in ems, and it will be added on top of the default value specified by the font.

If the typeface is bold or you have increased the space between letters, then a larger gap between words can increase readability. When you have several paragraphs of text, it is considered easiest to read if the text is left-aligned.

Justified text looks at the words on each individual line and creates an equal gap between those words. It can look odd if you end up with large gaps between some words and smaller gaps between others. This often happens when your lines are not very wide or when your text contains long words. The values it can take are: The text has been moved far to the left, off the screen. Background images are covered on pages We still want the heading text to be on the page for search engines and those who cannot see the image , but we cannot have it displayed on top of the logo or it will be unreadable.

By pushing it 9, pixels to the left, it is way out of sight but still in the HTML code. The second rule in this example indents the credits 20 pixels to the right. It can also be used color: The fourth value is the color of the drop shadow. The text-shadow property has become very popular but at the time of writing it was not supported in any versions of Internet Explorer currently IE9. Other browser makers introduced it in Firefox 3. They are known as pseudo-elements.

R E S U LT You specify the pseudo-element at the end of the selector, and then specify the declarations as you would normally for any other element. It is worth trying this example in your browser so that you can see how the first-line pseudo- element will only affect the first line of text, even if you resize your browser window and less or more words appear on each line.

CSS introduces both pseudo- A pseudo-class acts like an elements and pseudo-classes. A pseudo-element acts like an In the case of the: In pseudo-class, which you meet the case of the: Similarly, extra element around the first the: They are commonly used to control colors of the links and also whether they are to appear underlined or not.

On the left, you can see that visited links are shown in a different color to help visitors know what they have already seen. Often, the: It color: Sometimes this is used to make a button or link feel more like it is being pressed by changing the style or position of the element slightly.

Focus occurs when a browser possible to use the tab key on: Any element that page. For example, when your When pseudo-classes are you can interact with, such as a cursor is in a form input ready used, they should appear in this link you can click on or any form to accept typing, that element order: It is also: There are also a set of attribute selectors that allow you to create rules that apply to elements that have an attribute with a specific value.

The sizes of fonts are controlled using the font-size property. The headings are changed from bold to normal using the font-weight property. We have also specified different choices of font using the font-family property.

For the main body text, we have increased the line-height property so there is a bigger gap between each line of text, thereby making it easier to read. In the first paragraph, the first-line pseudo-element allows us to style the first line of the introduction in bold.

Finally, the credit is italicized and aligned to the right-hand side of the page. Georgia, Times, serif; font-size: Arial, Verdana, sans-serif; line-height: The breed was used by the French Army as sentries, messengers and to search for wounded soldiers because of its fine sense of hearing.

Briards were used in the First World War almost to the point of extinction. Currently the population of briards is slowly recovering. Charlemagne, Napoleon, Thomas Jefferson and Lafayette all owned briards. X There is a limited choice of fonts that you can assume most people will have installed. X If you want to use a wider range of typefaces there are several options, but you need to have the right license to use them.

X You can control the space between lines of text, individual letters, and words. Text can also be aligned to the left, right, center, or justified. It can also be indented. X You can use pseudo-classes to change the style of an element when a user hovers over or clicks on text, or when they have visited a link. You can set several properties that affect the appearance of these boxes. In this chapter you will see how to: Traditionally, pixels have been the most popular method because they allow designers to accurately control their size.

CSS When you use percentages, the size of the box is relative to div. Designers have recently started to use percentages and ems more for R E S U LT measurements as they try to create designs that are flexible across devices which have different-sized screens.

This means that the size of the paragraph is pixels wide by pixels high. These are very helpful properties to ensure that the content of CSS pages are legible especially on td. For example, you can max-width: You may find it helpful to try this R E S U LT example out in your browser so that you can see what happens when you increase or decrease the size of the browser window.

Please note that these properties were first supported in IE7 and Firefox 2 so they will not work in older versions of these browsers. To control font-size: It can have is one of the most popular electric guitars of one of two values: It was designed by Leo The first example has the overflow property with a value of hidden.

The overflow property is particularly handy because some browsers allow users to adjust the size of the text to appear as large or as small as they want. If the text is set too large then the page can become an unreadable mess. Hiding the overflow on such boxes helps prevent items overlapping on the page.

You can set the the border of a box and any be 0 pixels wide. The border width of a margin to create a content contained within it. If you specify a width for a box, then the hello borders, margin, and padding are added to its width and height.

Designers refer to the space Or, imagine you had two boxes If the bottom margin of any between items on a page as sitting side by side each with box touches the top margin of white space. Imagine you had a black border. You would not another, the browser will render a border around a box.

You necessarily want the boxes to it differently than you might would not want the text to touch touch edges as this would make expect.

It will only show the this border or it would become the line look twice as thick on larger of the two margins. If both harder to read. CSS You can control the individual p. CSS border-top-color border-right-color p. You could also use HSL values to specify the color as shown on pages However, these were only introduced in CSS3 and will not work in older browsers.

If a width is p. As you can see, the second paragraph here is much easier R E S U LT to read because there is a space between the text and the border of the box.

The box is also wider because it has padding. You can specify different values for each side of a box using: Up until Internet Explorer 6, the width of the box would include the padding: You can see more about this on page If the width of a box width: This same shorthand shown Up until Internet Explorer 6, the width of the box would include the above can also be applied to padding and margins.

This text-align: You therefore also need to specify the text-align property on the centered box if you do not want the text inside it to be centered. Internet Explorer 6, however, has a quirk whereby it includes the padding and margins in the width of the box. In this case, the element acts as though it is not on the page at all although a user could In this example you can see This technique is often used to still see the content of the box if a list. Each item in the list is create navigation for a site, and they used the view source option usually treated as a block-level in this example a margin has in their browser.

If you do not want a blank space to appear, then you should use R E S U LT the display property with a value of none instead as covered on the previous page. Please note that anyone can view the contents of any elements whose visibility property has been set to hidden by viewing the source in their browser. I have added marks where it is CSS sliced in the example, taking 18 pixels from each corner p.

The corner slices are 11 11 11 11 stretch; always placed in the four corners -webkit-border-image: The URL of the image 11 11 11 11 round; 2: Where to slice the image border-image: The -moz-border-image and -webkit-border-image properties are not in the CSS specification but help earlier versions of Chrome, Firefox, and Safari display this effect. It works just like -moz-box-shadow: It must box-shadow: Chrome, Firefox, and Safari were quick to support this property using the -moz-box-shadow and -webkit-box-shadow properties.

These are not in the CSS specification but using them can help this style to work in these browsers. The value instruments such as bicycle bells, buzzing indicates the size of the radius organs, harpsichords, flutes, Electro-Theremin, in pixels. However, they width: You can specify individual values for each corner of a box using: For example, this will create a radius that is wider than it is tall: You can even create a circle by taking a square box and making the border-radius the same height as the square, as shown in the third shape on the left.

This is centered using the margin property, with a value of auto for the left and right margins. The logo and other content are centered using this same technique. To prevent the page from becoming too narrow or too wide, the min-width and max-width properties are used. The navigation is created using an unordered list. There are borders set to the top and bottom of this list to make it stand out.

The display property has been applied to each of the items in the list so they behave like inline rather than block-level elements. This enables the navigation links to sit next to each other horizontally. The padding property has been used to create space between each of the links. If we had not included a DOCTYPE declaration at the start of this page, the sizes of the boxes would be different to each other in Internet Explorer 6 because this browser did not implement the box model in the correct way.

X You can use CSS to control the dimensions of a box. X You can also control the borders, margin and padding for each box with CSS.

The tech book, redesigned...

X It is possible to hide elements using the display and visibility properties. X Block-level boxes can be made into inline boxes, and inline boxes made into block-level boxes. X Legibility can be improved by controlling the width of boxes containing text and the leading.

X CSS3 has introduced the ability to create image borders and rounded borders. This is the default behaviour if this property is not CSS used. A margin has been added to each list item so that there is a clear gap between each. Arial, Verdana, sans-serif; color: You can also tr. ALIGn nUMeRALS You can use the text-align property to align the content of any column that contains numbers to the right, so that large numbers are clearly distinguished from smaller ones.

In the first table on the left, you can see that the border of the empty cell is showing. In the second table, it is hidden. You can specify two values if desired to specify separate numbers for horizontal and vertical spacing. FIReFOx yours look more attractive and easier to use, more people are likely to fill it in. Also, when you come to look at a form in a few different browsers as shown on the right , you will see that each browser displays them differently.

CSS is commonly used to control the appearance of form elements. This is both to make them more attractive and to make them more consistent across different browsers PC: Ie It is most common to style: Styling text inputs and submit To achieve this, you might like to forms look consistent across buttons is fairly easy. It is download the CSS files available browsers. Although the solution harder to get select boxes, radio at http: Because there is a different image for each input, we are using an attribute selector looking for the value of the id attribute on each input.

You will learn more about background images and how to position them in Chapter Creating a consistent style -moz-linear-gradient top, a8cfce, beeae9 ; for all buttons helps users background: A gradient background: Gradients are covered on page In this case, the background changes, the text gets darker, and the thicker border is applied to the top of the button. In a long form they can width: In this example, the width of the fieldset forces the form elements to wrap onto a new line R E S U LT in the correct place.

If it were wider, the items might sit on one line. When the form only contains text inputs, by setting all of the text inputs to be the same width, as well as aligning all of the form content to the right, the fields line up and the labels are in a consistent place. For more complex forms, you will need a solution more like the one shown on these pages. For the text inputs, the border-bottom: Both have width: The float.

Therefore, the form controls next to them will line up. The text-align property is used to align the titles to the right, and padding is used to make sure there is a gap between the text in the title boxes and the form controls. The submit button is also aligned to the right. For example, using a crosshair on a link might confuse users because they are not used to seeing it.

Download this tool from: CSS STYLeS When you hover over an While you are hovering over When hovering over an element, element, a red outline will be an element, the structure will click with your mouse to display drawn around it, showing you be shown at the top of the the CSS. You will be shown the how much space the element window.

Here you can see the rules that apply to that element takes up. You can use it on code for your This can be very helpful when own site or when you want to writing CSS selectors to help you see what styles someone else is target the right element.

For the list of free poetry events near the start of the page, the bullet points are styled with an image. The space between each list item is increased using the line-height property. For the table, the gaps between cells are removed using the border- spacing property. The head of the table has a darker background, light text, and a dark 2-pixel line between it and the table content. Rounded corners on the table header are created using the: Alternate rows of the table have different shading, and texture is added with different borders on each side of the cell.

The labels of the form controls on the left also use the float property to ensure the form controls are vertically aligned. When the text boxes of the form receive focus, or the user hovers over it, the background color and border colors change. The submit button has also been styled to make it clear where people should submit the form. Arial, Verdana, sans-serif; font-size: X List markers can be given different appearances using the list-style-type and list-style image properties.

X Table cells can have different borders and spacing in different browsers, but there are properties you can use to control them and make them more consistent. X Forms are easier to use if the form controls are vertically aligned using CSS.

X Forms benefit from styles that make them feel more interactive. This involves learning about how designing for a screen can be different to designing for other mediums such as print. In this chapter we will: This box will either be a block-level box or an inline box. Block-level boxes start on a new line and act as the main building blocks of any layout, while inline boxes flow between surrounding text.

You can control how much space each box takes up by setting the width of the boxes and sometimes the height, too. To separate boxes, you can use borders, margins, padding, and background colors. Block-level elements start on a new line Lorem Ipsum Examples include: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit. Ut surrounding text enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Examples include: Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. For example, you might group together all of the elements that form the header of a site such as the logo and the main navigation. The containing element is always the direct Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod parent of that element. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Excepteur sint occaecat. Duis aute. You specify the positioning scheme using the position property in CSS. You can also float elements using the float property. It is taken out of the page than the previous one. This does not affect the position of the boxes and there is space does not affect the position of of any surrounding elements for two elements to sit side-by- surrounding elements; they stay as they simply ignore the side, they will not appear next in the position they would be in space it would have taken up.

This is the default in normal flow. Absolutely positioned elements behavior unless you tell the move as users scroll up and browser to do something else. Lorem Ipsum Lorem Ipsum Lorem Lorem ipsum dolor sit amet, Ipsum consectetur adipisicing elit, sed do Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, eiusmod tempor incididunt ut labore et consectetur adipisicing elit, sed do consectetur adipisicing elit, sed do dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut Ut enim ad minim veniam, quis nostrud Ut enim ad minim veniam, quis aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit Duis aute irure dolor in reprehenderit in voluptate velit.

The paragraphs appear one The second paragraph has been The heading is positioned to the after the other, vertically down pushed down and right from top right, and the paragraphs the page. You will meet these when we introduce the positioning schemes on the following pages. The floated Elements with fixed positioning element becomes a block-level do not affect the position of element around which other surrounding elements and they content can flow.

Similar articles

Copyright © 2019
DMCA |Contact Us