Layouts with Stylesheets - Tutorial1. id selectors............................................................ 12. Centering elements using CSS ...............................23. Block-level to inline and vice versa........................34. Grouping CSS Selectors.........................................45. Nesting CSS Selectors............................................ 56. CSS Box Model ......................................................67. Reference..............................................................6id selectorsWe have learned how to use classes to give different styles to differen.t elements ofthe same tag in a web page. We will now introduce another way to do so. Supposethat you know that you only want to create a specific stylesheet for just one elementand nothing else. One way to accomplish that is to use an id selector. An id selectoronly gives styles to elements that have a matching id. For example:#right{text-align:right;}...
All text in here will be aligned to the right, because the idof this element matches that of the id selector in thestylesheet
The syntax for an id selector is similar to that of a class, where instead of a "." (e.g.,".container") we use "#" (e.g., "#container"). When the browser sees the # itautomatically looks for an element that has an id that matches the string following #.In the above example the browser applied the stylesheet to the
element becauseit's id matched.Just ...