Html_Css
Html_Css
Formatting Element
<b> - Bold text
<strong> - Important text
<i> - Italic text
<em> - Emphasized text
<mark> - Marked text
<small> - Smaller text
<del> - Deleted text
<ins> - Inserted text
<sub> - Subscript text
<sup> - Superscript text
Các thẻ trong html
- Heading: <h1> <h6>
- Paragraph: <p>
- <span></span>: được sử dụng cho 1 đoạn văn nhỏ trong 1 đoạn văn
lớn
- <img scr=”” alt=””> <map></map>
<picture></picture>
- Link: <a href=”” target=” _self/_blank/_parent/_top”></a>
- <br>
- <hr>
- <pre></pre>
- Quotations: <blockquote cite=””></blockquote>
- Short quotations: <q></q>
- Abbreviations: <abbr title=””></abbr>
- Contact information: <address><address>
- Work title: <cite><cite>
- <bdo dir=””></bdo>
- Comment: <!-- Write your comments here -->
- Table: <colgroup> <col span=””></colgroup>
<table>
<caption>\</caption>
<thead>
<tr> : row
<th colspan="2"> </th> : heading
<th rowspan="2"> </th>
</tr>
</thead>
<tbody>
<tr>
<td></td>: cells
<td></td>
<td> </td>
</tr>
</tbody>
</table>
- List: <ul>, <ol>, <dl> attribure type = “1/A/a/I/i”
<ul type = “1”>
<li> </li>
<li></li>
<li> </li>
</ul>
<dl>
<dt> </dt>
<dd> </dd>
<dt> </dt>
<dd>dd>
</dl>
- <div>: group sections
<div>
<h2> </h2>
<p></p>
<p></p>
</div>
- <iframe src="url" name=”” title="description"></iframe>
Attribute class và id
HTML layout elements
File Path
CSS
Syntax: Selector { Property: value; }
Comment: /* */
Selector:
.class
#id
*
h1, p, div
Element.class
Background
Background-color:
Opacity: 0.0 1.0
Background-image: url(“”)
Background-repeat: no-repeat, repeat-x, repeat-y
Background-position:
Background-attachment: fixed, scroll
Background_size: cover, contain
Background shorthand: background: color, image, size/position.repeat
Border
Border-styte: top, right, bottom, left
dotted - Defines a dotted border
dashed - Defines a dashed border
solid - Defines a solid border
double - Defines a double border
groove - Defines a 3D grooved border. The effect depends on the
border-color value
ridge - Defines a 3D ridged border. The effect depends on the border-
color value
inset - Defines a 3D inset border. The effect depends on the border-
color value
outset - Defines a 3D outset border. The effect depends on the border-
color value
none - Defines no border
hidden - Defines a hidden border
Border-width: top, right, bottom, left
Border-color: top right, bottom, left
border-top-…:
border-right-…:
border-bottom-…:
border-left-…:
Border shorthand: border: width style color
Border-radius
Margin
Margin: auto, inherit
Margin-collapse
Padding
Height and Width Value:
auto - This is default. The browser calculates the height and width
length - Defines the height/width in px, cm, etc.
% - Defines the height/width in percent of the containing block
initial - Sets the height/width to its default value
inherit - The height/width will be inherited from its parent value
Max-width, min-width
Max-height, min-height
Box model
Outline
Text
Text alignment:
Text-align: left, right, center, justify
text-align-last: align the last line of a text.
Direction: rtl (right to left) unicode-bidi
Vertical-align: baseline, text-top, text-bottom, sub, super
Text decoration:
text-decoration-line: overline, line-through, underline, overline
underline
text-decoration-color:
text-decoration-style:
text-decoration-thickness: auto 5px 40%
text-decoration (shorthand): line color style thickness (none)
Text-transform: uppercase, lowercase, capitalize
Text spacing:
text-indent
letter-spacing
line-height
word-spacing
white-space: nowrap
text-shadow: horizontal vertical blur-effect color
Font
Font-familly
Font-style: normal, italic, oblique
Font-weight: normal, bold
Font-variant: normal, small-caps
Font-size: px, em, %, vw
Shorthand: style variant weight size/line-height familly
Icons
Font Awesome Icons: <script
src="https://kit.fontawesome.com/yourcode.js"
crossorigin="anonymous"></script>
Bootstrap Icons: <link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.cs
s">
Google Icons: <link rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons">
Links
a:link - a normal, unvisited link
a:visited - a link the user has visited
a:hover - a link when the user mouses over it
a:active - a link the moment it is clicked
Lists
List-style-type: circle square upper-roman lower-alpha none
List-style-image: url(“”)
List-style-position: outside, inside
Shorthand: type position image
Table
Border
Border-collapse: collapse
Width
Height
Text-align
Vertical-align
:hover selector
:nth-child(even - odd)
Overflow-x: auto
Border-spacing:
Empty-cells:
Caption-side:
Table-layout:
Display
Block: start on a new line and take up the full width
Inline: not start on a new and only take up as much as necessary, not
allow to set width and height, top and bottom margin/padding is not
repected.
None:
Inline-block: allow set height and width, top and bottom
margin/padding is repected, not add a line break
Visibility: hidden
Position
Static: (default) Không ảnh hưởng bởi các thuộc tính như top, right,
bottom, left.
Relative: Phần tử được định vị tương đối so với vị trí ban đầu của nó
Fixed:
Absolute: Phần tử được định vị tuyệt đối so với phần tử tổ tiên gần
nhất có position khác static.
Nếu không có tổ tiên nào như vậy, nó sẽ được định vị so với khung nhìn
(viewport).
Sticky:
(top, right, bottom, left)
Z-index
overflow
visible - Default. The overflow is not clipped. The content renders
outside the element's box
hidden - The overflow is clipped, and the rest of the content will be
invisible
scroll - The overflow is clipped, and a scrollbar is added to see the rest
of the content
auto - Similar to scroll, but it adds scrollbars only when necessary
overflow-wrap
overflow-x và overflow-y
Float
left - The element floats to the left of its container
right - The element floats to the right of its container
none - The element does not float (will be displayed just where it
occurs in the text). This is default
inherit - The element inherits the float value of its parent
Clear
The clear property specifies what should happen with the element that is
next to a floating element.
none - The element is not pushed below left or right floated elements.
This is default
left - The element is pushed below left floated elements
right - The element is pushed below right floated elements
both - The element is pushed below both left and right floated
elements
inherit - The element inherits the clear value from its parent
Combinators
Descendant combinator (space): (ex: div p) selects all <p>
elements inside <div> elements
Child combinator (>): (ex: div > p) selects all <p> elements that
are children of a <div> element
Next sibling combinator (+): (ex: div + p) selects the first <p>
element that are placed immediately after <div> elements
Subsequent-sibling combinator (~): (ex: div ~ p) selects all <p>
elements that are next siblings of <div> elements
Ex: (.class1.class2) select all element have both 2 these classes
Pseudo-classes
Syntax: selector:pseudo-class {
property: value;}
:link - unvisited link
:visited - visited link
:hover - mouse over link
:active - selected link
:first-child - the first child of the element
:lang
:root : đặt biến
Pseudo-elements
Syntax: selector::pseudo-element {
property: value;}
::first-line
::first-letter
::before - insert some content before the content of an element.
::after - insert some content after the content of an element.
::marker - selects the markers of list items.
::selection - the part of an element that is selected by a user.
Opacity
Opacity: 0.0 1.0
Navigation Bar
Box-sizing
- Kích thước element
- Theo mặc định, các phần tử có kích thước được tính dựa trên content-
box, có nghĩa là kích thước width và height chỉ áp dụng cho nội dung
(content) của phần tử, không bao gồm padding và border.
content-box (mặc định): Kích thước của phần tử chỉ tính từ nội dung
(content), không tính padding và border.
border-box: Kích thước của phần tử bao gồm nội dung, padding và
border. Khi sử dụng border-box, các phần tử sẽ giữ kích thước chính xác
mà bạn chỉ định (ví dụ: width: 100px), bao gồm cả padding và border.
Transform
translate: Di chuyển phần tử theo các trục.
translateX(px) - Di chuyển theo chiều ngang.
translateY(px) - Di chuyển theo chiều dọc.
translate(x, y) - Di chuyển đồng thời cả hai chiều.
rotate: Xoay phần tử theo góc độ.
Đơn vị là deg (độ), rad (radian).
scale: Thay đổi kích thước phần tử.
scaleX(number) - Thay đổi chiều ngang.
scaleY(number) - Thay đổi chiều dọc.
scale(x, y) - Thay đổi đồng thời cả hai.
skew: Nghiêng phần tử theo trục.
skewX(angle) - Nghiêng theo chiều ngang.
skewY(angle) - Nghiêng theo chiều dọc.
skew(x, y) - Nghiêng đồng thời cả hai.
Form
An HTML form is used to collect user input. The user input is most often sent
to a server for processing.
<form action=”” target=”” method=”” autocomplete=””
novalidate>
<label for=””></label>
<input name=”” value=”” readonly required placeholder pattern autofocus
disabled size=”” maxlength=”” step=”” multiple min=”” max=””
formnovalidate="formnovalidate" formtarget=" " formmethod=" "
formenctype=”” form=”” formaction="”></input>
</form>
Type: password, submit, reset, color, date, datetime-local, email, image, file,
month, number, range, search, tel, time, url, week
The input readonly attribute specifies that an input field is read-only (cannot
be modified)
<textarea>
<input type=”password”>
The action attribute defines the action to be performed when the form is
submitted.
Usually, the form data is sent to a file on the server when the user clicks on
the submit button.
<form action=””>
<textarea name=" " rows="" cols=""> </textarea>
<input type="submit">
</form>
Flexbox
The Flexible Box Layout Module, makes it easier to design flexible
responsive layout structure without using float or positioning, is a
layout method for arranging items in rows or columns.
A flexbox always consists of: flex container and flex items.
Flex container
Setting flex for attribute display of flex container
The CSS properties we use for the flex container are:
flex-direction: row, column, row-reverse, column-reverse.
flex-wrap: nowrap, wrap, wrap-reverse.
flex-flow: a shorthand property for setting both the flex-
direction and flex-wrap properties.
justify-content: center, flex-start, flex-end, space-around, space-
between, space-evenly (horizontally).
align-items: center, flex-start, flex-end, stretch, baseline, normal
(vertically).
align-content: center, stretch, flex-start, flex-end, space-around,
space-between, space-evenly
Flex items
order: The order value must be a number, default value is 0.
flex-grow: The value must be a number, default value is 0.
flex-shrink: The value must be a number, default value is 0.
flex-basis: initial length of a flex item.
Flex: a shorthand property for the flex-grow, flex-shrink, and flex-
basis properties.
align-self: overrides the default alignment set by the
container's align-items property.